Lines Matching +full:top +full:- +full:left

1 // SPDX-License-Identifier: GPL-2.0+
3 * vsp1_rwpf.c -- R-Car VSP1 Read and Write Pixel Formatters
5 * Copyright (C) 2013-2014 Renesas Electronics Corporation
10 #include <media/v4l2-subdev.h>
19 /* -----------------------------------------------------------------------------
33 if (code->index >= ARRAY_SIZE(codes)) in vsp1_rwpf_enum_mbus_code()
34 return -EINVAL; in vsp1_rwpf_enum_mbus_code()
36 code->code = codes[code->index]; in vsp1_rwpf_enum_mbus_code()
49 RWPF_MIN_HEIGHT, rwpf->max_width, in vsp1_rwpf_enum_frame_size()
50 rwpf->max_height); in vsp1_rwpf_enum_frame_size()
62 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_set_format()
64 state = vsp1_entity_get_state(&rwpf->entity, sd_state, fmt->which); in vsp1_rwpf_set_format()
66 ret = -EINVAL; in vsp1_rwpf_set_format()
71 if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && in vsp1_rwpf_set_format()
72 fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && in vsp1_rwpf_set_format()
73 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) in vsp1_rwpf_set_format()
74 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; in vsp1_rwpf_set_format()
76 format = v4l2_subdev_state_get_format(state, fmt->pad); in vsp1_rwpf_set_format()
78 if (fmt->pad == RWPF_PAD_SOURCE) { in vsp1_rwpf_set_format()
83 format->code = fmt->format.code; in vsp1_rwpf_set_format()
84 fmt->format = *format; in vsp1_rwpf_set_format()
88 format->code = fmt->format.code; in vsp1_rwpf_set_format()
89 format->width = clamp_t(unsigned int, fmt->format.width, in vsp1_rwpf_set_format()
90 RWPF_MIN_WIDTH, rwpf->max_width); in vsp1_rwpf_set_format()
91 format->height = clamp_t(unsigned int, fmt->format.height, in vsp1_rwpf_set_format()
92 RWPF_MIN_HEIGHT, rwpf->max_height); in vsp1_rwpf_set_format()
93 format->field = V4L2_FIELD_NONE; in vsp1_rwpf_set_format()
94 format->colorspace = V4L2_COLORSPACE_SRGB; in vsp1_rwpf_set_format()
96 fmt->format = *format; in vsp1_rwpf_set_format()
98 if (rwpf->entity.type == VSP1_ENTITY_RPF) { in vsp1_rwpf_set_format()
103 crop->left = 0; in vsp1_rwpf_set_format()
104 crop->top = 0; in vsp1_rwpf_set_format()
105 crop->width = fmt->format.width; in vsp1_rwpf_set_format()
106 crop->height = fmt->format.height; in vsp1_rwpf_set_format()
111 *format = fmt->format; in vsp1_rwpf_set_format()
113 if (rwpf->flip.rotate) { in vsp1_rwpf_set_format()
114 format->width = fmt->format.height; in vsp1_rwpf_set_format()
115 format->height = fmt->format.width; in vsp1_rwpf_set_format()
119 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_set_format()
136 if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) in vsp1_rwpf_get_selection()
137 return -EINVAL; in vsp1_rwpf_get_selection()
139 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_get_selection()
141 state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which); in vsp1_rwpf_get_selection()
143 ret = -EINVAL; in vsp1_rwpf_get_selection()
147 switch (sel->target) { in vsp1_rwpf_get_selection()
149 sel->r = *v4l2_subdev_state_get_crop(state, RWPF_PAD_SINK); in vsp1_rwpf_get_selection()
154 sel->r.left = 0; in vsp1_rwpf_get_selection()
155 sel->r.top = 0; in vsp1_rwpf_get_selection()
156 sel->r.width = format->width; in vsp1_rwpf_get_selection()
157 sel->r.height = format->height; in vsp1_rwpf_get_selection()
161 ret = -EINVAL; in vsp1_rwpf_get_selection()
166 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_get_selection()
184 if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) in vsp1_rwpf_set_selection()
185 return -EINVAL; in vsp1_rwpf_set_selection()
187 if (sel->target != V4L2_SEL_TGT_CROP) in vsp1_rwpf_set_selection()
188 return -EINVAL; in vsp1_rwpf_set_selection()
190 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_set_selection()
192 state = vsp1_entity_get_state(&rwpf->entity, sd_state, sel->which); in vsp1_rwpf_set_selection()
194 ret = -EINVAL; in vsp1_rwpf_set_selection()
205 if (format->code == MEDIA_BUS_FMT_AYUV8_1X32) { in vsp1_rwpf_set_selection()
206 sel->r.left = ALIGN(sel->r.left, 2); in vsp1_rwpf_set_selection()
207 sel->r.top = ALIGN(sel->r.top, 2); in vsp1_rwpf_set_selection()
208 sel->r.width = round_down(sel->r.width, 2); in vsp1_rwpf_set_selection()
209 sel->r.height = round_down(sel->r.height, 2); in vsp1_rwpf_set_selection()
212 sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); in vsp1_rwpf_set_selection()
213 sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); in vsp1_rwpf_set_selection()
214 sel->r.width = min_t(unsigned int, sel->r.width, in vsp1_rwpf_set_selection()
215 format->width - sel->r.left); in vsp1_rwpf_set_selection()
216 sel->r.height = min_t(unsigned int, sel->r.height, in vsp1_rwpf_set_selection()
217 format->height - sel->r.top); in vsp1_rwpf_set_selection()
220 *crop = sel->r; in vsp1_rwpf_set_selection()
224 format->width = crop->width; in vsp1_rwpf_set_selection()
225 format->height = crop->height; in vsp1_rwpf_set_selection()
228 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_set_selection()
245 /* -----------------------------------------------------------------------------
252 container_of(ctrl->handler, struct vsp1_rwpf, ctrls); in vsp1_rwpf_s_ctrl()
254 switch (ctrl->id) { in vsp1_rwpf_s_ctrl()
256 rwpf->alpha = ctrl->val; in vsp1_rwpf_s_ctrl()
269 v4l2_ctrl_handler_init(&rwpf->ctrls, ncontrols + 1); in vsp1_rwpf_init_ctrls()
270 v4l2_ctrl_new_std(&rwpf->ctrls, &vsp1_rwpf_ctrl_ops, in vsp1_rwpf_init_ctrls()
273 rwpf->entity.subdev.ctrl_handler = &rwpf->ctrls; in vsp1_rwpf_init_ctrls()
275 return rwpf->ctrls.error; in vsp1_rwpf_init_ctrls()