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>
22 return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, sd_state, in vsp1_rwpf_get_crop()
26 /* -----------------------------------------------------------------------------
40 if (code->index >= ARRAY_SIZE(codes)) in vsp1_rwpf_enum_mbus_code()
41 return -EINVAL; in vsp1_rwpf_enum_mbus_code()
43 code->code = codes[code->index]; in vsp1_rwpf_enum_mbus_code()
56 RWPF_MIN_HEIGHT, rwpf->max_width, in vsp1_rwpf_enum_frame_size()
57 rwpf->max_height); in vsp1_rwpf_enum_frame_size()
69 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_set_format()
71 config = vsp1_entity_get_pad_config(&rwpf->entity, sd_state, in vsp1_rwpf_set_format()
72 fmt->which); in vsp1_rwpf_set_format()
74 ret = -EINVAL; in vsp1_rwpf_set_format()
79 if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && in vsp1_rwpf_set_format()
80 fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && in vsp1_rwpf_set_format()
81 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) in vsp1_rwpf_set_format()
82 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; in vsp1_rwpf_set_format()
84 format = vsp1_entity_get_pad_format(&rwpf->entity, config, fmt->pad); in vsp1_rwpf_set_format()
86 if (fmt->pad == RWPF_PAD_SOURCE) { in vsp1_rwpf_set_format()
91 format->code = fmt->format.code; in vsp1_rwpf_set_format()
92 fmt->format = *format; in vsp1_rwpf_set_format()
96 format->code = fmt->format.code; in vsp1_rwpf_set_format()
97 format->width = clamp_t(unsigned int, fmt->format.width, in vsp1_rwpf_set_format()
98 RWPF_MIN_WIDTH, rwpf->max_width); in vsp1_rwpf_set_format()
99 format->height = clamp_t(unsigned int, fmt->format.height, in vsp1_rwpf_set_format()
100 RWPF_MIN_HEIGHT, rwpf->max_height); in vsp1_rwpf_set_format()
101 format->field = V4L2_FIELD_NONE; in vsp1_rwpf_set_format()
102 format->colorspace = V4L2_COLORSPACE_SRGB; in vsp1_rwpf_set_format()
104 fmt->format = *format; in vsp1_rwpf_set_format()
106 if (rwpf->entity.type == VSP1_ENTITY_RPF) { in vsp1_rwpf_set_format()
111 crop->left = 0; in vsp1_rwpf_set_format()
112 crop->top = 0; in vsp1_rwpf_set_format()
113 crop->width = fmt->format.width; in vsp1_rwpf_set_format()
114 crop->height = fmt->format.height; in vsp1_rwpf_set_format()
118 format = vsp1_entity_get_pad_format(&rwpf->entity, config, in vsp1_rwpf_set_format()
120 *format = fmt->format; in vsp1_rwpf_set_format()
122 if (rwpf->flip.rotate) { in vsp1_rwpf_set_format()
123 format->width = fmt->format.height; in vsp1_rwpf_set_format()
124 format->height = fmt->format.width; in vsp1_rwpf_set_format()
128 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_set_format()
145 if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) in vsp1_rwpf_get_selection()
146 return -EINVAL; in vsp1_rwpf_get_selection()
148 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_get_selection()
150 config = vsp1_entity_get_pad_config(&rwpf->entity, sd_state, in vsp1_rwpf_get_selection()
151 sel->which); in vsp1_rwpf_get_selection()
153 ret = -EINVAL; in vsp1_rwpf_get_selection()
157 switch (sel->target) { in vsp1_rwpf_get_selection()
159 sel->r = *vsp1_rwpf_get_crop(rwpf, config); in vsp1_rwpf_get_selection()
163 format = vsp1_entity_get_pad_format(&rwpf->entity, config, in vsp1_rwpf_get_selection()
165 sel->r.left = 0; in vsp1_rwpf_get_selection()
166 sel->r.top = 0; in vsp1_rwpf_get_selection()
167 sel->r.width = format->width; in vsp1_rwpf_get_selection()
168 sel->r.height = format->height; in vsp1_rwpf_get_selection()
172 ret = -EINVAL; in vsp1_rwpf_get_selection()
177 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_get_selection()
195 if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK) in vsp1_rwpf_set_selection()
196 return -EINVAL; in vsp1_rwpf_set_selection()
198 if (sel->target != V4L2_SEL_TGT_CROP) in vsp1_rwpf_set_selection()
199 return -EINVAL; in vsp1_rwpf_set_selection()
201 mutex_lock(&rwpf->entity.lock); in vsp1_rwpf_set_selection()
203 config = vsp1_entity_get_pad_config(&rwpf->entity, sd_state, in vsp1_rwpf_set_selection()
204 sel->which); in vsp1_rwpf_set_selection()
206 ret = -EINVAL; in vsp1_rwpf_set_selection()
211 format = vsp1_entity_get_pad_format(&rwpf->entity, config, in vsp1_rwpf_set_selection()
218 if (format->code == MEDIA_BUS_FMT_AYUV8_1X32) { in vsp1_rwpf_set_selection()
219 sel->r.left = ALIGN(sel->r.left, 2); in vsp1_rwpf_set_selection()
220 sel->r.top = ALIGN(sel->r.top, 2); in vsp1_rwpf_set_selection()
221 sel->r.width = round_down(sel->r.width, 2); in vsp1_rwpf_set_selection()
222 sel->r.height = round_down(sel->r.height, 2); in vsp1_rwpf_set_selection()
225 sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); in vsp1_rwpf_set_selection()
226 sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); in vsp1_rwpf_set_selection()
227 sel->r.width = min_t(unsigned int, sel->r.width, in vsp1_rwpf_set_selection()
228 format->width - sel->r.left); in vsp1_rwpf_set_selection()
229 sel->r.height = min_t(unsigned int, sel->r.height, in vsp1_rwpf_set_selection()
230 format->height - sel->r.top); in vsp1_rwpf_set_selection()
233 *crop = sel->r; in vsp1_rwpf_set_selection()
236 format = vsp1_entity_get_pad_format(&rwpf->entity, config, in vsp1_rwpf_set_selection()
238 format->width = crop->width; in vsp1_rwpf_set_selection()
239 format->height = crop->height; in vsp1_rwpf_set_selection()
242 mutex_unlock(&rwpf->entity.lock); in vsp1_rwpf_set_selection()
256 /* -----------------------------------------------------------------------------
263 container_of(ctrl->handler, struct vsp1_rwpf, ctrls); in vsp1_rwpf_s_ctrl()
265 switch (ctrl->id) { in vsp1_rwpf_s_ctrl()
267 rwpf->alpha = ctrl->val; in vsp1_rwpf_s_ctrl()
280 v4l2_ctrl_handler_init(&rwpf->ctrls, ncontrols + 1); in vsp1_rwpf_init_ctrls()
281 v4l2_ctrl_new_std(&rwpf->ctrls, &vsp1_rwpf_ctrl_ops, in vsp1_rwpf_init_ctrls()
284 rwpf->entity.subdev.ctrl_handler = &rwpf->ctrls; in vsp1_rwpf_init_ctrls()
286 return rwpf->ctrls.error; in vsp1_rwpf_init_ctrls()