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

1 // SPDX-License-Identifier: GPL-2.0+
3 * vsp1_rpf.c -- R-Car VSP1 Read Pixel Formatter
5 * Copyright (C) 2013-2014 Renesas Electronics Corporation
12 #include <media/v4l2-subdev.h>
35 /* -----------------------------------------------------------------------------
42 vsp1_dl_body_write(dlb, reg + rpf->entity.index * VI6_RPF_OFFSET, in vsp1_rpf_write()
46 /* -----------------------------------------------------------------------------
55 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_stream()
56 const struct vsp1_format_info *fmtinfo = rpf->fmtinfo; in rpf_configure_stream()
57 const struct v4l2_pix_format_mplane *format = &rpf->format; in rpf_configure_stream()
60 unsigned int left = 0; in rpf_configure_stream() local
61 unsigned int top = 0; in rpf_configure_stream() local
66 pstride = format->plane_fmt[0].bytesperline in rpf_configure_stream()
68 if (format->num_planes > 1) in rpf_configure_stream()
69 pstride |= format->plane_fmt[1].bytesperline in rpf_configure_stream()
77 if (pipe->interlaced) in rpf_configure_stream()
83 sink_format = vsp1_entity_get_pad_format(&rpf->entity, in rpf_configure_stream()
84 rpf->entity.state, in rpf_configure_stream()
86 source_format = vsp1_entity_get_pad_format(&rpf->entity, in rpf_configure_stream()
87 rpf->entity.state, in rpf_configure_stream()
91 | (fmtinfo->hwfmt << VI6_RPF_INFMT_RDFMT_SHIFT); in rpf_configure_stream()
93 if (fmtinfo->swap_yc) in rpf_configure_stream()
95 if (fmtinfo->swap_uv) in rpf_configure_stream()
98 if (sink_format->code != source_format->code) in rpf_configure_stream()
102 vsp1_rpf_write(rpf, dlb, VI6_RPF_DSWAP, fmtinfo->swap); in rpf_configure_stream()
104 if (entity->vsp1->info->gen == 4) { in rpf_configure_stream()
109 switch (fmtinfo->fourcc) { in rpf_configure_stream()
157 if (pipe->brx) { in rpf_configure_stream()
160 compose = vsp1_entity_get_pad_selection(pipe->brx, in rpf_configure_stream()
161 pipe->brx->state, in rpf_configure_stream()
162 rpf->brx_input, in rpf_configure_stream()
164 left = compose->left; in rpf_configure_stream()
165 top = compose->top; in rpf_configure_stream()
168 if (pipe->interlaced) in rpf_configure_stream()
169 top /= 2; in rpf_configure_stream()
172 (left << VI6_RPF_LOC_HCOORD_SHIFT) | in rpf_configure_stream()
173 (top << VI6_RPF_LOC_VCOORD_SHIFT)); in rpf_configure_stream()
199 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED in rpf_configure_stream()
202 if (entity->vsp1->info->gen >= 3) { in rpf_configure_stream()
205 if (fmtinfo->alpha) { in rpf_configure_stream()
214 bool premultiplied = format->flags in rpf_configure_stream()
232 rpf->mult_alpha = mult; in rpf_configure_stream()
243 const struct v4l2_pix_format_mplane *format = &rpf->format; in vsp1_rpf_configure_autofld()
252 /* Re-index our auto_fld to match the current RPF. */ in vsp1_rpf_configure_autofld()
253 auto_fld = cmd->data; in vsp1_rpf_configure_autofld()
254 auto_fld = &auto_fld[rpf->entity.index]; in vsp1_rpf_configure_autofld()
256 auto_fld->top_y0 = rpf->mem.addr[0]; in vsp1_rpf_configure_autofld()
257 auto_fld->top_c0 = rpf->mem.addr[1]; in vsp1_rpf_configure_autofld()
258 auto_fld->top_c1 = rpf->mem.addr[2]; in vsp1_rpf_configure_autofld()
260 offset_y = format->plane_fmt[0].bytesperline; in vsp1_rpf_configure_autofld()
261 offset_c = format->plane_fmt[1].bytesperline; in vsp1_rpf_configure_autofld()
263 auto_fld->bottom_y0 = rpf->mem.addr[0] + offset_y; in vsp1_rpf_configure_autofld()
264 auto_fld->bottom_c0 = rpf->mem.addr[1] + offset_c; in vsp1_rpf_configure_autofld()
265 auto_fld->bottom_c1 = rpf->mem.addr[2] + offset_c; in vsp1_rpf_configure_autofld()
267 cmd->flags |= VI6_DL_EXT_AUTOFLD_INT | BIT(16 + rpf->entity.index); in vsp1_rpf_configure_autofld()
275 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_frame()
278 rpf->alpha << VI6_RPF_VRTCOL_SET_LAYA_SHIFT); in rpf_configure_frame()
279 vsp1_rpf_write(rpf, dlb, VI6_RPF_MULT_ALPHA, rpf->mult_alpha | in rpf_configure_frame()
280 (rpf->alpha << VI6_RPF_MULT_ALPHA_RATIO_SHIFT)); in rpf_configure_frame()
282 vsp1_pipeline_propagate_alpha(pipe, dlb, rpf->alpha); in rpf_configure_frame()
290 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_partition()
291 struct vsp1_rwpf_memory mem = rpf->mem; in rpf_configure_partition()
292 struct vsp1_device *vsp1 = rpf->entity.vsp1; in rpf_configure_partition()
293 const struct vsp1_format_info *fmtinfo = rpf->fmtinfo; in rpf_configure_partition()
294 const struct v4l2_pix_format_mplane *format = &rpf->format; in rpf_configure_partition()
301 * rectangle top left corner in the plane buffer. Only two in rpf_configure_partition()
305 crop = *vsp1_rwpf_get_crop(rpf, rpf->entity.state); in rpf_configure_partition()
313 * To achieve this, we adjust our crop to provide a 'sub-crop' in rpf_configure_partition()
314 * matching the expected partition window. Only 'left' and in rpf_configure_partition()
317 if (pipe->partitions > 1) { in rpf_configure_partition()
318 crop.width = pipe->partition->rpf.width; in rpf_configure_partition()
319 crop.left += pipe->partition->rpf.left; in rpf_configure_partition()
322 if (pipe->interlaced) { in rpf_configure_partition()
323 crop.height = round_down(crop.height / 2, fmtinfo->vsub); in rpf_configure_partition()
324 crop.top = round_down(crop.top / 2, fmtinfo->vsub); in rpf_configure_partition()
334 mem.addr[0] += crop.top * format->plane_fmt[0].bytesperline in rpf_configure_partition()
335 + crop.left * fmtinfo->bpp[0] / 8; in rpf_configure_partition()
337 if (format->num_planes > 1) { in rpf_configure_partition()
338 unsigned int bpl = format->plane_fmt[1].bytesperline; in rpf_configure_partition()
341 offset = crop.top / fmtinfo->vsub * bpl in rpf_configure_partition()
342 + crop.left / fmtinfo->hsub * fmtinfo->bpp[1] / 8; in rpf_configure_partition()
348 * On Gen3+ hardware the SPUVS bit has no effect on 3-planar in rpf_configure_partition()
351 if (vsp1->info->gen >= 3 && format->num_planes == 3 && in rpf_configure_partition()
352 fmtinfo->swap_uv) in rpf_configure_partition()
356 * Interlaced pipelines will use the extended pre-cmd to process in rpf_configure_partition()
359 if (pipe->interlaced) { in rpf_configure_partition()
374 partition->rpf = *window; in rpf_partition()
384 /* -----------------------------------------------------------------------------
394 rpf = devm_kzalloc(vsp1->dev, sizeof(*rpf), GFP_KERNEL); in vsp1_rpf_create()
396 return ERR_PTR(-ENOMEM); in vsp1_rpf_create()
398 rpf->max_width = RPF_MAX_WIDTH; in vsp1_rpf_create()
399 rpf->max_height = RPF_MAX_HEIGHT; in vsp1_rpf_create()
401 rpf->entity.ops = &rpf_entity_ops; in vsp1_rpf_create()
402 rpf->entity.type = VSP1_ENTITY_RPF; in vsp1_rpf_create()
403 rpf->entity.index = index; in vsp1_rpf_create()
406 ret = vsp1_entity_init(vsp1, &rpf->entity, name, 2, &vsp1_rwpf_subdev_ops, in vsp1_rpf_create()
414 dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n", in vsp1_rpf_create()
419 v4l2_ctrl_handler_setup(&rpf->ctrls); in vsp1_rpf_create()
424 vsp1_entity_destroy(&rpf->entity); in vsp1_rpf_create()