Lines Matching +full:reg +full:- +full:names
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 /* -----------------------------------------------------------------------------
29 static inline u32 vsp1_uif_read(struct vsp1_uif *uif, u32 reg) in vsp1_uif_read() argument
31 return vsp1_read(uif->entity.vsp1, in vsp1_uif_read()
32 uif->entity.index * VI6_UIF_OFFSET + reg); in vsp1_uif_read()
36 struct vsp1_dl_body *dlb, u32 reg, u32 data) in vsp1_uif_write() argument
38 vsp1_dl_body_write(dlb, reg + uif->entity.index * VI6_UIF_OFFSET, data); in vsp1_uif_write()
46 /* -----------------------------------------------------------------------------
92 if (sel->pad != UIF_PAD_SINK) in uif_get_selection()
93 return -EINVAL; in uif_get_selection()
95 mutex_lock(&uif->entity.lock); in uif_get_selection()
97 config = vsp1_entity_get_pad_config(&uif->entity, cfg, sel->which); in uif_get_selection()
99 ret = -EINVAL; in uif_get_selection()
103 switch (sel->target) { in uif_get_selection()
106 format = vsp1_entity_get_pad_format(&uif->entity, config, 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 = *vsp1_entity_get_pad_selection(&uif->entity, config, in uif_get_selection()
116 sel->pad, sel->target); in uif_get_selection()
120 ret = -EINVAL; in uif_get_selection()
125 mutex_unlock(&uif->entity.lock); in uif_get_selection()
139 if (sel->pad != UIF_PAD_SINK || in uif_set_selection()
140 sel->target != V4L2_SEL_TGT_CROP) in uif_set_selection()
141 return -EINVAL; in uif_set_selection()
143 mutex_lock(&uif->entity.lock); in uif_set_selection()
145 config = vsp1_entity_get_pad_config(&uif->entity, cfg, sel->which); in uif_set_selection()
147 ret = -EINVAL; in uif_set_selection()
152 format = vsp1_entity_get_pad_format(&uif->entity, config, UIF_PAD_SINK); in uif_set_selection()
154 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1); in uif_set_selection()
155 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1); in uif_set_selection()
156 sel->r.width = clamp_t(unsigned int, sel->r.width, UIF_MIN_SIZE, in uif_set_selection()
157 format->width - sel->r.left); in uif_set_selection()
158 sel->r.height = clamp_t(unsigned int, sel->r.height, UIF_MIN_SIZE, in uif_set_selection()
159 format->height - sel->r.top); in uif_set_selection()
162 selection = vsp1_entity_get_pad_selection(&uif->entity, config, in uif_set_selection()
163 sel->pad, V4L2_SEL_TGT_CROP); in uif_set_selection()
164 *selection = sel->r; in uif_set_selection()
167 mutex_unlock(&uif->entity.lock); in uif_set_selection()
171 /* -----------------------------------------------------------------------------
189 /* -----------------------------------------------------------------------------
198 struct vsp1_uif *uif = to_uif(&entity->subdev); in uif_configure_stream()
206 crop = vsp1_entity_get_pad_selection(entity, entity->config, 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()
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()
257 /* The datasheet names the two UIF instances UIF4 and UIF5. */ in vsp1_uif_create()
259 ret = vsp1_entity_init(vsp1, &uif->entity, name, 2, &uif_ops, in vsp1_uif_create()