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()
107 format = vsp1_entity_get_pad_format(&uif->entity, state, in uif_get_selection()
109 sel->r.left = 0; in uif_get_selection()
110 sel->r.top = 0; in uif_get_selection()
111 sel->r.width = format->width; in uif_get_selection()
112 sel->r.height = format->height; in uif_get_selection()
116 sel->r = *vsp1_entity_get_pad_selection(&uif->entity, state, in uif_get_selection()
117 sel->pad, sel->target); in uif_get_selection()
121 ret = -EINVAL; in uif_get_selection()
126 mutex_unlock(&uif->entity.lock); in uif_get_selection()
140 if (sel->pad != UIF_PAD_SINK || in uif_set_selection()
141 sel->target != V4L2_SEL_TGT_CROP) in uif_set_selection()
142 return -EINVAL; in uif_set_selection()
144 mutex_lock(&uif->entity.lock); in uif_set_selection()
146 state = vsp1_entity_get_state(&uif->entity, sd_state, sel->which); in uif_set_selection()
148 ret = -EINVAL; in uif_set_selection()
153 format = vsp1_entity_get_pad_format(&uif->entity, state, UIF_PAD_SINK); in uif_set_selection()
155 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1); in uif_set_selection()
156 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1); in uif_set_selection()
157 sel->r.width = clamp_t(unsigned int, sel->r.width, UIF_MIN_SIZE, in uif_set_selection()
158 format->width - sel->r.left); in uif_set_selection()
159 sel->r.height = clamp_t(unsigned int, sel->r.height, UIF_MIN_SIZE, in uif_set_selection()
160 format->height - sel->r.top); in uif_set_selection()
163 selection = vsp1_entity_get_pad_selection(&uif->entity, state, in uif_set_selection()
164 sel->pad, V4L2_SEL_TGT_CROP); in uif_set_selection()
165 *selection = sel->r; in uif_set_selection()
168 mutex_unlock(&uif->entity.lock); in uif_set_selection()
172 /* -----------------------------------------------------------------------------
189 /* -----------------------------------------------------------------------------
198 struct vsp1_uif *uif = to_uif(&entity->subdev); in uif_configure_stream()
200 unsigned int left; in uif_configure_stream() local
206 crop = vsp1_entity_get_pad_selection(entity, entity->state, in uif_configure_stream()
209 left = crop->left; in uif_configure_stream()
210 width = crop->width; in uif_configure_stream()
212 /* On M3-W the horizontal coordinates are twice the register value. */ in uif_configure_stream()
213 if (uif->m3w_quirk) { in uif_configure_stream()
214 left /= 2; in uif_configure_stream()
218 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSPXR, left); in uif_configure_stream()
219 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSPYR, crop->top); in uif_configure_stream()
221 vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMSZYR, crop->height); in uif_configure_stream()
231 /* -----------------------------------------------------------------------------
246 uif = devm_kzalloc(vsp1->dev, sizeof(*uif), GFP_KERNEL); in vsp1_uif_create()
248 return ERR_PTR(-ENOMEM); in vsp1_uif_create()
251 uif->m3w_quirk = true; in vsp1_uif_create()
253 uif->entity.ops = &uif_entity_ops; in vsp1_uif_create()
254 uif->entity.type = VSP1_ENTITY_UIF; in vsp1_uif_create()
255 uif->entity.index = index; in vsp1_uif_create()
259 ret = vsp1_entity_init(vsp1, &uif->entity, name, 2, &uif_ops, in vsp1_uif_create()