diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-02-15 06:04:29 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-25 14:09:59 -0400 |
commit | 5a4bdb4b34b90655891f627679bbba0ed9791c2e (patch) | |
tree | b9a7acaebd9a6009dee3de5e5d1fa352c5c8c22e /drivers/media/dvb-frontends | |
parent | e3f7586310e80be3f75fe03dabda0a64f54d6d73 (diff) |
[media] au8522_decoder: convert to the control framework
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r-- | drivers/media/dvb-frontends/au8522_decoder.c | 130 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/au8522_priv.h | 6 |
2 files changed, 46 insertions, 90 deletions
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 526902b45f9c..ad46a8f86af0 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c | |||
@@ -229,15 +229,11 @@ static void setup_decoder_defaults(struct au8522_state *state, u8 input_mode) | |||
229 | /* Provide reasonable defaults for picture tuning values */ | 229 | /* Provide reasonable defaults for picture tuning values */ |
230 | au8522_writereg(state, AU8522_TVDEC_SHARPNESSREG009H, 0x07); | 230 | au8522_writereg(state, AU8522_TVDEC_SHARPNESSREG009H, 0x07); |
231 | au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH, 0xed); | 231 | au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH, 0xed); |
232 | state->brightness = 0xed - 128; | ||
233 | au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH, 0x79); | 232 | au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH, 0x79); |
234 | state->contrast = 0x79; | ||
235 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH, 0x80); | 233 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH, 0x80); |
236 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH, 0x80); | 234 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH, 0x80); |
237 | state->saturation = 0x80; | ||
238 | au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH, 0x00); | 235 | au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH, 0x00); |
239 | au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH, 0x00); | 236 | au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH, 0x00); |
240 | state->hue = 0x00; | ||
241 | 237 | ||
242 | /* Other decoder registers */ | 238 | /* Other decoder registers */ |
243 | au8522_writereg(state, AU8522_TVDEC_INT_MASK_REG010H, 0x00); | 239 | au8522_writereg(state, AU8522_TVDEC_INT_MASK_REG010H, 0x00); |
@@ -489,75 +485,32 @@ static void set_audio_input(struct au8522_state *state, int aud_input) | |||
489 | 485 | ||
490 | /* ----------------------------------------------------------------------- */ | 486 | /* ----------------------------------------------------------------------- */ |
491 | 487 | ||
492 | static int au8522_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | 488 | static int au8522_s_ctrl(struct v4l2_ctrl *ctrl) |
493 | { | 489 | { |
494 | struct au8522_state *state = to_state(sd); | 490 | struct au8522_state *state = |
491 | container_of(ctrl->handler, struct au8522_state, hdl); | ||
495 | 492 | ||
496 | switch (ctrl->id) { | 493 | switch (ctrl->id) { |
497 | case V4L2_CID_BRIGHTNESS: | 494 | case V4L2_CID_BRIGHTNESS: |
498 | state->brightness = ctrl->value; | ||
499 | au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH, | 495 | au8522_writereg(state, AU8522_TVDEC_BRIGHTNESS_REG00AH, |
500 | ctrl->value - 128); | 496 | ctrl->val - 128); |
501 | break; | 497 | break; |
502 | case V4L2_CID_CONTRAST: | 498 | case V4L2_CID_CONTRAST: |
503 | state->contrast = ctrl->value; | ||
504 | au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH, | 499 | au8522_writereg(state, AU8522_TVDEC_CONTRAST_REG00BH, |
505 | ctrl->value); | 500 | ctrl->val); |
506 | break; | 501 | break; |
507 | case V4L2_CID_SATURATION: | 502 | case V4L2_CID_SATURATION: |
508 | state->saturation = ctrl->value; | ||
509 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH, | 503 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CB_REG00CH, |
510 | ctrl->value); | 504 | ctrl->val); |
511 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH, | 505 | au8522_writereg(state, AU8522_TVDEC_SATURATION_CR_REG00DH, |
512 | ctrl->value); | 506 | ctrl->val); |
513 | break; | 507 | break; |
514 | case V4L2_CID_HUE: | 508 | case V4L2_CID_HUE: |
515 | state->hue = ctrl->value; | ||
516 | au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH, | 509 | au8522_writereg(state, AU8522_TVDEC_HUE_H_REG00EH, |
517 | ctrl->value >> 8); | 510 | ctrl->val >> 8); |
518 | au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH, | 511 | au8522_writereg(state, AU8522_TVDEC_HUE_L_REG00FH, |
519 | ctrl->value & 0xFF); | 512 | ctrl->val & 0xFF); |
520 | break; | ||
521 | case V4L2_CID_AUDIO_VOLUME: | ||
522 | case V4L2_CID_AUDIO_BASS: | ||
523 | case V4L2_CID_AUDIO_TREBLE: | ||
524 | case V4L2_CID_AUDIO_BALANCE: | ||
525 | case V4L2_CID_AUDIO_MUTE: | ||
526 | /* Not yet implemented */ | ||
527 | default: | ||
528 | return -EINVAL; | ||
529 | } | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int au8522_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | ||
535 | { | ||
536 | struct au8522_state *state = to_state(sd); | ||
537 | |||
538 | /* Note that we are using values cached in the state structure instead | ||
539 | of reading the registers due to issues with i2c reads not working | ||
540 | properly/consistently yet on the HVR-950q */ | ||
541 | |||
542 | switch (ctrl->id) { | ||
543 | case V4L2_CID_BRIGHTNESS: | ||
544 | ctrl->value = state->brightness; | ||
545 | break; | ||
546 | case V4L2_CID_CONTRAST: | ||
547 | ctrl->value = state->contrast; | ||
548 | break; | ||
549 | case V4L2_CID_SATURATION: | ||
550 | ctrl->value = state->saturation; | ||
551 | break; | ||
552 | case V4L2_CID_HUE: | ||
553 | ctrl->value = state->hue; | ||
554 | break; | 513 | break; |
555 | case V4L2_CID_AUDIO_VOLUME: | ||
556 | case V4L2_CID_AUDIO_BASS: | ||
557 | case V4L2_CID_AUDIO_TREBLE: | ||
558 | case V4L2_CID_AUDIO_BALANCE: | ||
559 | case V4L2_CID_AUDIO_MUTE: | ||
560 | /* Not yet supported */ | ||
561 | default: | 514 | default: |
562 | return -EINVAL; | 515 | return -EINVAL; |
563 | } | 516 | } |
@@ -616,26 +569,6 @@ static int au8522_s_stream(struct v4l2_subdev *sd, int enable) | |||
616 | return 0; | 569 | return 0; |
617 | } | 570 | } |
618 | 571 | ||
619 | static int au8522_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | ||
620 | { | ||
621 | switch (qc->id) { | ||
622 | case V4L2_CID_CONTRAST: | ||
623 | return v4l2_ctrl_query_fill(qc, 0, 255, 1, | ||
624 | AU8522_TVDEC_CONTRAST_REG00BH_CVBS); | ||
625 | case V4L2_CID_BRIGHTNESS: | ||
626 | return v4l2_ctrl_query_fill(qc, 0, 255, 1, 109); | ||
627 | case V4L2_CID_SATURATION: | ||
628 | return v4l2_ctrl_query_fill(qc, 0, 255, 1, 128); | ||
629 | case V4L2_CID_HUE: | ||
630 | return v4l2_ctrl_query_fill(qc, -32768, 32768, 1, 0); | ||
631 | default: | ||
632 | break; | ||
633 | } | ||
634 | |||
635 | qc->type = 0; | ||
636 | return -EINVAL; | ||
637 | } | ||
638 | |||
639 | static int au8522_reset(struct v4l2_subdev *sd, u32 val) | 572 | static int au8522_reset(struct v4l2_subdev *sd, u32 val) |
640 | { | 573 | { |
641 | struct au8522_state *state = to_state(sd); | 574 | struct au8522_state *state = to_state(sd); |
@@ -712,20 +645,18 @@ static int au8522_g_chip_ident(struct v4l2_subdev *sd, | |||
712 | return v4l2_chip_ident_i2c_client(client, chip, state->id, state->rev); | 645 | return v4l2_chip_ident_i2c_client(client, chip, state->id, state->rev); |
713 | } | 646 | } |
714 | 647 | ||
715 | static int au8522_log_status(struct v4l2_subdev *sd) | ||
716 | { | ||
717 | /* FIXME: Add some status info here */ | ||
718 | return 0; | ||
719 | } | ||
720 | |||
721 | /* ----------------------------------------------------------------------- */ | 648 | /* ----------------------------------------------------------------------- */ |
722 | 649 | ||
723 | static const struct v4l2_subdev_core_ops au8522_core_ops = { | 650 | static const struct v4l2_subdev_core_ops au8522_core_ops = { |
724 | .log_status = au8522_log_status, | 651 | .log_status = v4l2_ctrl_subdev_log_status, |
652 | .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, | ||
653 | .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, | ||
654 | .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, | ||
655 | .g_ctrl = v4l2_subdev_g_ctrl, | ||
656 | .s_ctrl = v4l2_subdev_s_ctrl, | ||
657 | .queryctrl = v4l2_subdev_queryctrl, | ||
658 | .querymenu = v4l2_subdev_querymenu, | ||
725 | .g_chip_ident = au8522_g_chip_ident, | 659 | .g_chip_ident = au8522_g_chip_ident, |
726 | .g_ctrl = au8522_g_ctrl, | ||
727 | .s_ctrl = au8522_s_ctrl, | ||
728 | .queryctrl = au8522_queryctrl, | ||
729 | .reset = au8522_reset, | 660 | .reset = au8522_reset, |
730 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 661 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
731 | .g_register = au8522_g_register, | 662 | .g_register = au8522_g_register, |
@@ -753,12 +684,17 @@ static const struct v4l2_subdev_ops au8522_ops = { | |||
753 | .video = &au8522_video_ops, | 684 | .video = &au8522_video_ops, |
754 | }; | 685 | }; |
755 | 686 | ||
687 | static const struct v4l2_ctrl_ops au8522_ctrl_ops = { | ||
688 | .s_ctrl = au8522_s_ctrl, | ||
689 | }; | ||
690 | |||
756 | /* ----------------------------------------------------------------------- */ | 691 | /* ----------------------------------------------------------------------- */ |
757 | 692 | ||
758 | static int au8522_probe(struct i2c_client *client, | 693 | static int au8522_probe(struct i2c_client *client, |
759 | const struct i2c_device_id *did) | 694 | const struct i2c_device_id *did) |
760 | { | 695 | { |
761 | struct au8522_state *state; | 696 | struct au8522_state *state; |
697 | struct v4l2_ctrl_handler *hdl; | ||
762 | struct v4l2_subdev *sd; | 698 | struct v4l2_subdev *sd; |
763 | int instance; | 699 | int instance; |
764 | struct au8522_config *demod_config; | 700 | struct au8522_config *demod_config; |
@@ -799,6 +735,27 @@ static int au8522_probe(struct i2c_client *client, | |||
799 | sd = &state->sd; | 735 | sd = &state->sd; |
800 | v4l2_i2c_subdev_init(sd, client, &au8522_ops); | 736 | v4l2_i2c_subdev_init(sd, client, &au8522_ops); |
801 | 737 | ||
738 | hdl = &state->hdl; | ||
739 | v4l2_ctrl_handler_init(hdl, 4); | ||
740 | v4l2_ctrl_new_std(hdl, &au8522_ctrl_ops, | ||
741 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 109); | ||
742 | v4l2_ctrl_new_std(hdl, &au8522_ctrl_ops, | ||
743 | V4L2_CID_CONTRAST, 0, 255, 1, | ||
744 | AU8522_TVDEC_CONTRAST_REG00BH_CVBS); | ||
745 | v4l2_ctrl_new_std(hdl, &au8522_ctrl_ops, | ||
746 | V4L2_CID_SATURATION, 0, 255, 1, 128); | ||
747 | v4l2_ctrl_new_std(hdl, &au8522_ctrl_ops, | ||
748 | V4L2_CID_HUE, -32768, 32767, 1, 0); | ||
749 | sd->ctrl_handler = hdl; | ||
750 | if (hdl->error) { | ||
751 | int err = hdl->error; | ||
752 | |||
753 | v4l2_ctrl_handler_free(hdl); | ||
754 | kfree(demod_config); | ||
755 | kfree(state); | ||
756 | return err; | ||
757 | } | ||
758 | |||
802 | state->c = client; | 759 | state->c = client; |
803 | state->vid_input = AU8522_COMPOSITE_CH1; | 760 | state->vid_input = AU8522_COMPOSITE_CH1; |
804 | state->aud_input = AU8522_AUDIO_NONE; | 761 | state->aud_input = AU8522_AUDIO_NONE; |
@@ -815,6 +772,7 @@ static int au8522_remove(struct i2c_client *client) | |||
815 | { | 772 | { |
816 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 773 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
817 | v4l2_device_unregister_subdev(sd); | 774 | v4l2_device_unregister_subdev(sd); |
775 | v4l2_ctrl_handler_free(sd->ctrl_handler); | ||
818 | au8522_release_state(to_state(sd)); | 776 | au8522_release_state(to_state(sd)); |
819 | return 0; | 777 | return 0; |
820 | } | 778 | } |
diff --git a/drivers/media/dvb-frontends/au8522_priv.h b/drivers/media/dvb-frontends/au8522_priv.h index 0529699a27bd..aa0f16d6b610 100644 --- a/drivers/media/dvb-frontends/au8522_priv.h +++ b/drivers/media/dvb-frontends/au8522_priv.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/videodev2.h> | 30 | #include <linux/videodev2.h> |
31 | #include <media/v4l2-device.h> | 31 | #include <media/v4l2-device.h> |
32 | #include <media/v4l2-ctrls.h> | ||
32 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
33 | #include "dvb_frontend.h" | 34 | #include "dvb_frontend.h" |
34 | #include "au8522.h" | 35 | #include "au8522.h" |
@@ -65,10 +66,7 @@ struct au8522_state { | |||
65 | int aud_input; | 66 | int aud_input; |
66 | u32 id; | 67 | u32 id; |
67 | u32 rev; | 68 | u32 rev; |
68 | u8 brightness; | 69 | struct v4l2_ctrl_handler hdl; |
69 | u8 contrast; | ||
70 | u8 saturation; | ||
71 | s16 hue; | ||
72 | }; | 70 | }; |
73 | 71 | ||
74 | /* These are routines shared by both the VSB/QAM demodulator and the analog | 72 | /* These are routines shared by both the VSB/QAM demodulator and the analog |