420
static int vpx3220_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
423
case V4L2_CID_BRIGHTNESS:
424
v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
427
case V4L2_CID_CONTRAST:
428
v4l2_ctrl_query_fill(qc, 0, 63, 1, 32);
431
case V4L2_CID_SATURATION:
432
v4l2_ctrl_query_fill(qc, 0, 4095, 1, 2048);
436
v4l2_ctrl_query_fill(qc, -512, 511, 1, 0);
445
static int vpx3220_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
447
struct vpx3220 *decoder = to_vpx3220(sd);
450
case V4L2_CID_BRIGHTNESS:
451
ctrl->value = decoder->bright;
453
case V4L2_CID_CONTRAST:
454
ctrl->value = decoder->contrast;
456
case V4L2_CID_SATURATION:
457
ctrl->value = decoder->sat;
460
ctrl->value = decoder->hue;
468
static int vpx3220_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
470
struct vpx3220 *decoder = to_vpx3220(sd);
473
case V4L2_CID_BRIGHTNESS:
474
if (decoder->bright != ctrl->value) {
475
decoder->bright = ctrl->value;
476
vpx3220_write(sd, 0xe6, decoder->bright);
479
case V4L2_CID_CONTRAST:
480
if (decoder->contrast != ctrl->value) {
481
/* Bit 7 and 8 is for noise shaping */
482
decoder->contrast = ctrl->value;
483
vpx3220_write(sd, 0xe7, decoder->contrast + 192);
486
case V4L2_CID_SATURATION:
487
if (decoder->sat != ctrl->value) {
488
decoder->sat = ctrl->value;
489
vpx3220_fp_write(sd, 0xa0, decoder->sat);
493
if (decoder->hue != ctrl->value) {
494
decoder->hue = ctrl->value;
495
vpx3220_fp_write(sd, 0x1c, decoder->hue);
423
static int vpx3220_s_ctrl(struct v4l2_ctrl *ctrl)
425
struct v4l2_subdev *sd = to_sd(ctrl);
428
case V4L2_CID_BRIGHTNESS:
429
vpx3220_write(sd, 0xe6, ctrl->val);
431
case V4L2_CID_CONTRAST:
432
/* Bit 7 and 8 is for noise shaping */
433
vpx3220_write(sd, 0xe7, ctrl->val + 192);
435
case V4L2_CID_SATURATION:
436
vpx3220_fp_write(sd, 0xa0, ctrl->val);
439
vpx3220_fp_write(sd, 0x1c, ctrl->val);
504
445
static int vpx3220_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
512
453
/* ----------------------------------------------------------------------- */
455
static const struct v4l2_ctrl_ops vpx3220_ctrl_ops = {
456
.s_ctrl = vpx3220_s_ctrl,
514
459
static const struct v4l2_subdev_core_ops vpx3220_core_ops = {
515
460
.g_chip_ident = vpx3220_g_chip_ident,
516
461
.init = vpx3220_init,
517
.g_ctrl = vpx3220_g_ctrl,
518
.s_ctrl = vpx3220_s_ctrl,
519
.queryctrl = vpx3220_queryctrl,
462
.g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
463
.try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
464
.s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
465
.g_ctrl = v4l2_subdev_g_ctrl,
466
.s_ctrl = v4l2_subdev_s_ctrl,
467
.queryctrl = v4l2_subdev_queryctrl,
468
.querymenu = v4l2_subdev_querymenu,
520
469
.s_std = vpx3220_s_std,
558
507
decoder->norm = V4L2_STD_PAL;
559
508
decoder->input = 0;
560
509
decoder->enable = 1;
561
decoder->bright = 32768;
562
decoder->contrast = 32768;
563
decoder->hue = 32768;
564
decoder->sat = 32768;
510
v4l2_ctrl_handler_init(&decoder->hdl, 4);
511
v4l2_ctrl_new_std(&decoder->hdl, &vpx3220_ctrl_ops,
512
V4L2_CID_BRIGHTNESS, -128, 127, 1, 0);
513
v4l2_ctrl_new_std(&decoder->hdl, &vpx3220_ctrl_ops,
514
V4L2_CID_CONTRAST, 0, 63, 1, 32);
515
v4l2_ctrl_new_std(&decoder->hdl, &vpx3220_ctrl_ops,
516
V4L2_CID_SATURATION, 0, 4095, 1, 2048);
517
v4l2_ctrl_new_std(&decoder->hdl, &vpx3220_ctrl_ops,
518
V4L2_CID_HUE, -512, 511, 1, 0);
519
sd->ctrl_handler = &decoder->hdl;
520
if (decoder->hdl.error) {
521
int err = decoder->hdl.error;
523
v4l2_ctrl_handler_free(&decoder->hdl);
527
v4l2_ctrl_handler_setup(&decoder->hdl);
566
529
ver = i2c_smbus_read_byte_data(client, 0x00);
567
530
pn = (i2c_smbus_read_byte_data(client, 0x02) << 8) +