Lines Matching refs:sd
44 struct v4l2_subdev sd; member
63 static inline struct saa717x_state *to_state(struct v4l2_subdev *sd) in to_state() argument
65 return container_of(sd, struct saa717x_state, sd); in to_state()
70 return &container_of(ctrl->handler, struct saa717x_state, hdl)->sd; in to_sd()
86 static int saa717x_write(struct v4l2_subdev *sd, u32 reg, u32 value) in saa717x_write() argument
88 struct i2c_client *client = v4l2_get_subdevdata(sd); in saa717x_write()
108 v4l2_dbg(2, debug, sd, "wrote: reg 0x%03x=%08x\n", reg, value); in saa717x_write()
112 static void saa717x_write_regs(struct v4l2_subdev *sd, u32 *data) in saa717x_write_regs() argument
115 saa717x_write(sd, data[0], data[1]); in saa717x_write_regs()
120 static u32 saa717x_read(struct v4l2_subdev *sd, u32 reg) in saa717x_read() argument
122 struct i2c_client *client = v4l2_get_subdevdata(sd); in saa717x_read()
146 v4l2_dbg(2, debug, sd, "read: reg 0x%03x=0x%08x\n", reg, value); in saa717x_read()
680 static void get_inf_dev_status(struct v4l2_subdev *sd, in get_inf_dev_status() argument
719 reg_data3 = saa717x_read(sd, 0x0528); in get_inf_dev_status()
721 v4l2_dbg(1, debug, sd, "tvaudio thread status: 0x%x [%s%s%s]\n", in get_inf_dev_status()
725 v4l2_dbg(1, debug, sd, "detailed status: " in get_inf_dev_status()
746 v4l2_dbg(1, debug, sd, "ST!!!\n"); in get_inf_dev_status()
751 v4l2_dbg(1, debug, sd, "DUAL!!!\n"); in get_inf_dev_status()
757 static void set_audio_mode(struct v4l2_subdev *sd, int audio_mode) in set_audio_mode() argument
759 v4l2_dbg(1, debug, sd, "writing registers to set audio mode by set %d\n", in set_audio_mode()
762 saa717x_write(sd, 0x46c, reg_set_audio_template[audio_mode][0]); in set_audio_mode()
763 saa717x_write(sd, 0x470, reg_set_audio_template[audio_mode][1]); in set_audio_mode()
767 static int set_audio_regs(struct v4l2_subdev *sd, in set_audio_regs() argument
775 saa717x_write(sd, 0x0594, decoder->audio_input); in set_audio_regs()
776 v4l2_dbg(1, debug, sd, "set audio input %d\n", in set_audio_regs()
796 saa717x_write(sd, 0x480, val); in set_audio_regs()
801 saa717x_write(sd, 0x488, val); in set_audio_regs()
806 static void set_h_prescale(struct v4l2_subdev *sd, in set_h_prescale() argument
839 saa717x_write(sd, 0x60 + task_shift, vals[i].xpsc); in set_h_prescale()
841 saa717x_write(sd, 0x61 + task_shift, vals[i].xacl); in set_h_prescale()
843 saa717x_write(sd, 0x62 + task_shift, in set_h_prescale()
846 saa717x_write(sd, 0x63 + task_shift, in set_h_prescale()
851 static void set_v_scale(struct v4l2_subdev *sd, int task, int yscale) in set_v_scale() argument
857 saa717x_write(sd, 0x70 + task_shift, yscale & 0xff); in set_v_scale()
859 saa717x_write(sd, 0x71 + task_shift, yscale >> 8); in set_v_scale()
864 struct v4l2_subdev *sd = to_sd(ctrl); in saa717x_s_ctrl() local
865 struct saa717x_state *state = to_state(sd); in saa717x_s_ctrl()
869 saa717x_write(sd, 0x10a, ctrl->val); in saa717x_s_ctrl()
873 saa717x_write(sd, 0x10b, ctrl->val); in saa717x_s_ctrl()
877 saa717x_write(sd, 0x10c, ctrl->val); in saa717x_s_ctrl()
881 saa717x_write(sd, 0x10d, ctrl->val); in saa717x_s_ctrl()
907 set_audio_regs(sd, state); in saa717x_s_ctrl()
911 static int saa717x_s_video_routing(struct v4l2_subdev *sd, in saa717x_s_video_routing() argument
914 struct saa717x_state *decoder = to_state(sd); in saa717x_s_video_routing()
919 v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", input); in saa717x_s_video_routing()
929 v4l2_dbg(1, debug, sd, "now setting %s input %d\n", in saa717x_s_video_routing()
934 saa717x_write(sd, 0x102, in saa717x_s_video_routing()
935 (saa717x_read(sd, 0x102) & 0xf0) | in saa717x_s_video_routing()
939 saa717x_write(sd, 0x109, in saa717x_s_video_routing()
940 (saa717x_read(sd, 0x109) & 0x7f) | in saa717x_s_video_routing()
946 set_audio_mode(sd, decoder->tuner_audio_mode); in saa717x_s_video_routing()
950 set_audio_mode(sd, TUNER_AUDIO_STEREO); in saa717x_s_video_routing()
954 saa717x_write_regs(sd, reg_init_tuner_input); in saa717x_s_video_routing()
956 saa717x_write_regs(sd, reg_init_svideo_input); in saa717x_s_video_routing()
958 saa717x_write_regs(sd, reg_init_composite_input); in saa717x_s_video_routing()
965 static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in saa717x_g_register() argument
967 reg->val = saa717x_read(sd, reg->reg); in saa717x_g_register()
972 static int saa717x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in saa717x_s_register() argument
977 saa717x_write(sd, addr, val); in saa717x_s_register()
982 static int saa717x_set_fmt(struct v4l2_subdev *sd, in saa717x_set_fmt() argument
989 v4l2_dbg(1, debug, sd, "decoder set size\n"); in saa717x_set_fmt()
1016 set_h_prescale(sd, 0, prescale); in saa717x_set_fmt()
1017 set_h_prescale(sd, 1, prescale); in saa717x_set_fmt()
1021 saa717x_write(sd, 0x6C, (u8)(h_scale & 0xFF)); in saa717x_set_fmt()
1022 saa717x_write(sd, 0x6D, (u8)((h_scale >> 8) & 0xFF)); in saa717x_set_fmt()
1024 saa717x_write(sd, 0xAC, (u8)(h_scale & 0xFF)); in saa717x_set_fmt()
1025 saa717x_write(sd, 0xAD, (u8)((h_scale >> 8) & 0xFF)); in saa717x_set_fmt()
1028 set_v_scale(sd, 0, v_scale); in saa717x_set_fmt()
1029 set_v_scale(sd, 1, v_scale); in saa717x_set_fmt()
1034 saa717x_write(sd, 0x5C, (u8)(fmt->width & 0xFF)); in saa717x_set_fmt()
1035 saa717x_write(sd, 0x5D, (u8)((fmt->width >> 8) & 0xFF)); in saa717x_set_fmt()
1037 saa717x_write(sd, 0x9C, (u8)(fmt->width & 0xFF)); in saa717x_set_fmt()
1038 saa717x_write(sd, 0x9D, (u8)((fmt->width >> 8) & 0xFF)); in saa717x_set_fmt()
1042 saa717x_write(sd, 0x5E, (u8)(fmt->height & 0xFF)); in saa717x_set_fmt()
1043 saa717x_write(sd, 0x5F, (u8)((fmt->height >> 8) & 0xFF)); in saa717x_set_fmt()
1045 saa717x_write(sd, 0x9E, (u8)(fmt->height & 0xFF)); in saa717x_set_fmt()
1046 saa717x_write(sd, 0x9F, (u8)((fmt->height >> 8) & 0xFF)); in saa717x_set_fmt()
1050 static int saa717x_s_radio(struct v4l2_subdev *sd) in saa717x_s_radio() argument
1052 struct saa717x_state *decoder = to_state(sd); in saa717x_s_radio()
1058 static int saa717x_s_std(struct v4l2_subdev *sd, v4l2_std_id std) in saa717x_s_std() argument
1060 struct saa717x_state *decoder = to_state(sd); in saa717x_s_std()
1062 v4l2_dbg(1, debug, sd, "decoder set norm "); in saa717x_s_std()
1063 v4l2_dbg(1, debug, sd, "(not yet implemented)\n"); in saa717x_s_std()
1070 static int saa717x_s_audio_routing(struct v4l2_subdev *sd, in saa717x_s_audio_routing() argument
1073 struct saa717x_state *decoder = to_state(sd); in saa717x_s_audio_routing()
1077 v4l2_dbg(1, debug, sd, in saa717x_s_audio_routing()
1080 set_audio_regs(sd, decoder); in saa717x_s_audio_routing()
1086 static int saa717x_s_stream(struct v4l2_subdev *sd, int enable) in saa717x_s_stream() argument
1088 struct saa717x_state *decoder = to_state(sd); in saa717x_s_stream()
1090 v4l2_dbg(1, debug, sd, "decoder %s output\n", in saa717x_s_stream()
1093 saa717x_write(sd, 0x193, enable ? 0xa6 : 0x26); in saa717x_s_stream()
1098 static int saa717x_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt) in saa717x_s_tuner() argument
1100 struct saa717x_state *decoder = to_state(sd); in saa717x_s_tuner()
1123 v4l2_dbg(1, debug, sd, "change audio mode to %s\n", in saa717x_s_tuner()
1128 set_audio_mode(sd, decoder->tuner_audio_mode); in saa717x_s_tuner()
1132 static int saa717x_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) in saa717x_g_tuner() argument
1134 struct saa717x_state *decoder = to_state(sd); in saa717x_g_tuner()
1139 get_inf_dev_status(sd, &dual_f, &stereo_f); in saa717x_g_tuner()
1141 v4l2_dbg(1, debug, sd, "DETECT==st:%d dual:%d\n", in saa717x_g_tuner()
1147 v4l2_dbg(1, debug, sd, "DETECT==MONO\n"); in saa717x_g_tuner()
1155 v4l2_dbg(1, debug, sd, "DETECT==ST(ST)\n"); in saa717x_g_tuner()
1158 v4l2_dbg(1, debug, sd, "DETECT==ST(MONO)\n"); in saa717x_g_tuner()
1166 v4l2_dbg(1, debug, sd, "DETECT==DUAL1\n"); in saa717x_g_tuner()
1169 v4l2_dbg(1, debug, sd, "DETECT==DUAL2\n"); in saa717x_g_tuner()
1175 static int saa717x_log_status(struct v4l2_subdev *sd) in saa717x_log_status() argument
1177 struct saa717x_state *state = to_state(sd); in saa717x_log_status()
1179 v4l2_ctrl_handler_log_status(&state->hdl, sd->name); in saa717x_log_status()
1235 struct v4l2_subdev *sd; in saa717x_probe() local
1247 sd = &decoder->sd; in saa717x_probe()
1248 v4l2_i2c_subdev_init(sd, client, &saa717x_ops); in saa717x_probe()
1250 if (saa717x_write(sd, 0x5a4, 0xfe) && in saa717x_probe()
1251 saa717x_write(sd, 0x5a5, 0x0f) && in saa717x_probe()
1252 saa717x_write(sd, 0x5a6, 0x00) && in saa717x_probe()
1253 saa717x_write(sd, 0x5a7, 0x01)) in saa717x_probe()
1254 id = saa717x_read(sd, 0x5a0); in saa717x_probe()
1256 v4l2_dbg(1, debug, sd, "saa717x not found (id=%02x)\n", id); in saa717x_probe()
1267 v4l2_info(sd, "%s found @ 0x%x (%s)\n", p, in saa717x_probe()
1291 sd->ctrl_handler = hdl; in saa717x_probe()
1314 v4l2_dbg(1, debug, sd, "writing init values\n"); in saa717x_probe()
1317 saa717x_write_regs(sd, reg_init_initialize); in saa717x_probe()
1328 struct v4l2_subdev *sd = i2c_get_clientdata(client); in saa717x_remove() local
1330 v4l2_device_unregister_subdev(sd); in saa717x_remove()
1331 v4l2_ctrl_handler_free(sd->ctrl_handler); in saa717x_remove()