aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-02 02:33:52 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 14:03:12 -0400
commit7088f4df4c489811f6a5ad9a883b7dd259adfb6a (patch)
treebdada78cf74b8653720806e5a66b95c158f7b83a /drivers/media/video
parent3d51dca2a951330ec60fac705316cf3d82988e29 (diff)
[media] vivi: add the alpha component control
Useful to set the alpha component for the pixel formats with an alpha channel. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/vivi.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 5e457452a6e1..0960d7f0d394 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -200,6 +200,7 @@ struct vivi_dev {
200 struct v4l2_ctrl *gain; 200 struct v4l2_ctrl *gain;
201 }; 201 };
202 struct v4l2_ctrl *volume; 202 struct v4l2_ctrl *volume;
203 struct v4l2_ctrl *alpha;
203 struct v4l2_ctrl *button; 204 struct v4l2_ctrl *button;
204 struct v4l2_ctrl *boolean; 205 struct v4l2_ctrl *boolean;
205 struct v4l2_ctrl *int32; 206 struct v4l2_ctrl *int32;
@@ -237,6 +238,7 @@ struct vivi_dev {
237 u8 bars[9][3]; 238 u8 bars[9][3];
238 u8 line[MAX_WIDTH * 8]; 239 u8 line[MAX_WIDTH * 8];
239 unsigned int pixelsize; 240 unsigned int pixelsize;
241 u8 alpha_component;
240}; 242};
241 243
242/* ------------------------------------------------------------------ 244/* ------------------------------------------------------------------
@@ -359,6 +361,7 @@ static void precalculate_bars(struct vivi_dev *dev)
359static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd) 361static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd)
360{ 362{
361 u8 r_y, g_u, b_v; 363 u8 r_y, g_u, b_v;
364 u8 alpha = dev->alpha_component;
362 int color; 365 int color;
363 u8 *p; 366 u8 *p;
364 367
@@ -436,14 +439,14 @@ static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd)
436 *p = (g_u << 5) | b_v; 439 *p = (g_u << 5) | b_v;
437 break; 440 break;
438 case 1: 441 case 1:
439 *p = (r_y << 2) | (g_u >> 3); 442 *p = (alpha & 0x80) | (r_y << 2) | (g_u >> 3);
440 break; 443 break;
441 } 444 }
442 break; 445 break;
443 case V4L2_PIX_FMT_RGB555X: 446 case V4L2_PIX_FMT_RGB555X:
444 switch (color) { 447 switch (color) {
445 case 0: 448 case 0:
446 *p = (r_y << 2) | (g_u >> 3); 449 *p = (alpha & 0x80) | (r_y << 2) | (g_u >> 3);
447 break; 450 break;
448 case 1: 451 case 1:
449 *p = (g_u << 5) | b_v; 452 *p = (g_u << 5) | b_v;
@@ -479,7 +482,7 @@ static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd)
479 case V4L2_PIX_FMT_RGB32: 482 case V4L2_PIX_FMT_RGB32:
480 switch (color) { 483 switch (color) {
481 case 0: 484 case 0:
482 *p = 0; 485 *p = alpha;
483 break; 486 break;
484 case 1: 487 case 1:
485 *p = r_y; 488 *p = r_y;
@@ -504,7 +507,7 @@ static void gen_twopix(struct vivi_dev *dev, u8 *buf, int colorpos, bool odd)
504 *p = r_y; 507 *p = r_y;
505 break; 508 break;
506 case 3: 509 case 3:
507 *p = 0; 510 *p = alpha;
508 break; 511 break;
509 } 512 }
510 break; 513 break;
@@ -595,8 +598,9 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
595 dev->saturation->cur.val, 598 dev->saturation->cur.val,
596 dev->hue->cur.val); 599 dev->hue->cur.val);
597 gen_text(dev, vbuf, line++ * 16, 16, str); 600 gen_text(dev, vbuf, line++ * 16, 16, str);
598 snprintf(str, sizeof(str), " autogain %d, gain %3d, volume %3d ", 601 snprintf(str, sizeof(str), " autogain %d, gain %3d, volume %3d, alpha 0x%02x ",
599 dev->autogain->cur.val, gain, dev->volume->cur.val); 602 dev->autogain->cur.val, gain, dev->volume->cur.val,
603 dev->alpha->cur.val);
600 gen_text(dev, vbuf, line++ * 16, 16, str); 604 gen_text(dev, vbuf, line++ * 16, 16, str);
601 snprintf(str, sizeof(str), " int32 %d, int64 %lld, bitmask %08x ", 605 snprintf(str, sizeof(str), " int32 %d, int64 %lld, bitmask %08x ",
602 dev->int32->cur.val, 606 dev->int32->cur.val,
@@ -1125,8 +1129,15 @@ static int vivi_s_ctrl(struct v4l2_ctrl *ctrl)
1125{ 1129{
1126 struct vivi_dev *dev = container_of(ctrl->handler, struct vivi_dev, ctrl_handler); 1130 struct vivi_dev *dev = container_of(ctrl->handler, struct vivi_dev, ctrl_handler);
1127 1131
1128 if (ctrl == dev->button) 1132 switch (ctrl->id) {
1129 dev->button_pressed = 30; 1133 case V4L2_CID_ALPHA_COMPONENT:
1134 dev->alpha_component = ctrl->val;
1135 break;
1136 default:
1137 if (ctrl == dev->button)
1138 dev->button_pressed = 30;
1139 break;
1140 }
1130 return 0; 1141 return 0;
1131} 1142}
1132 1143
@@ -1387,6 +1398,8 @@ static int __init vivi_create_instance(int inst)
1387 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); 1398 V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
1388 dev->gain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, 1399 dev->gain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
1389 V4L2_CID_GAIN, 0, 255, 1, 100); 1400 V4L2_CID_GAIN, 0, 255, 1, 100);
1401 dev->alpha = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
1402 V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 0);
1390 dev->button = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_button, NULL); 1403 dev->button = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_button, NULL);
1391 dev->int32 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int32, NULL); 1404 dev->int32 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int32, NULL);
1392 dev->int64 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int64, NULL); 1405 dev->int64 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int64, NULL);