Lines Matching +full:top +full:- +full:left
1 // SPDX-License-Identifier: GPL-2.0+
3 * vsp1_uif.c -- R-Car VSP1 User Logic Interface
5 * Copyright (C) 2017-2018 Laurent Pinchart
14 #include <media/media-entity.h>
15 #include <media/v4l2-subdev.h>
25 /* -----------------------------------------------------------------------------
31 return vsp1_read(uif->entity.vsp1, in vsp1_uif_read()
32 uif->entity.index * VI6_UIF_OFFSET + reg); in vsp1_uif_read()
38 vsp1_dl_body_write(dlb, reg + uif->entity.index * VI6_UIF_OFFSET, data); in vsp1_uif_write()
46 /* -----------------------------------------------------------------------------
93 if (sel->pad != UIF_PAD_SINK) in uif_get_selection()
94 return -EINVAL; in uif_get_selection()
96 mutex_lock(&uif->entity.lock); in uif_get_selection()
98 state = vsp1_entity_get_state(&uif->entity, sd_state, sel->which); in uif_get_selection()
100 ret = -EINVAL; in uif_get_selection()
104 switch (sel->target) { in uif_get_selection()
108 sel->r.left = 0; in uif_get_selection()
109 sel->r.top = 0; in uif_get_selection()
110 sel->r.width = format->width; in uif_get_selection()
111 sel->r.height = format->height; in uif_get_selection()
115 sel->r = *v4l2_subdev_state_get_crop(state, sel->pad); in uif_get_selection()
119 ret = -EINVAL; in uif_get_selection()
124 mutex_unlock(&uif->entity.lock); in uif_get_selection()
138 if (sel->pad != UIF_PAD_SINK || in uif_set_selection()
139 sel->target != V4L2_SEL_TGT_CROP) in uif_set_selection()
140 return -EINVAL; in uif_set_selection()
142 mutex_lock(&uif->entity.lock); in uif_set_selection()
144 state = vsp1_entity_get_state(&uif->entity, sd_state, sel->which); in uif_set_selection()
146 ret = -EINVAL; in uif_set_selection()
153 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1); in uif_set_selection()
154 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1); in uif_set_selection()
155 sel->r.width = clamp_t(unsigned int, sel->r.width, UIF_MIN_SIZE, in uif_set_selection()
156 format->width - sel->r.left); in uif_set_selection()
157 sel->r.height = clamp_t(unsigned int, sel->r.height, UIF_MIN_SIZE, in uif_set_selection()
158 format->height - sel->r.top); in uif_set_selection()
161 selection = v4l2_subdev_state_get_crop(state, sel->pad); in uif_set_selection()
162 *selection = sel->r; in uif_set_selection()
165 mutex_unlock(&uif->entity.lock); in uif_set_selection()
169 /* -----------------------------------------------------------------------------
186 /* -----------------------------------------------------------------------------
196 struct vsp1_uif *uif = to_uif(&entity->subdev); in uif_configure_stream()
198 unsigned int left; in uif_configure_stream() local
206 left = crop->left; in uif_configure_stream()
207 width = crop->width; in uif_configure_stream()
209 /* On M3-W the horizontal coordinates are twice the register value. */ in uif_configure_stream()
210 if (uif->m3w_quirk) { in uif_configure_stream()
211 left /= 2; in uif_configure_stream()
215 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSPXR, left); in uif_configure_stream()
216 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSPYR, crop->top); in uif_configure_stream()
218 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSZYR, crop->height); in uif_configure_stream()
228 /* -----------------------------------------------------------------------------
243 uif = devm_kzalloc(vsp1->dev, sizeof(*uif), GFP_KERNEL); in vsp1_uif_create()
245 return ERR_PTR(-ENOMEM); in vsp1_uif_create()
248 uif->m3w_quirk = true; in vsp1_uif_create()
250 uif->entity.ops = &uif_entity_ops; in vsp1_uif_create()
251 uif->entity.type = VSP1_ENTITY_UIF; in vsp1_uif_create()
252 uif->entity.index = index; in vsp1_uif_create()
256 ret = vsp1_entity_init(vsp1, &uif->entity, name, 2, &uif_ops, in vsp1_uif_create()