aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-11-17 08:21:19 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-12-02 08:18:08 -0500
commitcd8adbe7013f4a0c82c29f549161588eeec13696 (patch)
tree78198c2bf6a40669203db5a65f92b2e509b81649 /drivers/media
parent481b97a1f24e267e630d722d8160105a88399529 (diff)
[media] vivid: add new colorspaces
Add AdobeRGB and BT.2020 support. The colorspace control now orders the colorspaces according to how often they are used. So rarely used colorspaces are moved to the end. This makes it more logical when testing colorspace support. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/vivid/vivid-core.h11
-rw-r--r--drivers/media/platform/vivid/vivid-ctrls.c27
-rw-r--r--drivers/media/platform/vivid/vivid-vid-cap.c16
3 files changed, 36 insertions, 18 deletions
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index 6f4445ad7d4d..9e41cbe23006 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -116,6 +116,17 @@ enum vivid_signal_mode {
116 CUSTOM_DV_TIMINGS, 116 CUSTOM_DV_TIMINGS,
117}; 117};
118 118
119enum vivid_colorspace {
120 VIVID_CS_170M,
121 VIVID_CS_709,
122 VIVID_CS_SRGB,
123 VIVID_CS_ADOBERGB,
124 VIVID_CS_2020,
125 VIVID_CS_240M,
126 VIVID_CS_SYS_M,
127 VIVID_CS_SYS_BG,
128};
129
119#define VIVID_INVALID_SIGNAL(mode) \ 130#define VIVID_INVALID_SIGNAL(mode) \
120 ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE) 131 ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE)
121 132
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index ad8df5ce823c..dcb912d6e4ba 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -333,6 +333,16 @@ static const struct v4l2_ctrl_ops vivid_user_vid_ctrl_ops = {
333 333
334static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl) 334static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
335{ 335{
336 static const u32 colorspaces[] = {
337 V4L2_COLORSPACE_SMPTE170M,
338 V4L2_COLORSPACE_REC709,
339 V4L2_COLORSPACE_SRGB,
340 V4L2_COLORSPACE_ADOBERGB,
341 V4L2_COLORSPACE_BT2020,
342 V4L2_COLORSPACE_SMPTE240M,
343 V4L2_COLORSPACE_470_SYSTEM_M,
344 V4L2_COLORSPACE_470_SYSTEM_BG,
345 };
336 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_cap); 346 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_cap);
337 unsigned i; 347 unsigned i;
338 348
@@ -342,7 +352,7 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
342 tpg_s_pattern(&dev->tpg, ctrl->val); 352 tpg_s_pattern(&dev->tpg, ctrl->val);
343 break; 353 break;
344 case VIVID_CID_COLORSPACE: 354 case VIVID_CID_COLORSPACE:
345 tpg_s_colorspace(&dev->tpg, ctrl->val); 355 tpg_s_colorspace(&dev->tpg, colorspaces[ctrl->val]);
346 vivid_send_source_change(dev, TV); 356 vivid_send_source_change(dev, TV);
347 vivid_send_source_change(dev, SVID); 357 vivid_send_source_change(dev, SVID);
348 vivid_send_source_change(dev, HDMI); 358 vivid_send_source_change(dev, HDMI);
@@ -662,15 +672,14 @@ static const struct v4l2_ctrl_config vivid_ctrl_max_edid_blocks = {
662}; 672};
663 673
664static const char * const vivid_ctrl_colorspace_strings[] = { 674static const char * const vivid_ctrl_colorspace_strings[] = {
665 "",
666 "SMPTE 170M", 675 "SMPTE 170M",
667 "SMPTE 240M",
668 "REC 709", 676 "REC 709",
669 "", /* Skip Bt878 entry */ 677 "sRGB",
678 "AdobeRGB",
679 "BT.2020",
680 "SMPTE 240M",
670 "470 System M", 681 "470 System M",
671 "470 System BG", 682 "470 System BG",
672 "", /* Skip JPEG entry */
673 "sRGB",
674 NULL, 683 NULL,
675}; 684};
676 685
@@ -679,10 +688,8 @@ static const struct v4l2_ctrl_config vivid_ctrl_colorspace = {
679 .id = VIVID_CID_COLORSPACE, 688 .id = VIVID_CID_COLORSPACE,
680 .name = "Colorspace", 689 .name = "Colorspace",
681 .type = V4L2_CTRL_TYPE_MENU, 690 .type = V4L2_CTRL_TYPE_MENU,
682 .min = 1, 691 .max = 7,
683 .max = 8, 692 .def = 2,
684 .menu_skip_mask = (1 << 4) | (1 << 7),
685 .def = 8,
686 .qmenu = vivid_ctrl_colorspace_strings, 693 .qmenu = vivid_ctrl_colorspace_strings,
687}; 694};
688 695
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index 1309d311c627..923a4f854eba 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -443,12 +443,12 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
443 break; 443 break;
444 if (bt->standards & V4L2_DV_BT_STD_CEA861) { 444 if (bt->standards & V4L2_DV_BT_STD_CEA861) {
445 if (bt->width == 720 && bt->height <= 576) 445 if (bt->width == 720 && bt->height <= 576)
446 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); 446 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M);
447 else 447 else
448 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_REC709); 448 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709);
449 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1); 449 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 1);
450 } else { 450 } else {
451 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); 451 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB);
452 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0); 452 v4l2_ctrl_s_ctrl(dev->real_rgb_range_cap, 0);
453 } 453 }
454 tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap)); 454 tpg_s_rgb_range(&dev->tpg, v4l2_ctrl_g_ctrl(dev->rgb_range_cap));
@@ -1307,20 +1307,20 @@ int vidioc_s_input(struct file *file, void *priv, unsigned i)
1307 if (dev->colorspace) { 1307 if (dev->colorspace) {
1308 switch (dev->input_type[i]) { 1308 switch (dev->input_type[i]) {
1309 case WEBCAM: 1309 case WEBCAM:
1310 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); 1310 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB);
1311 break; 1311 break;
1312 case TV: 1312 case TV:
1313 case SVID: 1313 case SVID:
1314 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); 1314 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M);
1315 break; 1315 break;
1316 case HDMI: 1316 case HDMI:
1317 if (bt->standards & V4L2_DV_BT_STD_CEA861) { 1317 if (bt->standards & V4L2_DV_BT_STD_CEA861) {
1318 if (dev->src_rect.width == 720 && dev->src_rect.height <= 576) 1318 if (dev->src_rect.width == 720 && dev->src_rect.height <= 576)
1319 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SMPTE170M); 1319 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_170M);
1320 else 1320 else
1321 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_REC709); 1321 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_709);
1322 } else { 1322 } else {
1323 v4l2_ctrl_s_ctrl(dev->colorspace, V4L2_COLORSPACE_SRGB); 1323 v4l2_ctrl_s_ctrl(dev->colorspace, VIVID_CS_SRGB);
1324 } 1324 }
1325 break; 1325 break;
1326 } 1326 }