24
25
module_param(debug, int, 0);
25
26
MODULE_PARM_DESC(debug, "Debug level (0-2)");
27
/* supported controls */
28
static struct v4l2_queryctrl tvp5150_qctrl[] = {
30
.id = V4L2_CID_BRIGHTNESS,
31
.type = V4L2_CTRL_TYPE_INTEGER,
39
.id = V4L2_CID_CONTRAST,
40
.type = V4L2_CTRL_TYPE_INTEGER,
48
.id = V4L2_CID_SATURATION,
49
.type = V4L2_CTRL_TYPE_INTEGER,
58
.type = V4L2_CTRL_TYPE_INTEGER,
69
29
struct v4l2_subdev sd;
30
struct v4l2_ctrl_handler hdl;
71
32
v4l2_std_id norm; /* Current set standard */
81
38
static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
775
737
static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
777
739
struct tvp5150 *decoder = to_tvp5150(sd);
778
u8 msb_id, lsb_id, msb_rom, lsb_rom;
780
msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID);
781
lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID);
782
msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER);
783
lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
785
if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */
786
v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id);
788
/* ITU-T BT.656.4 timing */
789
tvp5150_write(sd, TVP5150_REV_SELECT, 0);
791
if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */
792
v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id);
794
v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
796
v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom);
800
741
/* Initializes TVP5150 to its default values */
801
742
tvp5150_write_inittab(sd, tvp5150_init_default);
810
751
tvp5150_write_inittab(sd, tvp5150_init_enable);
812
753
/* Initialize image preferences */
813
tvp5150_write(sd, TVP5150_BRIGHT_CTL, decoder->bright);
814
tvp5150_write(sd, TVP5150_CONTRAST_CTL, decoder->contrast);
815
tvp5150_write(sd, TVP5150_SATURATION_CTL, decoder->contrast);
816
tvp5150_write(sd, TVP5150_HUE_CTL, decoder->hue);
754
v4l2_ctrl_handler_setup(&decoder->hdl);
818
756
tvp5150_set_std(sd, decoder->norm);
822
static int tvp5150_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
824
v4l2_dbg(1, debug, sd, "g_ctrl called\n");
827
case V4L2_CID_BRIGHTNESS:
828
ctrl->value = tvp5150_read(sd, TVP5150_BRIGHT_CTL);
830
case V4L2_CID_CONTRAST:
831
ctrl->value = tvp5150_read(sd, TVP5150_CONTRAST_CTL);
833
case V4L2_CID_SATURATION:
834
ctrl->value = tvp5150_read(sd, TVP5150_SATURATION_CTL);
837
ctrl->value = tvp5150_read(sd, TVP5150_HUE_CTL);
843
static int tvp5150_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
846
n = ARRAY_SIZE(tvp5150_qctrl);
848
for (i = 0; i < n; i++) {
849
if (ctrl->id != tvp5150_qctrl[i].id)
851
if (ctrl->value < tvp5150_qctrl[i].minimum ||
852
ctrl->value > tvp5150_qctrl[i].maximum)
854
v4l2_dbg(1, debug, sd, "s_ctrl: id=%d, value=%d\n",
855
ctrl->id, ctrl->value);
860
case V4L2_CID_BRIGHTNESS:
861
tvp5150_write(sd, TVP5150_BRIGHT_CTL, ctrl->value);
863
case V4L2_CID_CONTRAST:
864
tvp5150_write(sd, TVP5150_CONTRAST_CTL, ctrl->value);
866
case V4L2_CID_SATURATION:
867
tvp5150_write(sd, TVP5150_SATURATION_CTL, ctrl->value);
870
tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->value);
760
static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
762
struct v4l2_subdev *sd = to_sd(ctrl);
765
case V4L2_CID_BRIGHTNESS:
766
tvp5150_write(sd, TVP5150_BRIGHT_CTL, ctrl->val);
768
case V4L2_CID_CONTRAST:
769
tvp5150_write(sd, TVP5150_CONTRAST_CTL, ctrl->val);
771
case V4L2_CID_SATURATION:
772
tvp5150_write(sd, TVP5150_SATURATION_CTL, ctrl->val);
775
tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
998
static int tvp5150_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1002
v4l2_dbg(1, debug, sd, "queryctrl called\n");
1004
for (i = 0; i < ARRAY_SIZE(tvp5150_qctrl); i++)
1005
if (qc->id && qc->id == tvp5150_qctrl[i].id) {
1006
memcpy(qc, &(tvp5150_qctrl[i]),
1014
903
/* ----------------------------------------------------------------------- */
905
static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = {
906
.s_ctrl = tvp5150_s_ctrl,
1016
909
static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
1017
910
.log_status = tvp5150_log_status,
1018
.g_ctrl = tvp5150_g_ctrl,
1019
.s_ctrl = tvp5150_s_ctrl,
1020
.queryctrl = tvp5150_queryctrl,
911
.g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
912
.try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
913
.s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
914
.g_ctrl = v4l2_subdev_g_ctrl,
915
.s_ctrl = v4l2_subdev_s_ctrl,
916
.queryctrl = v4l2_subdev_queryctrl,
917
.querymenu = v4l2_subdev_querymenu,
1021
918
.s_std = tvp5150_s_std,
1022
919
.reset = tvp5150_reset,
1023
920
.g_chip_ident = tvp5150_g_chip_ident,
1074
972
v4l_info(c, "chip found @ 0x%02x (%s)\n",
1075
973
c->addr << 1, c->adapter->name);
975
msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID);
976
lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID);
977
msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER);
978
lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
980
if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */
981
v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id);
983
/* ITU-T BT.656.4 timing */
984
tvp5150_write(sd, TVP5150_REV_SELECT, 0);
986
if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */
987
v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id);
989
v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
991
v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom);
1077
995
core->norm = V4L2_STD_ALL; /* Default is autodetect */
1078
996
core->input = TVP5150_COMPOSITE1;
1079
997
core->enable = 1;
1081
core->contrast = 128;
999
v4l2_ctrl_handler_init(&core->hdl, 4);
1000
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1001
V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
1002
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1003
V4L2_CID_CONTRAST, 0, 255, 1, 128);
1004
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1005
V4L2_CID_SATURATION, 0, 255, 1, 128);
1006
v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
1007
V4L2_CID_HUE, -128, 127, 1, 0);
1008
sd->ctrl_handler = &core->hdl;
1009
if (core->hdl.error) {
1010
int err = core->hdl.error;
1012
v4l2_ctrl_handler_free(&core->hdl);
1016
v4l2_ctrl_handler_setup(&core->hdl);
1086
1019
tvp5150_log_status(sd);