Skip to content

Commit

Permalink
media: xilinx: Create menu based control for foreground pattern
Browse files Browse the repository at this point in the history
In TPG v7.0 cross-hair and moving box are mutually exclusive.
Menu based control allows the foreground pattern to have
exclusive states i.e  no overlay, moving box and cross-hair.

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com>
Tested-by: Christian Kohn <christian.kohn@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
  • Loading branch information
radheyxilinx authored and Michal Simek committed Dec 2, 2015
1 parent 852861e commit bd2f3fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
63 changes: 26 additions & 37 deletions drivers/media/platform/xilinx/xilinx-tpg.c
Expand Up @@ -136,8 +136,6 @@ struct xtpg_device {
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *pattern;
struct v4l2_ctrl *moving_box;
struct v4l2_ctrl *cross_hair;
bool streaming;
bool is_hls;

Expand Down Expand Up @@ -536,15 +534,7 @@ static int xtpg_hls_s_ctrl(struct v4l2_ctrl *ctrl)
xvip_clr_and_set(&xtpg->xvip, XTPG_HLS_BG_PATTERN,
XTPG_PATTERN_MASK, ctrl->val);
return 0;
case V4L2_CID_XILINX_TPG_CROSS_HAIRS:
if (ctrl->val)
__v4l2_ctrl_s_ctrl(xtpg->moving_box, 0x0);
xvip_write(&xtpg->xvip, XTPG_HLS_FG_PATTERN,
ctrl->val ? XTPG_HLS_FG_PATTERN_CROSS_HAIR : 0);
return 0;
case V4L2_CID_XILINX_TPG_MOVING_BOX:
if (ctrl->val)
__v4l2_ctrl_s_ctrl(xtpg->cross_hair, 0x0);
case V4L2_CID_XILINX_TPG_HLS_FG_PATTERN:
xvip_write(&xtpg->xvip, XTPG_HLS_FG_PATTERN, ctrl->val);
return 0;
case V4L2_CID_XILINX_TPG_COLOR_MASK:
Expand Down Expand Up @@ -666,6 +656,22 @@ static const char *const xtpg_hls_pattern_strings[] = {
"Black/White Checker Board",
};

static const char *const xtpg_hls_fg_strings[] = {
"No Overlay",
"Moving Box",
"Cross Hairs",
};

static const struct v4l2_ctrl_config xtpg_hls_fg_ctrl = {
.ops = &xtpg_hls_ctrl_ops,
.id = V4L2_CID_XILINX_TPG_HLS_FG_PATTERN,
.name = "Test Pattern: Foreground Pattern",
.type = V4L2_CTRL_TYPE_MENU,
.min = 0,
.max = ARRAY_SIZE(xtpg_hls_fg_strings) - 1,
.qmenu = xtpg_hls_fg_strings,
};

static struct v4l2_ctrl_config xtpg_ctrls[] = {
{
.ops = &xtpg_ctrl_ops,
Expand Down Expand Up @@ -834,24 +840,6 @@ static struct v4l2_ctrl_config xtpg_ctrls[] = {

static struct v4l2_ctrl_config xtpg_hls_ctrls[] = {
{
.ops = &xtpg_hls_ctrl_ops,
.id = V4L2_CID_XILINX_TPG_CROSS_HAIRS,
.name = "Test Pattern: Cross Hairs",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.min = false,
.max = true,
.step = 1,
.def = 0,
}, {
.ops = &xtpg_hls_ctrl_ops,
.id = V4L2_CID_XILINX_TPG_MOVING_BOX,
.name = "Test Pattern: Moving Box",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.min = false,
.max = true,
.step = 1,
.def = 0,
}, {
.ops = &xtpg_hls_ctrl_ops,
.id = V4L2_CID_XILINX_TPG_COLOR_MASK,
.name = "Test Pattern: Color Mask (RGB)",
Expand Down Expand Up @@ -1141,7 +1129,10 @@ static int xtpg_probe(struct platform_device *pdev)
if (ret < 0)
goto error;

v4l2_ctrl_handler_init(&xtpg->ctrl_handler, 3 + nctrls);
if (xtpg->is_hls)
v4l2_ctrl_handler_init(&xtpg->ctrl_handler, 4 + nctrls);
else
v4l2_ctrl_handler_init(&xtpg->ctrl_handler, 3 + nctrls);

xtpg->vblank = v4l2_ctrl_new_std(&xtpg->ctrl_handler, ctrl_ops,
V4L2_CID_VBLANK, XTPG_MIN_VBLANK,
Expand All @@ -1150,22 +1141,25 @@ static int xtpg_probe(struct platform_device *pdev)
V4L2_CID_HBLANK, XTPG_MIN_HBLANK,
XTPG_MAX_HBLANK, 1, 100);

if (xtpg->is_hls)
if (xtpg->is_hls) {
xtpg->pattern =
v4l2_ctrl_new_std_menu_items(&xtpg->ctrl_handler,
ctrl_ops,
V4L2_CID_TEST_PATTERN,
npatterns - 1,
1, 9,
xtpg_hls_pattern_strings);
else
v4l2_ctrl_new_custom(&xtpg->ctrl_handler,
&xtpg_hls_fg_ctrl, NULL);
} else {
xtpg->pattern =
v4l2_ctrl_new_std_menu_items(&xtpg->ctrl_handler,
ctrl_ops,
V4L2_CID_TEST_PATTERN,
npatterns - 1,
1, 9,
xtpg_pattern_strings);
}

for (i = 0; i < nctrls; i++)
v4l2_ctrl_new_custom(&xtpg->ctrl_handler,
Expand All @@ -1177,11 +1171,6 @@ static int xtpg_probe(struct platform_device *pdev)
goto error;
}

xtpg->moving_box = v4l2_ctrl_find(&xtpg->ctrl_handler,
V4L2_CID_XILINX_TPG_MOVING_BOX);
xtpg->cross_hair = v4l2_ctrl_find(&xtpg->ctrl_handler,
V4L2_CID_XILINX_TPG_CROSS_HAIRS);

subdev->ctrl_handler = &xtpg->ctrl_handler;

xtpg_update_pattern_control(xtpg, true, true);
Expand Down
3 changes: 3 additions & 0 deletions include/uapi/linux/xilinx-v4l2-controls.h
Expand Up @@ -69,6 +69,9 @@
#define V4L2_CID_XILINX_TPG_STUCK_PIXEL_THRESH (V4L2_CID_XILINX_TPG + 16)
/* Noise level */
#define V4L2_CID_XILINX_TPG_NOISE_GAIN (V4L2_CID_XILINX_TPG + 17)
/* Foreground pattern (HLS)*/
#define V4L2_CID_XILINX_TPG_HLS_FG_PATTERN (V4L2_CID_XILINX_TPG + 18)


/*
* Xilinx CRESAMPLE Video IP
Expand Down

0 comments on commit bd2f3fa

Please sign in to comment.