Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l: vsp1: bru: Make the background color configurable

Expose the background color to userspace through the V4L2_CID_BG_COLOR
control.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
a16e2794 9aca813e

+49 -5
+46 -5
drivers/media/platform/vsp1/vsp1_bru.c
··· 38 38 } 39 39 40 40 /* ----------------------------------------------------------------------------- 41 + * Controls 42 + */ 43 + 44 + static int bru_s_ctrl(struct v4l2_ctrl *ctrl) 45 + { 46 + struct vsp1_bru *bru = 47 + container_of(ctrl->handler, struct vsp1_bru, ctrls); 48 + 49 + if (!vsp1_entity_is_streaming(&bru->entity)) 50 + return 0; 51 + 52 + switch (ctrl->id) { 53 + case V4L2_CID_BG_COLOR: 54 + vsp1_bru_write(bru, VI6_BRU_VIRRPF_COL, ctrl->val | 55 + (0xff << VI6_BRU_VIRRPF_COL_A_SHIFT)); 56 + break; 57 + } 58 + 59 + return 0; 60 + } 61 + 62 + static const struct v4l2_ctrl_ops bru_ctrl_ops = { 63 + .s_ctrl = bru_s_ctrl, 64 + }; 65 + 66 + /* ----------------------------------------------------------------------------- 41 67 * V4L2 Subdevice Core Operations 42 68 */ 43 69 ··· 74 48 struct v4l2_mbus_framefmt *format; 75 49 unsigned int flags; 76 50 unsigned int i; 51 + int ret; 52 + 53 + ret = vsp1_entity_set_streaming(&bru->entity, enable); 54 + if (ret < 0) 55 + return ret; 77 56 78 57 if (!enable) 79 58 return 0; ··· 99 68 flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ? 100 69 0 : VI6_BRU_INCTRL_NRM); 101 70 102 - /* Set the background position to cover the whole output image and 103 - * set its color to opaque black. 104 - */ 71 + /* Set the background position to cover the whole output image. */ 105 72 vsp1_bru_write(bru, VI6_BRU_VIRRPF_SIZE, 106 73 (format->width << VI6_BRU_VIRRPF_SIZE_HSIZE_SHIFT) | 107 74 (format->height << VI6_BRU_VIRRPF_SIZE_VSIZE_SHIFT)); 108 75 vsp1_bru_write(bru, VI6_BRU_VIRRPF_LOC, 0); 109 - vsp1_bru_write(bru, VI6_BRU_VIRRPF_COL, 110 - 0xff << VI6_BRU_VIRRPF_COL_A_SHIFT); 111 76 112 77 /* Route BRU input 1 as SRC input to the ROP unit and configure the ROP 113 78 * unit with a NOP operation to make BRU input 1 available as the ··· 433 406 subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 434 407 435 408 vsp1_entity_init_formats(subdev, NULL); 409 + 410 + /* Initialize the control handler. */ 411 + v4l2_ctrl_handler_init(&bru->ctrls, 1); 412 + v4l2_ctrl_new_std(&bru->ctrls, &bru_ctrl_ops, V4L2_CID_BG_COLOR, 413 + 0, 0xffffff, 1, 0); 414 + 415 + bru->entity.subdev.ctrl_handler = &bru->ctrls; 416 + 417 + if (bru->ctrls.error) { 418 + dev_err(vsp1->dev, "bru: failed to initialize controls\n"); 419 + ret = bru->ctrls.error; 420 + vsp1_entity_destroy(&bru->entity); 421 + return ERR_PTR(ret); 422 + } 436 423 437 424 return bru; 438 425 }
+3
drivers/media/platform/vsp1/vsp1_bru.h
··· 14 14 #define __VSP1_BRU_H__ 15 15 16 16 #include <media/media-entity.h> 17 + #include <media/v4l2-ctrls.h> 17 18 #include <media/v4l2-subdev.h> 18 19 19 20 #include "vsp1_entity.h" ··· 27 26 28 27 struct vsp1_bru { 29 28 struct vsp1_entity entity; 29 + 30 + struct v4l2_ctrl_handler ctrls; 30 31 31 32 struct { 32 33 struct vsp1_rwpf *rpf;