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 /* -----------------------------------------------------------------------------
56 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_stream()
57 const struct vsp1_format_info *fmtinfo = rpf->fmtinfo; in rpf_configure_stream()
58 const struct v4l2_pix_format_mplane *format = &rpf->format; in rpf_configure_stream()
61 unsigned int left = 0; in rpf_configure_stream() local
62 unsigned int top = 0; in rpf_configure_stream() local
67 pstride = format->plane_fmt[0].bytesperline in rpf_configure_stream()
69 if (format->num_planes > 1) in rpf_configure_stream()
70 pstride |= format->plane_fmt[1].bytesperline in rpf_configure_stream()
78 if (pipe->interlaced) in rpf_configure_stream()
88 | (fmtinfo->hwfmt << VI6_RPF_INFMT_RDFMT_SHIFT); in rpf_configure_stream()
90 if (fmtinfo->swap_yc) in rpf_configure_stream()
92 if (fmtinfo->swap_uv) in rpf_configure_stream()
95 if (sink_format->code != source_format->code) in rpf_configure_stream()
99 vsp1_rpf_write(rpf, dlb, VI6_RPF_DSWAP, fmtinfo->swap); in rpf_configure_stream()
101 if (entity->vsp1->info->gen == 4) { in rpf_configure_stream()
106 switch (fmtinfo->fourcc) { in rpf_configure_stream()
154 if (pipe->brx) { in rpf_configure_stream()
157 compose = v4l2_subdev_state_get_compose(pipe->brx->state, in rpf_configure_stream()
158 rpf->brx_input); in rpf_configure_stream()
159 left = compose->left; in rpf_configure_stream()
160 top = compose->top; in rpf_configure_stream()
163 if (pipe->interlaced) in rpf_configure_stream()
164 top /= 2; in rpf_configure_stream()
167 (left << VI6_RPF_LOC_HCOORD_SHIFT) | in rpf_configure_stream()
168 (top << VI6_RPF_LOC_VCOORD_SHIFT)); in rpf_configure_stream()
194 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED in rpf_configure_stream()
197 if (entity->vsp1->info->gen >= 3) { in rpf_configure_stream()
200 if (fmtinfo->alpha) { in rpf_configure_stream()
209 bool premultiplied = format->flags in rpf_configure_stream()
227 rpf->mult_alpha = mult; in rpf_configure_stream()
238 const struct v4l2_pix_format_mplane *format = &rpf->format; in vsp1_rpf_configure_autofld()
247 /* Re-index our auto_fld to match the current RPF. */ in vsp1_rpf_configure_autofld()
248 auto_fld = cmd->data; in vsp1_rpf_configure_autofld()
249 auto_fld = &auto_fld[rpf->entity.index]; in vsp1_rpf_configure_autofld()
251 auto_fld->top_y0 = rpf->mem.addr[0]; in vsp1_rpf_configure_autofld()
252 auto_fld->top_c0 = rpf->mem.addr[1]; in vsp1_rpf_configure_autofld()
253 auto_fld->top_c1 = rpf->mem.addr[2]; in vsp1_rpf_configure_autofld()
255 offset_y = format->plane_fmt[0].bytesperline; in vsp1_rpf_configure_autofld()
256 offset_c = format->plane_fmt[1].bytesperline; in vsp1_rpf_configure_autofld()
258 auto_fld->bottom_y0 = rpf->mem.addr[0] + offset_y; in vsp1_rpf_configure_autofld()
259 auto_fld->bottom_c0 = rpf->mem.addr[1] + offset_c; in vsp1_rpf_configure_autofld()
260 auto_fld->bottom_c1 = rpf->mem.addr[2] + offset_c; in vsp1_rpf_configure_autofld()
262 cmd->flags |= VI6_DL_EXT_AUTOFLD_INT | BIT(16 + rpf->entity.index); in vsp1_rpf_configure_autofld()
270 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_frame()
273 rpf->alpha << VI6_RPF_VRTCOL_SET_LAYA_SHIFT); in rpf_configure_frame()
274 vsp1_rpf_write(rpf, dlb, VI6_RPF_MULT_ALPHA, rpf->mult_alpha | in rpf_configure_frame()
275 (rpf->alpha << VI6_RPF_MULT_ALPHA_RATIO_SHIFT)); in rpf_configure_frame()
277 vsp1_pipeline_propagate_alpha(pipe, dlb, rpf->alpha); in rpf_configure_frame()
286 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_configure_partition()
287 struct vsp1_rwpf_memory mem = rpf->mem; in rpf_configure_partition()
288 struct vsp1_device *vsp1 = rpf->entity.vsp1; in rpf_configure_partition()
289 const struct vsp1_format_info *fmtinfo = rpf->fmtinfo; in rpf_configure_partition()
290 const struct v4l2_pix_format_mplane *format = &rpf->format; in rpf_configure_partition()
291 struct v4l2_rect crop = partition->rpf[rpf->entity.index]; in rpf_configure_partition()
297 * rectangle top left corner in the plane buffer. Only two in rpf_configure_partition()
302 if (pipe->interlaced) { in rpf_configure_partition()
303 crop.height = round_down(crop.height / 2, fmtinfo->vsub); in rpf_configure_partition()
304 crop.top = round_down(crop.top / 2, fmtinfo->vsub); in rpf_configure_partition()
314 mem.addr[0] += crop.top * format->plane_fmt[0].bytesperline in rpf_configure_partition()
315 + crop.left * fmtinfo->bpp[0] / 8; in rpf_configure_partition()
317 if (format->num_planes > 1) { in rpf_configure_partition()
318 unsigned int bpl = format->plane_fmt[1].bytesperline; in rpf_configure_partition()
321 offset = crop.top / fmtinfo->vsub * bpl in rpf_configure_partition()
322 + crop.left / fmtinfo->hsub * fmtinfo->bpp[1] / 8; in rpf_configure_partition()
328 * On Gen3+ hardware the SPUVS bit has no effect on 3-planar in rpf_configure_partition()
331 if (vsp1->info->gen >= 3 && format->num_planes == 3 && in rpf_configure_partition()
332 fmtinfo->swap_uv) in rpf_configure_partition()
336 * Interlaced pipelines will use the extended pre-cmd to process in rpf_configure_partition()
339 if (pipe->interlaced) { in rpf_configure_partition()
355 struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); in rpf_partition()
356 struct v4l2_rect *rpf_rect = &partition->rpf[rpf->entity.index]; in rpf_partition()
364 * our crop to provide a 'sub-crop' matching the expected partition in rpf_partition()
369 if (pipe->partitions > 1) { in rpf_partition()
370 rpf_rect->width = window->width; in rpf_partition()
371 rpf_rect->left += window->left; in rpf_partition()
382 /* -----------------------------------------------------------------------------
392 rpf = devm_kzalloc(vsp1->dev, sizeof(*rpf), GFP_KERNEL); in vsp1_rpf_create()
394 return ERR_PTR(-ENOMEM); in vsp1_rpf_create()
396 rpf->max_width = RPF_MAX_WIDTH; in vsp1_rpf_create()
397 rpf->max_height = RPF_MAX_HEIGHT; in vsp1_rpf_create()
399 rpf->entity.ops = &rpf_entity_ops; in vsp1_rpf_create()
400 rpf->entity.type = VSP1_ENTITY_RPF; in vsp1_rpf_create()
401 rpf->entity.index = index; in vsp1_rpf_create()
404 ret = vsp1_entity_init(vsp1, &rpf->entity, name, 2, &vsp1_rwpf_subdev_ops, in vsp1_rpf_create()
412 dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n", in vsp1_rpf_create()
417 v4l2_ctrl_handler_setup(&rpf->ctrls); in vsp1_rpf_create()
422 vsp1_entity_destroy(&rpf->entity); in vsp1_rpf_create()