22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/i2c.h>
25 #include <linux/types.h>
26 #include <linux/videodev2.h>
28 #include <linux/errno.h>
29 #include <linux/slab.h>
30 #include <linux/poll.h>
31 #include <linux/wait.h>
32 #include <asm/uaccess.h>
40 static unsigned int debug;
41 static unsigned int xtal;
42 static unsigned int mmbs;
43 static unsigned int plvl;
44 static unsigned int bufblocks = 100;
65 #define PREFIX "saa6588: "
66 #define dprintk if (debug) printk
97 #define cModeStandard 0x00
98 #define cModeFastPI 0x01
99 #define cModeReducedRequest 0x02
100 #define cModeInvalid 0x03
103 #define cProcessingModeRDS 0x00
104 #define cProcessingModeRBDS 0x04
107 #define cErrCorrectionNone 0x00
108 #define cErrCorrection2Bits 0x08
109 #define cErrCorrection5Bits 0x10
110 #define cErrCorrectionNoneRBDS 0x18
113 #define cSyncNormal 0x00
114 #define cSyncRestart 0x20
117 #define cSigQualityDetectOFF 0x00
118 #define cSigQualityDetectON 0x40
121 #define cSigQualityTriggered 0x00
122 #define cSigQualityContinous 0x80
127 #define cFlywheelMaxBlocksMask 0x3F
128 #define cFlywheelDefault 0x20
131 #define cPauseLevel_11mV 0x00
132 #define cPauseLevel_17mV 0x40
133 #define cPauseLevel_27mV 0x80
134 #define cPauseLevel_43mV 0xC0
139 #define cQualityDetectSensMask 0x1F
140 #define cQualityDetectDefault 0x0F
143 #define cSelectOscFreqOFF 0x00
144 #define cSelectOscFreqON 0x20
147 #define cOscFreq_4332kHz 0x00
148 #define cOscFreq_8664kHz 0x40
149 #define cOscFreq_12996kHz 0x80
150 #define cOscFreq_17328kHz 0xC0
154 static int block_to_user_buf(
struct saa6588 *
s,
unsigned char __user *user_buf)
190 unsigned int rd_blocks;
211 spin_unlock_irqrestore(&s->
lock, flags);
215 for (i = 0; i < rd_blocks; i++) {
216 if (block_to_user_buf(s, buf_ptr)) {
224 spin_unlock_irqrestore(&s->
lock, flags);
227 static void block_to_buf(
struct saa6588 *s,
unsigned char *blockbuf)
234 for (i = 0; i < 3; ++
i) {
236 dprintk(
"0x%02x ", blockbuf[i]);
255 static void saa6588_i2c_poll(
struct saa6588 *s)
260 unsigned char blocknum;
271 s->
sync = tmpbuf[0] & 0x10;
274 blocknum = tmpbuf[0] >> 5;
277 dprintk(
"Saw block %d again.\n", blocknum);
300 tmpbuf[2] = tmpbuf[0];
310 else if (!mmbs && blocknum == 5)
313 tmp |= blocknum << 3;
314 if ((tmpbuf[2] & 0x03) == 0x03)
316 else if ((tmpbuf[2] & 0x03) != 0x00)
321 block_to_buf(s, tmpbuf);
322 spin_unlock_irqrestore(&s->
lock, flags);
335 static void saa6588_configure(
struct saa6588 *s)
337 struct i2c_client *client = v4l2_get_subdevdata(&s->
sd);
338 unsigned char buf[3];
383 buf[0], buf[1], buf[2]);
387 printk(
PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc);
394 struct saa6588 *s = to_saa6588(sd);
430 struct saa6588 *s = to_saa6588(sd);
440 struct saa6588 *s = to_saa6588(sd);
442 saa6588_configure(s);
448 struct i2c_client *client = v4l2_get_subdevdata(sd);
456 .g_chip_ident = saa6588_g_chip_ident,
457 .ioctl = saa6588_ioctl,
461 .g_tuner = saa6588_g_tuner,
462 .s_tuner = saa6588_s_tuner,
466 .core = &saa6588_core_ops,
467 .tuner = &saa6588_tuner_ops,
472 static int saa6588_probe(
struct i2c_client *client,
478 v4l_info(client,
"saa6588 found @ 0x%x (%s)\n",
502 saa6588_configure(s);
510 static int saa6588_remove(
struct i2c_client *client)
512 struct v4l2_subdev *sd = i2c_get_clientdata(client);
513 struct saa6588 *s = to_saa6588(sd);
537 .probe = saa6588_probe,
538 .remove = saa6588_remove,
539 .id_table = saa6588_id,