aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPete Eberlein <pete@sensoray.com>2009-09-18 21:55:13 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:54:08 -0400
commit047efc7db9fea32703e8ba04629562e52cccdf88 (patch)
treed7f3759dd6a68eeaf591255f2078797e3fac4652 /drivers
parentd66ddf21723146a69915a0cf46db77f409e74602 (diff)
V4L/DVB (13026): s2250-board: Implement brightness and contrast controls
The brightness and contrast controls were added to the Sensoray 2250 device. A read register function was added to set the correct bit fields. Signed-off-by: Pete Eberlein <pete@sensoray.com> Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/go7007/s2250-board.c77
1 files changed, 72 insertions, 5 deletions
diff --git a/drivers/staging/go7007/s2250-board.c b/drivers/staging/go7007/s2250-board.c
index 3310961de1ec..8c85a9c3665a 100644
--- a/drivers/staging/go7007/s2250-board.c
+++ b/drivers/staging/go7007/s2250-board.c
@@ -112,7 +112,7 @@ static u16 vid_regs_fp_pal[] =
112}; 112};
113 113
114struct s2250 { 114struct s2250 {
115 int std; 115 v4l2_std_id std;
116 int input; 116 int input;
117 int brightness; 117 int brightness;
118 int contrast; 118 int contrast;
@@ -240,6 +240,45 @@ static int write_reg_fp(struct i2c_client *client, u16 addr, u16 val)
240 return 0; 240 return 0;
241} 241}
242 242
243static int read_reg_fp(struct i2c_client *client, u16 addr, u16 *val)
244{
245 struct go7007 *go = i2c_get_adapdata(client->adapter);
246 struct go7007_usb *usb;
247 u8 *buf;
248
249 if (go == NULL)
250 return -ENODEV;
251
252 if (go->status == STATUS_SHUTDOWN)
253 return -EBUSY;
254
255 buf = kzalloc(16, GFP_KERNEL);
256
257 if (buf == NULL)
258 return -ENOMEM;
259
260
261
262 memset(buf, 0xcd, 6);
263 usb = go->hpi_context;
264 if (down_interruptible(&usb->i2c_lock) != 0) {
265 printk(KERN_INFO "i2c lock failed\n");
266 kfree(buf);
267 return -EINTR;
268 }
269 if (go7007_usb_vendor_request(go, 0x58, addr, 0, buf, 16, 1) < 0) {
270 kfree(buf);
271 return -EFAULT;
272 }
273 up(&usb->i2c_lock);
274
275 *val = (buf[0] << 8) | buf[1];
276 kfree(buf);
277
278 return 0;
279}
280
281
243static int write_regs(struct i2c_client *client, u8 *regs) 282static int write_regs(struct i2c_client *client, u8 *regs)
244{ 283{
245 int i; 284 int i;
@@ -354,14 +393,42 @@ static int s2250_command(struct i2c_client *client,
354 { 393 {
355 struct v4l2_control *ctrl = arg; 394 struct v4l2_control *ctrl = arg;
356 int value1; 395 int value1;
396 u16 oldvalue;
357 397
358 switch (ctrl->id) { 398 switch (ctrl->id) {
359 case V4L2_CID_BRIGHTNESS: 399 case V4L2_CID_BRIGHTNESS:
360 printk(KERN_INFO "s2250: future setting\n"); 400 if (ctrl->value > 100)
361 return -EINVAL; 401 dec->brightness = 100;
402 else if (ctrl->value < 0)
403 dec->brightness = 0;
404 else
405 dec->brightness = ctrl->value;
406 value1 = (dec->brightness - 50) * 255 / 100;
407 read_reg_fp(client, VPX322_ADDR_BRIGHTNESS0, &oldvalue);
408 write_reg_fp(client, VPX322_ADDR_BRIGHTNESS0,
409 value1 | (oldvalue & ~0xff));
410 read_reg_fp(client, VPX322_ADDR_BRIGHTNESS1, &oldvalue);
411 write_reg_fp(client, VPX322_ADDR_BRIGHTNESS1,
412 value1 | (oldvalue & ~0xff));
413 write_reg_fp(client, 0x140, 0x60);
414 break;
362 case V4L2_CID_CONTRAST: 415 case V4L2_CID_CONTRAST:
363 printk(KERN_INFO "s2250: future setting\n"); 416 if (ctrl->value > 100)
364 return -EINVAL; 417 dec->contrast = 100;
418 else if (ctrl->value < 0)
419 dec->contrast = 0;
420 else
421 dec->contrast = ctrl->value;
422 value1 = dec->contrast * 0x40 / 100;
423 if (value1 > 0x3f)
424 value1 = 0x3f; /* max */
425 read_reg_fp(client, VPX322_ADDR_CONTRAST0, &oldvalue);
426 write_reg_fp(client, VPX322_ADDR_CONTRAST0,
427 value1 | (oldvalue & ~0x3f));
428 read_reg_fp(client, VPX322_ADDR_CONTRAST1, &oldvalue);
429 write_reg_fp(client, VPX322_ADDR_CONTRAST1,
430 value1 | (oldvalue & ~0x3f));
431 write_reg_fp(client, 0x140, 0x60);
365 break; 432 break;
366 case V4L2_CID_SATURATION: 433 case V4L2_CID_SATURATION:
367 if (ctrl->value > 127) 434 if (ctrl->value > 127)