Lines Matching refs:sd

66 	struct v4l2_subdev sd;  member
78 static inline struct venc_state *to_state(struct v4l2_subdev *sd) in to_state() argument
80 return container_of(sd, struct venc_state, sd); in to_state()
83 static inline u32 venc_read(struct v4l2_subdev *sd, u32 offset) in venc_read() argument
85 struct venc_state *venc = to_state(sd); in venc_read()
90 static inline u32 venc_write(struct v4l2_subdev *sd, u32 offset, u32 val) in venc_write() argument
92 struct venc_state *venc = to_state(sd); in venc_write()
99 static inline u32 venc_modify(struct v4l2_subdev *sd, u32 offset, in venc_modify() argument
102 u32 new_val = (venc_read(sd, offset) & ~mask) | (val & mask); in venc_modify()
104 venc_write(sd, offset, new_val); in venc_modify()
109 static inline u32 vdaccfg_write(struct v4l2_subdev *sd, u32 val) in vdaccfg_write() argument
111 struct venc_state *venc = to_state(sd); in vdaccfg_write()
124 static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index) in venc_set_dac() argument
128 v4l2_dbg(debug, 1, sd, "Setting output to Composite\n"); in venc_set_dac()
129 venc_write(sd, VENC_DACSEL, 0); in venc_set_dac()
132 v4l2_dbg(debug, 1, sd, "Setting output to Component\n"); in venc_set_dac()
133 venc_write(sd, VENC_DACSEL, VDAC_COMPONENT); in venc_set_dac()
136 v4l2_dbg(debug, 1, sd, "Setting output to S-video\n"); in venc_set_dac()
137 venc_write(sd, VENC_DACSEL, VDAC_S_VIDEO); in venc_set_dac()
146 static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable) in venc_enabledigitaloutput() argument
148 struct venc_state *venc = to_state(sd); in venc_enabledigitaloutput()
150 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n"); in venc_enabledigitaloutput()
153 venc_write(sd, VENC_VMOD, 0); in venc_enabledigitaloutput()
154 venc_write(sd, VENC_CVBS, 0); in venc_enabledigitaloutput()
155 venc_write(sd, VENC_LCDOUT, 0); in venc_enabledigitaloutput()
156 venc_write(sd, VENC_HSPLS, 0); in venc_enabledigitaloutput()
157 venc_write(sd, VENC_HSTART, 0); in venc_enabledigitaloutput()
158 venc_write(sd, VENC_HVALID, 0); in venc_enabledigitaloutput()
159 venc_write(sd, VENC_HINT, 0); in venc_enabledigitaloutput()
160 venc_write(sd, VENC_VSPLS, 0); in venc_enabledigitaloutput()
161 venc_write(sd, VENC_VSTART, 0); in venc_enabledigitaloutput()
162 venc_write(sd, VENC_VVALID, 0); in venc_enabledigitaloutput()
163 venc_write(sd, VENC_VINT, 0); in venc_enabledigitaloutput()
164 venc_write(sd, VENC_YCCCTL, 0); in venc_enabledigitaloutput()
165 venc_write(sd, VENC_DACSEL, 0); in venc_enabledigitaloutput()
168 venc_write(sd, VENC_VMOD, 0); in venc_enabledigitaloutput()
170 venc_write(sd, VENC_VIDCTL, 0x141); in venc_enabledigitaloutput()
173 venc_write(sd, VENC_SYNCCTL, 0); in venc_enabledigitaloutput()
176 venc_write(sd, VENC_DCLKCTL, 0); in venc_enabledigitaloutput()
177 venc_write(sd, VENC_DRGBX1, 0x0000057C); in venc_enabledigitaloutput()
180 venc_write(sd, VENC_LCDOUT, 0); in venc_enabledigitaloutput()
182 venc_write(sd, VENC_CMPNT, 0x100); in venc_enabledigitaloutput()
183 venc_write(sd, VENC_HSPLS, 0); in venc_enabledigitaloutput()
184 venc_write(sd, VENC_HINT, 0); in venc_enabledigitaloutput()
185 venc_write(sd, VENC_HSTART, 0); in venc_enabledigitaloutput()
186 venc_write(sd, VENC_HVALID, 0); in venc_enabledigitaloutput()
188 venc_write(sd, VENC_VSPLS, 0); in venc_enabledigitaloutput()
189 venc_write(sd, VENC_VINT, 0); in venc_enabledigitaloutput()
190 venc_write(sd, VENC_VSTART, 0); in venc_enabledigitaloutput()
191 venc_write(sd, VENC_VVALID, 0); in venc_enabledigitaloutput()
193 venc_write(sd, VENC_HSDLY, 0); in venc_enabledigitaloutput()
194 venc_write(sd, VENC_VSDLY, 0); in venc_enabledigitaloutput()
196 venc_write(sd, VENC_YCCCTL, 0); in venc_enabledigitaloutput()
197 venc_write(sd, VENC_VSTARTA, 0); in venc_enabledigitaloutput()
200 venc_write(sd, VENC_OSDCLK0, 1); in venc_enabledigitaloutput()
201 venc_write(sd, VENC_OSDCLK1, 2); in venc_enabledigitaloutput()
229 static int venc_set_ntsc(struct v4l2_subdev *sd) in venc_set_ntsc() argument
232 struct venc_state *venc = to_state(sd); in venc_set_ntsc()
235 v4l2_dbg(debug, 2, sd, "venc_set_ntsc\n"); in venc_set_ntsc()
243 venc_enabledigitaloutput(sd, 0); in venc_set_ntsc()
246 venc_write(sd, VENC_CLKCTL, 0x01); in venc_set_ntsc()
247 venc_write(sd, VENC_VIDCTL, 0); in venc_set_ntsc()
248 val = vdaccfg_write(sd, VDAC_CONFIG_SD_V3); in venc_set_ntsc()
250 venc_write(sd, VENC_CLKCTL, 0x01); in venc_set_ntsc()
251 venc_write(sd, VENC_VIDCTL, 0); in venc_set_ntsc()
252 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); in venc_set_ntsc()
255 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); in venc_set_ntsc()
257 venc_write(sd, VENC_YCCCTL, 0x1); in venc_set_ntsc()
258 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ); in venc_set_ntsc()
259 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS); in venc_set_ntsc()
262 venc_write(sd, VENC_VMOD, 0); in venc_set_ntsc()
263 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_ntsc()
265 venc_modify(sd, VENC_VMOD, (0 << VENC_VMOD_VMD), VENC_VMOD_VMD); in venc_set_ntsc()
266 venc_modify(sd, VENC_VMOD, (0 << VENC_VMOD_TVTYP_SHIFT), in venc_set_ntsc()
268 venc_write(sd, VENC_DACTST, 0x0); in venc_set_ntsc()
269 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_ntsc()
277 static int venc_set_pal(struct v4l2_subdev *sd) in venc_set_pal() argument
279 struct venc_state *venc = to_state(sd); in venc_set_pal()
281 v4l2_dbg(debug, 2, sd, "venc_set_pal\n"); in venc_set_pal()
289 venc_enabledigitaloutput(sd, 0); in venc_set_pal()
292 venc_write(sd, VENC_CLKCTL, 0x1); in venc_set_pal()
293 venc_write(sd, VENC_VIDCTL, 0); in venc_set_pal()
294 vdaccfg_write(sd, VDAC_CONFIG_SD_V3); in venc_set_pal()
296 venc_write(sd, VENC_CLKCTL, 0x1); in venc_set_pal()
297 venc_write(sd, VENC_VIDCTL, 0); in venc_set_pal()
298 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); in venc_set_pal()
301 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); in venc_set_pal()
303 venc_write(sd, VENC_YCCCTL, 0x1); in venc_set_pal()
306 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT, in venc_set_pal()
308 venc_write(sd, VENC_VMOD, 0); in venc_set_pal()
309 venc_modify(sd, VENC_VMOD, in venc_set_pal()
312 venc_modify(sd, VENC_VMOD, in venc_set_pal()
314 venc_modify(sd, VENC_VMOD, in venc_set_pal()
317 venc_write(sd, VENC_DACTST, 0x0); in venc_set_pal()
318 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_pal()
329 static int venc_set_480p59_94(struct v4l2_subdev *sd) in venc_set_480p59_94() argument
331 struct venc_state *venc = to_state(sd); in venc_set_480p59_94()
334 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n"); in venc_set_480p59_94()
344 venc_enabledigitaloutput(sd, 0); in venc_set_480p59_94()
347 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_set_480p59_94()
348 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_480p59_94()
349 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_480p59_94()
352 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, in venc_set_480p59_94()
354 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, in venc_set_480p59_94()
358 venc_write(sd, VENC_VMOD, 0); in venc_set_480p59_94()
359 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_480p59_94()
361 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_480p59_94()
362 venc_modify(sd, VENC_VMOD, (HDTV_525P << VENC_VMOD_TVTYP_SHIFT), in venc_set_480p59_94()
364 venc_modify(sd, VENC_VMOD, VENC_VMOD_VDMD_YCBCR8 << in venc_set_480p59_94()
367 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_480p59_94()
377 static int venc_set_576p50(struct v4l2_subdev *sd) in venc_set_576p50() argument
379 struct venc_state *venc = to_state(sd); in venc_set_576p50()
382 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n"); in venc_set_576p50()
392 venc_enabledigitaloutput(sd, 0); in venc_set_576p50()
395 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_set_576p50()
397 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_576p50()
398 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_576p50()
401 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, in venc_set_576p50()
403 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, in venc_set_576p50()
407 venc_write(sd, VENC_VMOD, 0); in venc_set_576p50()
408 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_576p50()
410 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_576p50()
411 venc_modify(sd, VENC_VMOD, (HDTV_625P << VENC_VMOD_TVTYP_SHIFT), in venc_set_576p50()
414 venc_modify(sd, VENC_VMOD, VENC_VMOD_VDMD_YCBCR8 << in venc_set_576p50()
416 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_576p50()
424 static int venc_set_720p60_internal(struct v4l2_subdev *sd) in venc_set_720p60_internal() argument
426 struct venc_state *venc = to_state(sd); in venc_set_720p60_internal()
433 venc_enabledigitaloutput(sd, 0); in venc_set_720p60_internal()
435 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_720p60_internal()
436 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_720p60_internal()
438 venc_write(sd, VENC_VMOD, 0); in venc_set_720p60_internal()
440 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_720p60_internal()
442 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_720p60_internal()
443 venc_modify(sd, VENC_VMOD, (HDTV_720P << VENC_VMOD_TVTYP_SHIFT), in venc_set_720p60_internal()
445 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_720p60_internal()
446 venc_write(sd, VENC_XHINTVL, 0); in venc_set_720p60_internal()
453 static int venc_set_1080i30_internal(struct v4l2_subdev *sd) in venc_set_1080i30_internal() argument
455 struct venc_state *venc = to_state(sd); in venc_set_1080i30_internal()
462 venc_enabledigitaloutput(sd, 0); in venc_set_1080i30_internal()
464 venc_write(sd, VENC_OSDCLK0, 0); in venc_set_1080i30_internal()
465 venc_write(sd, VENC_OSDCLK1, 1); in venc_set_1080i30_internal()
468 venc_write(sd, VENC_VMOD, 0); in venc_set_1080i30_internal()
470 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), in venc_set_1080i30_internal()
472 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD); in venc_set_1080i30_internal()
473 venc_modify(sd, VENC_VMOD, (HDTV_1080I << VENC_VMOD_TVTYP_SHIFT), in venc_set_1080i30_internal()
475 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC); in venc_set_1080i30_internal()
476 venc_write(sd, VENC_XHINTVL, 0); in venc_set_1080i30_internal()
480 static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm) in venc_s_std_output() argument
482 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n"); in venc_s_std_output()
485 return venc_set_ntsc(sd); in venc_s_std_output()
487 return venc_set_pal(sd); in venc_s_std_output()
492 static int venc_s_dv_timings(struct v4l2_subdev *sd, in venc_s_dv_timings() argument
495 struct venc_state *venc = to_state(sd); in venc_s_dv_timings()
499 v4l2_dbg(debug, 1, sd, "venc_s_dv_timings\n"); in venc_s_dv_timings()
502 return venc_set_576p50(sd); in venc_s_dv_timings()
504 return venc_set_480p59_94(sd); in venc_s_dv_timings()
508 ret = venc_set_720p60_internal(sd); in venc_s_dv_timings()
510 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_s_dv_timings()
515 ret = venc_set_1080i30_internal(sd); in venc_s_dv_timings()
517 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); in venc_s_dv_timings()
523 static int venc_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, in venc_s_routing() argument
526 struct venc_state *venc = to_state(sd); in venc_s_routing()
529 v4l2_dbg(debug, 1, sd, "venc_s_routing\n"); in venc_s_routing()
531 ret = venc_set_dac(sd, output); in venc_s_routing()
538 static long venc_ioctl(struct v4l2_subdev *sd, in venc_ioctl() argument
546 val = venc_read(sd, VENC_VSTAT); in venc_ioctl()
551 v4l2_err(sd, "Wrong IOCTL cmd\n"); in venc_ioctl()
573 static int venc_initialize(struct v4l2_subdev *sd) in venc_initialize() argument
575 struct venc_state *venc = to_state(sd); in venc_initialize()
582 ret = venc_s_routing(sd, 0, venc->output, 0); in venc_initialize()
584 v4l2_err(sd, "Error setting output during init\n"); in venc_initialize()
588 ret = venc_s_std_output(sd, venc->std); in venc_initialize()
590 v4l2_err(sd, "Error setting std during init\n"); in venc_initialize()
619 v4l2_subdev_init(&venc->sd, &venc_ops); in venc_sub_dev_init()
621 strcpy(venc->sd.name, venc_name); in venc_sub_dev_init()
622 if (v4l2_device_register_subdev(v4l2_dev, &venc->sd) < 0) { in venc_sub_dev_init()
627 if (venc_initialize(&venc->sd)) { in venc_sub_dev_init()
633 return &venc->sd; in venc_sub_dev_init()