Kworld 315U and SAA7113?
I tweaked the GPIO's a bit more for the Kworld 315U and switching between analog and digital signals is more reliable now. Attached is an updated diff.
linux/drivers/media/video/em28xx/em28xx-cards.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/em28xx/em28xx-cards.c Thu Dec 31 19:14:54 2009 -0200 +35 -9
@@ -122,13 +122,31 @@ }; #endif +/* Kworld 315U + GPIO0 - Enable digital power (lgdt3303) - low to enable + GPIO1 - Enable analog power (saa7113/emp202) - low to enable + GPIO7 - enables something ? + GOP2 - ?? some sort of reset ? + GOP3 - lgdt3303 reset + */ /* Board - EM2882 Kworld 315U digital */ static struct em28xx_reg_seq em2882_kworld_315u_digital[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM28XX_R08_GPIO, 0xfe, 0xff, 10}, + {EM28XX_R08_GPIO, 0x7e, 0xff, 10}, {EM2880_R04_GPO, 0x04, 0xff, 10}, {EM2880_R04_GPO, 0x0c, 0xff, 10}, - {EM28XX_R08_GPIO, 0x7e, 0xff, 10}, + { -1, -1, -1, -1}, +}; + +/* Board - EM2882 Kworld 315U analog1 analog tv */ +static struct em28xx_reg_seq em2882_kworld_315u_analog1[] = { + {EM28XX_R08_GPIO, 0xfd, 0xff, 10}, + {EM28XX_R08_GPIO, 0x7d, 0xff, 10}, + { -1, -1, -1, -1}, +}; + +/* Board - EM2882 Kworld 315U analog2 component/svideo */ +static struct em28xx_reg_seq em2882_kworld_315u_analog2[] = { + {EM28XX_R08_GPIO, 0xfd, 0xff, 10}, { -1, -1, -1, -1}, };
@@ -140,6 +158,14 @@ { -1, -1, -1, -1}, }; +/* Board - EM2882 Kworld 315U suspend */ +static struct em28xx_reg_seq em2882_kworld_315u_suspend[] = { + {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2880_R04_GPO, 0x08, 0xff, 10}, + {EM2880_R04_GPO, 0x0c, 0xff, 10}, + { -1, -1, -1, -1}, +}; + static struct em28xx_reg_seq kworld_330u_analog[] = { {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x00, 0xff, 10},
@@ -1314,28 +1340,28 @@ .decoder = EM28XX_SAA711X, .has_dvb = 1, .dvb_gpio = em2882_kworld_315u_digital, + .suspend_gpio = em2882_kworld_315u_suspend, .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE, - /* Analog mode - still not ready */ - /*.input = { { + .input = { { .type = EM28XX_VMUX_TELEVISION, .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, - .gpio = em2882_kworld_315u_analog, + .gpio = em2882_kworld_315u_analog1, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { .type = EM28XX_VMUX_COMPOSITE1, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, - .gpio = em2882_kworld_315u_analog1, + .gpio = em2882_kworld_315u_analog2, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { .type = EM28XX_VMUX_SVIDEO, .vmux = SAA7115_SVIDEO3, .amux = EM28XX_AMUX_LINE_IN, - .gpio = em2882_kworld_315u_analog1, + .gpio = em2882_kworld_315u_analog2, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, - } }, */ + } }, }, [EM2880_BOARD_EMPIRE_DUAL_TV] = { .name = "Empire dual TV",
linux/drivers/media/video/em28xx/em28xx-core.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/em28xx/em28xx-core.c Thu Dec 31 19:14:54 2009 -0200 +1 -0
@@ -1132,6 +1132,7 @@ */ void em28xx_wake_i2c(struct em28xx *dev) { + v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 1); v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, 0); v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, INPUT(dev->ctl_input)->vmux, 0, 0);
linux/drivers/media/video/saa7115.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/saa7115.c Thu Dec 31 19:14:54 2009 -0200 +54 -0
66 lines not on this page · raw message
Thanks,
Franklin Meng
Quoted 56 lines · Franklin Meng
From: Franklin Meng <[email protected]>
Subject: Kworld 315U and SAA7113?
To: [email protected]
Date: Thursday, January 7, 2010, 7:48 PM
After some work I have finally gotten
the analog inputs to work with the Kworld 315U device. I have attached the changes/updates to the em28xx driver.
Note: I still don't have analog sound working yet..I am hoping someone can comment on the changes in saa7115.c. I added a
s_powerroutine to reinitialize the device. The reason I am reinitializing this device is because1. I cannot keep both the LG demod and the SAA powered on at the same time for my device
2. The SAA datasheet seems to suggest that after a reset/power-on the chip needs to be reinitialized.
3. Reinitializing causes the analog inputs to work correctly.
Here's what is says in the SAA7113 datasheet..
....
Status after power-on
control sequenceVPO7 to VPO0, RTCO, RTS0 and RTS1
are held in high-impedance stateafter power-on (reset
sequence) a complete
I2C-bus transmission is
required
...
The above is really suppose to be arranged horizontally in 3 columns. Anyways, the last part describes that "a complete I2C bus transmission is required" This is why I think the chip needs to be reinitialized.Last thing is that the initialization routing uses these defaults:
state->bright = 128;
state->contrast = 64;
state->hue = 0;
state->sat = 64;I was wondering if we should just read the back the values that were initialized by the initialization routine and use those values instead.The reason is because it seems like the different SAA's use slightly different values when initializing.
Quoted 5 lines
Thanks,
Franklin Meng
linux/drivers/media/video/em28xx/em28xx-cards.c +35 -9
82 lines not on this page · raw message
linux/drivers/media/video/em28xx/em28xx-core.c +1 -0
@@ -1132,6 +1132,7 @@*/ void em28xx_wake_i2c (struct em28xx *dev) { +v4l2_device_call_all (&dev->v4l2_dev,0 , core, s_power,1 );v4l2_device_call_all (&dev->v4l2_dev,0 , core, reset,0 );v4l2_device_call_all (&dev->v4l2_dev,0 , video, s_routing,INPUT (dev->ctl_input)->vmux,0 ,0 );
linux/drivers/media/video/saa7115.c +54 -0
66 lines not on this page · raw message
Hi Franklin,
I have no Kworld 315U here for testing, but your patch looked sane on my eyes. In order to merge this upstream, it would be better if you could submit it as two separate patches: the first one with the saa7115 changes to support re-energizing the device, and the second one with the em28xx changes.
Please send your Signed-off-by: on the patches.
Cheers,
Mauro.
Quoted 244 lines · Franklin Meng
I tweaked the GPIO's a bit more for the Kworld 315U and switching between analog and digital signals is more reliable now. Attached is an updated diff.
diff -r
b6b82258cf5elinux/drivers/media/video/em28xx/em28xx-cards.clinux/drivers/media/video/em28xx/em28xx-cards.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/em28xx/em28xx-cards.c Thu Dec 31 19:14:54 2009 -0200 +35
-9@@ -122,13 +122,31 @@ }; #endif +/* Kworld 315U + GPIO0 - Enable digital power (lgdt3303) - low to enable + GPIO1 - Enable analog power (saa7113/emp202) - low to enable + GPIO7 - enables something ? + GOP2 - ?? some sort of reset ? + GOP3 - lgdt3303 reset + */ /* Board - EM2882 Kworld 315U digital */ static struct em28xx_reg_seq em2882_kworld_315u_digital[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM28XX_R08_GPIO, 0xfe, 0xff, 10}, + {EM28XX_R08_GPIO, 0x7e, 0xff, 10}, {EM2880_R04_GPO, 0x04, 0xff, 10}, {EM2880_R04_GPO, 0x0c, 0xff, 10}, - {EM28XX_R08_GPIO, 0x7e, 0xff, 10}, + { -1, -1, -1, -1}, +}; + +/* Board - EM2882 Kworld 315U analog1 analog tv */ +static struct em28xx_reg_seq em2882_kworld_315u_analog1[] = { + {EM28XX_R08_GPIO, 0xfd, 0xff, 10}, + {EM28XX_R08_GPIO, 0x7d, 0xff, 10}, + { -1, -1, -1, -1}, +}; + +/* Board - EM2882 Kworld 315U analog2 component/svideo */ +static struct em28xx_reg_seq em2882_kworld_315u_analog2[] = { + {EM28XX_R08_GPIO, 0xfd, 0xff, 10}, { -1, -1, -1, -1}, };@@ -140,6 +158,14 @@ { -1, -1, -1, -1}, }; +/* Board - EM2882 Kworld 315U suspend */ +static struct em28xx_reg_seq em2882_kworld_315u_suspend[] = { + {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2880_R04_GPO, 0x08, 0xff, 10}, + {EM2880_R04_GPO, 0x0c, 0xff, 10}, + { -1, -1, -1, -1}, +}; + static struct em28xx_reg_seq kworld_330u_analog[] = { {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x00, 0xff, 10},@@ -1314,28 +1340,28 @@ .decoder = EM28XX_SAA711X, .has_dvb = 1, .dvb_gpio = em2882_kworld_315u_digital, + .suspend_gpio = em2882_kworld_315u_suspend, .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE, - /* Analog mode - still not ready */ - /*.input = { { + .input = { { .type = EM28XX_VMUX_TELEVISION, .vmux = SAA7115_COMPOSITE2, .amux = EM28XX_AMUX_VIDEO, - .gpio = em2882_kworld_315u_analog, + .gpio = em2882_kworld_315u_analog1, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { .type = EM28XX_VMUX_COMPOSITE1, .vmux = SAA7115_COMPOSITE0, .amux = EM28XX_AMUX_LINE_IN, - .gpio = em2882_kworld_315u_analog1, + .gpio = em2882_kworld_315u_analog2, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, }, { .type = EM28XX_VMUX_SVIDEO, .vmux = SAA7115_SVIDEO3, .amux = EM28XX_AMUX_LINE_IN, - .gpio = em2882_kworld_315u_analog1, + .gpio = em2882_kworld_315u_analog2, .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, - } }, */ + } }, }, [EM2880_BOARD_EMPIRE_DUAL_TV] = { .name = "Empire dual TV",diff -r
b6b82258cf5elinux/drivers/media/video/em28xx/em28xx-core.clinux/drivers/media/video/em28xx/em28xx-core.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/em28xx/em28xx-core.c Thu Dec 31 19:14:54 2009 -0200 +1
-0@@ -1132,6 +1132,7 @@ */ void em28xx_wake_i2c(struct em28xx *dev) { + v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 1); v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, 0); v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, INPUT(dev->ctl_input)->vmux, 0, 0);diff -r
b6b82258cf5elinux/drivers/media/video/saa7115.clinux/drivers/media/video/saa7115.c Sat Jan 09 11:29:27 2010 -0800 renamed from linux/drivers/media/video/saa7115.c Thu Dec 31 19:14:54 2009 -0200 +54
-0@@ -1338,6 +1338,59 @@ return 0; } +static int saa711x_s_power(struct v4l2_subdev *sd, int val) +{ + struct saa711x_state *state = to_state(sd); + + if(val > 1 || val < 0) + return -EINVAL; + + /* There really isn't a way to put the chip into power saving + other than by pulling CE to ground so all we do is return + out of this function + */ + if(val == 0) + return 0; + + /* When enabling the chip again we need to reinitialize the + all the values + */ + state->input = -1; + state->output = SAA7115_IPORT_ON; + state->enable = 1; + state->radio = 0; + state->bright = 128; + state->contrast = 64; + state->hue = 0; + state->sat = 64; + + state->audclk_freq = 48000; + + v4l2_dbg(1, debug, sd, "writing init values s_power\n"); + + /* init to 60hz/48khz */ + state->crystal_freq = SAA7115_FREQ_24_576_MHZ; + switch (state->ident) { + case V4L2_IDENT_SAA7111: + saa711x_writeregs(sd, saa7111_init); + break; + case V4L2_IDENT_SAA7113: + saa711x_writeregs(sd, saa7113_init); + break; + default: + state->crystal_freq = SAA7115_FREQ_32_11_MHZ; + saa711x_writeregs(sd, saa7115_init_auto_input); + } + if (state->ident != V4L2_IDENT_SAA7111) + saa711x_writeregs(sd, saa7115_init_misc); + saa711x_set_v4lstd(sd, V4L2_STD_NTSC); + + v4l2_dbg(1, debug, sd, "status: (1E) 0x%02x, (1F) 0x%02x\n", + saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC), + saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC)); + return 0; +} + static int saa711x_reset(struct v4l2_subdev *sd, u32 val) { v4l2_dbg(1, debug, sd, "decoder RESET\n");@@ -1513,6 +1566,7 @@ .s_std = saa711x_s_std, .reset = saa711x_reset, .s_gpio = saa711x_s_gpio, + .s_power = saa711x_s_power, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = saa711x_g_register, .s_register = saa711x_s_register,Thanks,
Franklin MengQuoted 61 lines · Franklin Meng
From: Franklin Meng <[email protected]>
Subject: Kworld 315U and SAA7113?
To: [email protected]
Date: Thursday, January 7, 2010, 7:48 PM
After some work I have finally gotten
the analog inputs to work with the Kworld 315U device. I have attached the changes/updates to the em28xx driver.
Note: I still don't have analog sound working yet..I am hoping someone can comment on the changes in
saa7115.c. I added as_powerroutine to reinitialize the device. The reason I am reinitializing this device is because1. I cannot keep both the LG demod and the SAA powered on at the same time for my device
2. The SAA datasheet seems to suggest that after a reset/power-on the chip needs to be reinitialized.
3. Reinitializing causes the analog inputs to work correctly.
Here's what is says in the SAA7113 datasheet..
....
Status after power-on
control sequenceVPO7 to VPO0, RTCO, RTS0 and RTS1
are held in high-impedance stateafter power-on (reset
sequence) a complete
I2C-bus transmission is
required
...
The above is really suppose to be arranged horizontally in 3 columns. Anyways, the last part describes that "a complete I2C bus transmission is required" This is why I think the chip needs to be reinitialized.Last thing is that the initialization routing uses these defaults:
state->bright = 128; state->contrast = 64; state->hue = 0; state->sat = 64;I was wondering if we should just read the back the values that were initialized by the initialization routine and use those values instead.The reason is because it seems like the different SAA's use slightly different values when initializing.
Thanks,
Franklin Meng
Mario,
Thank you for taking a look at this.. I'll resubmit the patches.
Thanks,
Franklin Meng
Quoted 895 lines · Mauro Carvalho Chehab
From: Mauro Carvalho Chehab <[email protected]>
Subject: Re: Kworld 315U and SAA7113?
To: "Franklin Meng" <[email protected]>
Cc: [email protected]
Date: Wednesday, January 13, 2010, 1:10 PM
Hi Franklin,I have no Kworld 315U here for testing, but your patch looked sane on my eyes.
In order to merge this upstream, it would be better if you could submit it as two
separate patches: the first one with the saa7115 changes to support re-energizing
the device, and the second one with the em28xx changes.Please send your Signed-off-by: on the patches.
Cheers,
Mauro.Quoted 1 line · Franklin Meng
I tweaked the GPIO's a bit more for the Kworld 315U
and switching between analog and digital signals is more reliable now. Attached is an updated diff.
Quoted 2 lines
diff -r
b6b82258cf5e
linux/drivers/media/video/em28xx/em28xx-cards.cQuoted 1 line
---
a/linux/drivers/media/video/em28xx/em28xx-cards.c Thu
Dec 31 19:14:54 2009 -0200Quoted 1 line
+++
b/linux/drivers/media/video/em28xx/em28xx-cards.c Sat
Jan 09 11:29:27 2010 -0800Review
Quoted 1 line
(quoted diff) +0
-0@@ -122,13 +122,31 @@
Review line 122
Quoted 1 line
(quoted diff) +0
-0};
Review line 123
Quoted 1 line
(quoted diff) +0
-0#endif
Quoted 1 line
Quoted 1 line
+/* Kworld 315U
Quoted 1 line
+ GPIO0 - Enable digital power
(lgdt3303) - low to enable
Quoted 1 line
+ GPIO1 - Enable analog power
(saa7113/emp202) - low to enable
Quoted 1 line
+ GPIO7 - enables something ?
Quoted 1 line
+ GOP2 - ?? some sort of reset
?
Quoted 1 line
+ GOP3 - lgdt3303 reset
Quoted 1 line
+ */
Quoted 1 line
/* Board - EM2882 Kworld 315U digital */
Quoted 1 line
static struct
em28xx_reg_seqem2882_kworld_315u_digital[] = {
Quoted 1 line
-
{EM28XX_R08_GPIO,
0xff, 0xff,
10},Quoted 1 line
-
{EM28XX_R08_GPIO,
0xfe, 0xff,
10},Quoted 1 line
+
{EM28XX_R08_GPIO,
0x7e, 0xff,
10},Quoted 1 line
{EM2880_R04_GPO,
0x04, 0xff,
10},Quoted 1 line
{EM2880_R04_GPO,
0x0c, 0xff,
10},Quoted 1 line
-
{EM28XX_R08_GPIO,
0x7e, 0xff,
10},Quoted 1 line
+ { -1,
-1, -1,
-1},Quoted 1 line
+};
Quoted 1 line
+
Quoted 1 line
+/* Board - EM2882 Kworld 315U analog1 analog tv
*/
Quoted 1 line
+static struct
em28xx_reg_seqem2882_kworld_315u_analog1[] = {
Quoted 1 line
+
{EM28XX_R08_GPIO,
0xfd, 0xff,
10},Quoted 1 line
+
{EM28XX_R08_GPIO,
0x7d, 0xff,
10},Quoted 1 line
+ { -1,
-1, -1,
-1},Quoted 1 line
+};
Quoted 1 line
+
Quoted 1 line
+/* Board - EM2882 Kworld 315U analog2
component/svideo */
Quoted 1 line
+static struct
em28xx_reg_seqem2882_kworld_315u_analog2[] = {
Quoted 1 line
+
{EM28XX_R08_GPIO,
0xfd, 0xff,
10},Quoted 1 line
{
-1,
-1, -1,
-1},Quoted 1 line
};
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0@@ -140,6 +158,14 @@
Review line 158
Quoted 1 line
(quoted diff) +0
-0{-1,
-1, -1,
-1},Review line 159
Quoted 1 line
(quoted diff) +0
-0};
Quoted 1 line
Quoted 1 line
+/* Board - EM2882 Kworld 315U suspend */
Quoted 1 line
+static struct
em28xx_reg_seqem2882_kworld_315u_suspend[] = {
Quoted 1 line
+
{EM28XX_R08_GPIO,
0xff, 0xff,
10},Quoted 1 line
+
{EM2880_R04_GPO,
0x08, 0xff,
10},Quoted 1 line
+
{EM2880_R04_GPO,
0x0c, 0xff,
10},Quoted 1 line
+ { -1,
-1, -1,
-1},Quoted 1 line
+};
Quoted 1 line
+
Quoted 1 line
static struct
em28xx_reg_seqkworld_330u_analog[] = {
Quoted 1 line
{EM28XX_R08_GPIO,
0x6d, ~EM_GPIO_4,
10},Quoted 1 line
{EM2880_R04_GPO,
0x00, 0xff,
10},Review
Quoted 1 line
(quoted diff) +0
-0@@ -1314,28 +1340,28 @@
Quoted 1 line
.decoder =
EM28XX_SAA711X,Quoted 1 line
.has_dvb =
1,Quoted 1 line
.dvb_gpio =
em2882_kworld_315u_digital,Quoted 1 line
+
.suspend_gpio =
em2882_kworld_315u_suspend,Quoted 1 line
.xclk
=EM28XX_XCLK_FREQUENCY_12MHZ,Quoted 1 line
.i2c_speed =
EM28XX_I2C_CLK_WAIT_ENABLE,Quoted 1 line
-
/* Analog mode - still not ready */
Quoted 1 line
-
/*.input = {
{Quoted 1 line
+
.input = {
{Quoted 1 line
.type =
EM28XX_VMUX_TELEVISION,Quoted 1 line
.vmux =
SAA7115_COMPOSITE2,Quoted 1 line
.amux =
EM28XX_AMUX_VIDEO,Quoted 1 line
-
.gpio =
em2882_kworld_315u_analog,Quoted 1 line
+
.gpio =
em2882_kworld_315u_analog1,Quoted 1 line
.aout =
EM28XX_AOUT_PCM_IN|EM28XX_AOUT_PCM_STEREO,Quoted 1 line
}, {
Quoted 1 line
.type =
EM28XX_VMUX_COMPOSITE1,Quoted 1 line
.vmux =
SAA7115_COMPOSITE0,Quoted 1 line
.amux =
EM28XX_AMUX_LINE_IN,Quoted 1 line
-
.gpio =
em2882_kworld_315u_analog1,Quoted 1 line
+
.gpio =
em2882_kworld_315u_analog2,Quoted 1 line
.aout =
EM28XX_AOUT_PCM_IN|EM28XX_AOUT_PCM_STEREO,Quoted 1 line
}, {
Quoted 1 line
.type =
EM28XX_VMUX_SVIDEO,Quoted 1 line
.vmux =
SAA7115_SVIDEO3,Quoted 1 line
.amux =
EM28XX_AMUX_LINE_IN,Quoted 1 line
-
.gpio =
em2882_kworld_315u_analog1,Quoted 1 line
+
.gpio =
em2882_kworld_315u_analog2,Quoted 1 line
.aout =
EM28XX_AOUT_PCM_IN|EM28XX_AOUT_PCM_STEREO,Quoted 1 line
-
} }, */
Quoted 1 line
+
} },
Quoted 1 line
},
Quoted 1 line
[EM2880_BOARD_EMPIRE_DUAL_TV] = {
Quoted 1 line
.name = "Empire dual TV",
Quoted 1 line
diff -r
b6b82258cf5e
linux/drivers/media/video/em28xx/em28xx-core.cQuoted 1 line
---
a/linux/drivers/media/video/em28xx/em28xx-core.cThu Dec 31 19:14:54 2009 -0200Quoted 1 line
+++
b/linux/drivers/media/video/em28xx/em28xx-core.cSat Jan 09 11:29:27 2010 -0800Review
Quoted 1 line
(quoted diff) +0
-0@@ -1132,6 +1132,7 @@
Review line 1132
Quoted 1 line
(quoted diff) +0
-0*/
Review line 1133
Quoted 1 line
(quoted diff) +0
-0void em28xx_wake_i2c(struct em28xx *dev)
Review line 1134
Quoted 1 line
(quoted diff) +0
-0{
Review line 1135
Quoted 1 line
(quoted diff) +1
-0+v4l2_device_call_all(&dev->v4l2_dev,
0, core,s_power, 1);Quoted 1 line
v4l2_device_call_all(&dev->v4l2_dev,
0, core, reset, 0);Quoted 1 line
v4l2_device_call_all(&dev->v4l2_dev,
0, video,s_routing,Quoted 1 line
INPUT(dev->ctl_input)->vmux, 0,
0);Quoted 1 line
diff -r
b6b82258cf5e
linux/drivers/media/video/saa7115.cQuoted 1 line
---
a/linux/drivers/media/video/saa7115.cThu Dec 31 19:14:54 2009 -0200
Quoted 1 line
+++
b/linux/drivers/media/video/saa7115.cSat Jan 09 11:29:27 2010 -0800
Review
Quoted 1 line
(quoted diff) +0
-0@@ -1338,6 +1338,59 @@
Review line 1338
Quoted 1 line
(quoted diff) +0
-0return 0;
Review line 1339
Quoted 1 line
(quoted diff) +0
-0}
Quoted 1 line
Quoted 1 line
+static int saa711x_s_power(struct
v4l2_subdev*sd,int val)
Quoted 1 line
+{
Quoted 1 line
+ struct
saa711x_state*state =
to_state(sd);Quoted 1 line
+
Quoted 1 line
+ if(val > 1 || val
< 0)
Quoted 1 line
+
return
-EINVAL;Quoted 1 line
+
Quoted 1 line
+ /* There really isn't
a way to put the chip into power saving
Quoted 1 line
+
other than by pulling CE to ground so all
we do is returnQuoted 1 line
+
out of this function
Quoted 1 line
+ */
Quoted 1 line
+ if(val == 0)
Quoted 1 line
+
return 0;
Quoted 1 line
+
Quoted 1 line
+ /* When enabling the
chip again we need to reinitialize the
Quoted 1 line
+
all the values
Quoted 1 line
+ */
Quoted 1 line
+ state->input =
-1;
Quoted 1 line
+ state->output =
SAA7115_IPORT_ON;Quoted 1 line
+ state->enable =
1;
Quoted 1 line
+ state->radio =
0;
Quoted 1 line
+ state->bright =
128;
Quoted 1 line
+ state->contrast =
64;
Quoted 1 line
+ state->hue =
0;
Quoted 1 line
+ state->sat =
64;
Quoted 1 line
+
Quoted 1 line
+ state->audclk_freq
= 48000;
Quoted 1 line
+
Quoted 1 line
+ v4l2_dbg(1, debug,
sd, "writing init values s_power\n");
Quoted 1 line
+
Quoted 1 line
+ /* init to 60hz/48khz
*/
Quoted 1 line
+
state->crystal_freq =
SAA7115_FREQ_24_576_MHZ;Quoted 1 line
+ switch
(
state->ident) {Quoted 1 line
+ case
V4L2_IDENT_SAA7111:Quoted 1 line
+
saa711x_writeregs(sd,
saa7111_init);Quoted 1 line
+
break;
Quoted 1 line
+ case
V4L2_IDENT_SAA7113:Quoted 1 line
+
saa711x_writeregs(sd,
saa7113_init);Quoted 1 line
+
break;
Quoted 2 lines
+ default:
+state->crystal_freq =
SAA7115_FREQ_32_11_MHZ;Quoted 1 line
+
saa711x_writeregs(sd,
saa7115_init_auto_input);Quoted 2 lines
+ }
+ if (state->ident!=
V4L2_IDENT_SAA7111)Quoted 1 line
+
saa711x_writeregs(sd,
saa7115_init_misc);Quoted 1 line
+
saa711x_set_v4lstd(sd,
V4L2_STD_NTSC);Quoted 2 lines
+
+ v4l2_dbg(1, debug,sd, "status: (1E) 0x%02x, (1F) 0x%02x\n",
Quoted 1 line
+
saa711x_read(sd,
R_1E_STATUS_BYTE_1_VD_DEC),Quoted 1 line
+
saa711x_read(sd,
R_1F_STATUS_BYTE_2_VD_DEC));Quoted 4 lines
+ return 0;
(quoted diff) +2
-0+} +static int saa711x_reset(struct
v4l2_subdev*sd,u32 val)
Quoted 2 lines
{
v4l2_dbg(1,debug, sd, "decoder RESET\n");
Quoted 2 lines
(quoted diff) +0
-0@@ -1513,6 +1566,7 @@.s_std =
saa711x_s_std,Quoted 1 line
.reset =
saa711x_reset,Quoted 1 line
.s_gpio =
saa711x_s_gpio,Quoted 1 line
+ .s_power =
saa711x_s_power,Quoted 2 lines
#ifdef
CONFIG_VIDEO_ADV_DEBUG
.g_register =
saa711x_g_register,Quoted 1 line
.s_register =
saa711x_s_register,Quoted 6 lines
Thanks,
Franklin Meng--- On Thu, 1/7/10, Franklin Meng <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines
From: Franklin Meng <[email protected]>
Subject: Kworld 315U and SAA7113?
To: [email protected]
Date: Thursday, January 7, 2010, 7:48 PM After some work I have finally gotten
the analog inputs to work with the Kworld 315Udevice. I
Quoted 1 line
Quoted 1 line
have attached the changes/updates to the em28xx
driver.
Quoted 1 line
Quoted 1 line
Note: I still don't have analog sound working
yet..
Quoted 3 lines
Quoted 3 lines
I am hoping someone can comment on the changes in saa7115.c. I added a
s_powerroutine toreinitialize the
Quoted 1 line
Quoted 1 line
device. The reason I am reinitializing this
device is
Quoted 3 lines
Quoted 3 lines
because
1. I cannot keep both the LG demod and the SAA
powered on
Quoted 3 lines
Quoted 3 lines
at the same time for my device
2. The SAA datasheet seems to suggest that after
a
Quoted 1 line
Quoted 1 line
reset/power-on the chip needs to be
reinitialized.
Quoted 2 lines
Quoted 2 lines
3. Reinitializing causes the analog inputs to
work
Quoted 10 lines
Quoted 10 lines
correctly.
Here's what is says in the SAA7113 datasheet..
....
Status after power-on
control sequenceVPO7 to VPO0, RTCO, RTS0 and RTS1
are held in high-impedance stateQuoted 6 lines
Quoted 6 lines
after power-on (reset
sequence) a complete
I2C-bus transmission is
required
...
The above is really suppose to be arrangedhorizontally in
Quoted 1 line
Quoted 1 line
3 columns. Anyways, the last part describes
that "a
Quoted 1 line
Quoted 1 line
complete I2C bus transmission is required"
This is why
Quoted 5 lines
Quoted 5 lines
I think the chip needs to be reinitialized.
Last thing is that the initialization routing uses
these
Quoted 3 lines
Quoted 3 lines
defaults:
state->bright=128;
Quoted 1 line
Quoted 1 line
state->contrast=64;
Quoted 4 lines
Quoted 4 lines
state->hue= 0;
state->sat= 64;I was wondering if we should just read the back
the values
Quoted 1 line
Quoted 1 line
that were initialized by the initialization
routine and use
Quoted 1 line
Quoted 1 line
those values instead.The reason is because it
seems like the
Quoted 1 line
Quoted 1 line
different SAA's use slightly different values
when
Quoted 11 lines
Quoted 7 lines
initializing.
Thanks,
Franklin Meng--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Franklin Meng
I tweaked the GPIO's a bit more for the Kworld 315U and switching between analog and digital signals is more reliable now. Attached is an updated diff.
Hello Franklin,
This is pretty good stuff. A few questions/comments about your patch:
The code has different GPIO configurations for the two analog modes. This is a bit unusual for an em28xx design. Do you know what the difference is in terms of what GPIO7 controls?
The digital GPIO block strobes GPO3 to reset the lgdt3303. While I generally believe that it's good to explicitly strobe the reset low, this could cause problems with em28xx devices. This is because the em28xx calls the digital GPIO whenever starting streaming. Hence, you could end up with the chip being reset without the demod driver's init() routine being called, resulting in the chip's register state not being in sync with the driver's state info. In fact, we have this issue with one of the Terratec boards where the zl10353 driver state gets out of sync with the hardware (I still need to submit a patch upstream for that case). Your code at this point should probably only ensure the 3303 is not in reset (by setting the GPIO pin high).
It's not surprising that you would uncover an issue with the suspend logic. Despite the fact that the em28xx driver provides a suspend method it is not actually used today in any of the board profiles.
The saa7115 stuff looks pretty reasonable at first glance, although I am a bit worried about the possibility that it could cause a regression in other products that use that decoder.
Did you actually do any power analysis to confirm that the suspend functionality is working properly?
I agree with Mauro though that this should be split into multiple patches. In fact, I would seriously consider three patches instead of two - the first patch adds the basic functionality to get the board working, the second adds the saa7115 code, and the third adds the suspend GPIO changes. This will make it easier for others who have problems to isolate whether any problems are a basic issue with the board not working or whether it is related to the suspend and power management changes.
Cheers,
Devin
Signature · 2 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com
Devin,
Quoted 9 lines
This is pretty good stuff. A few questions/comments about your patch:
The code has different GPIO configurations for the two analog modes.
This is a bit unusual for an em28xx design. Do you know what the
difference is in terms of what GPIO7 controls?
Unfortunately, I do not know the difference. I thought it might be to do something to the tuner but I am not quite sure. If I remember correctly, the traces that I obtained also showed a difference between the analog modes. I do know that if I leave the bit on it does not cause any adverse affects (other than maybe more power is being drawn)..
Quoted 15 lines
The digital GPIO block strobes GPO3 to reset the lgdt3303. While I
generally believe that it's good to explicitly strobe the reset low,
this could cause problems with em28xx devices. This is because the
em28xx calls the digital GPIO whenever starting streaming. Hence, you
could end up with the chip being reset without the demod driver'sinit()routine being called, resulting in the chip's register state
not being in sync with the driver's state info. In fact, we have this
Quoted 9 lines
issue with one of the Terratec boards where the zl10353 driver state
gets out of sync with the hardware (I still need to submit a patch
upstream for that case). Your code at this point should probably only
ensure the 3303 is not in reset (by setting the GPIO pin high).
I might try leaving the GPIO pin high.. I had lots of issues switching between analog and digital modes so changing this bit may cause one or the other to not work. For example if I leave both pins for the SAA/EM202 and the demod high, the analog doesn't seem to work correctly. I'm guessing that there probably isn't enough power to keep both devices operational. I'll try it out some more to see what happens.
Quoted 6 lines
It's not surprising that you would uncover an issue with the suspend
logic. Despite the fact that the em28xx driver provides a suspend
method it is not actually used today in any of the board profiles.
I saw it was available so I decided to use it. I actually also implemented a suspend state for the AC97 chip (the EM202 I believe) though I wasn't fully happy with the code so I didn't include it this time around.
Quoted 6 lines
The saa7115 stuff looks pretty reasonable at first glance, although I
am a bit worried about the possibility that it could cause a
regression in other products that use that decoder.
As far as I can tell, the Kworld 315U is the only board that uses this combination of parts.. Thomson tuner, LG demod, and SAA7113. I don't think any other device has used the SAA7113 together with a digital demod. Most products seem to only have the SAA711X on an analog only board. Since I don't have any other USB adapters with the SAA chip I was unable to do any further testing on the SAA code changes.
Quoted 4 lines
Did you actually do any power analysis to confirm that the suspend
functionality is working properly?
Humm.. I did not actually do this. Though, maybe I can figure this out by seeing how much power draw is on the USB bus. I don't recall if there is a way to figure this out or not from within Linux. I do remember Windows having such a feature.. I probably need to do a comparison between both OS's to make sure I get things are correct.. Is there a way to get information on how much power draw is happening on the USB bus in Linux?
Quoted 17 lines
I agree with Mauro though that this should be split into multiple
patches. In fact, I would seriously consider three patches instead of
two - the first patch adds the basic functionality to get the board
working, the second adds the saa7115 code, and the third adds the
suspend GPIO changes. This will make it easier for others who have
problems to isolate whether any problems are a basic issue with the
board not working or whether it is related to the suspend and power
management changes.
Well basic functionality of the board is already included (digital only). Douglas helped me get those changes in earlier. I'll see if I can split up the patches better.
Last thing is that my responses may be kind of slow since I had a new addition to the family not too long ago. :)
Thanks,
Franklin
Quoted 1 line · Franklin Meng
Unfortunately, I do not know the difference. I thought it might be to do something to the tuner but I am not quite sure. If I remember correctly, the traces that I obtained also showed a difference between the analog modes. I do know that if I leave the bit on it does not cause any adverse affects (other than maybe more power is being drawn)..
If there is no difference, it might make sense to just pick one. If you could measure the power draw though, you might gain some insight regarding the difference.
Quoted 1 line
I might try leaving the GPIO pin high.. I had lots of issues switching between analog and digital modes so changing this bit may cause one or the other to not work. For example if I leave both pins for the SAA/EM202 and the demod high, the analog doesn't seem to work correctly. I'm guessing that there probably isn't enough power to keep both devices operational. I'll try it out some more to see what happens.
You would obviously need to retest. The cases where having the digital GPIO do an actual reset were exposed when performing multiple tuning attempts without closing the DVB device in between attempts.
Quoted 1 line
As far as I can tell, the Kworld 315U is the only board that uses this combination of parts.. Thomson tuner, LG demod, and SAA7113. I don't think any other device has used the SAA7113 together with a digital demod. Most products seem to only have the SAA711X on an analog only board. Since I don't have any other USB adapters with the SAA chip I was unable to do any further testing on the SAA code changes.
I'm more worried about it interfering with other devices that use some other bridge, regardless of whether that device has a demodulator. Implementing power management on any chip is likely to expose bugs in neighboring components like the bridge.
Quoted 6 lines
Quoted 4 lines
Did you actually do any power analysis to confirm that the suspend
functionality is working properly?Humm.. I did not actually do this. Though, maybe I can figure this out by seeing how much power draw is on the USB bus. I don't recall if there is a way to figure this out or not from within Linux. I do remember Windows having such a feature.. I probably need to do a comparison between both OS's to make sure I get things are correct.. Is there a way to get information on how much power draw is happening on the USB bus in Linux?
I don't trust the operating system when it comes to that sort of thing. I cut up an old USB cable and put an ammeter in-line. Has helped alot in finding all sorts of power management bugs both in drivers and in the v4l-dvb core.
Devin
Signature · 2 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com
Quoted 2 lines · Franklin Meng
As far as I can tell, the Kworld 315U is the only board that uses this combination of parts.. Thomson tuner, LG demod, and SAA7113. I don't think any other device has used the SAA7113 together with a digital demod. Most products seem to only have the SAA711X on an analog only board. Since I don't have any other USB adapters with the SAA chip I was unable to do any further testing on the SAA code changes.
IIRC, a couple of the Sasem/OnAir devices use a saa7113 together with a digital demod. I seem to also recall something else, though maybe I'm mistaken.
Quoted 7 lines · CityK
Quoted 2 lines · Franklin Meng
As far as I can tell, the Kworld 315U is the only board that uses this combination of parts.. Thomson tuner, LG demod, and SAA7113. I don't think any other device has used the SAA7113 together with a digital demod. Most products seem to only have the SAA711X on an analog only board. Since I don't have any other USB adapters with the SAA chip I was unable to do any further testing on the SAA code changes.
IIRC, a couple of the Sasem/OnAir devices use a saa7113 together with a digital demod. I seem to also recall something else, though maybe I'm mistaken.
I'm actually not really concerned about it's interaction with a demod.
I'm more worried about other products that have saa711[345] that use
a bridge other than em28xx. The introduction of power management could always expose bugs in those bridges (I had this problem in several different cases where I had to fix problems in other drivers because of the introduction of power management).
Devin
Signature · 2 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com
Actually I was a bit short sighted here. I was referring to devices in the em28xx tree.
In the case of the SAA7113 device, there really is no power saving feature unless a hardware pin is pulled down (or up I don't remember). The pin will basically reset the device.
Quoted 1 line
From my testing it seems like the power on defaults don't fully enable the device which is why I added the reinitialization to the
s_powerroutine.
Thanks,
Franklin Meng
Quoted 48 lines · Devin Heitmueller
From: Devin Heitmueller <[email protected]>
Subject: Re: Kworld 315U and SAA7113?
To: "CityK" <[email protected]>
Cc: "Franklin Meng" <[email protected]>, [email protected]
Date: Thursday, January 14, 2010, 2:09 PMQuoted 2 lines · CityK
Quoted 1 line · Franklin Meng
As far as I can tell, the Kworld 315U is the only
board that uses this combination of parts.. Thomson tuner, LG demod, and SAA7113. I don't think any other device has used the SAA7113 together with a digital demod. Most products seem to only have the SAA711X on an analog only board. Since I don't have any other USB adapters with the SAA chip I was unable to do any further testing on the SAA code changes.
Quoted 3 lines
Quoted 1 line
IIRC, a couple of the Sasem/OnAir devices use a
saa7113 together with a
Quoted 1 line
digital demod. I seem to also recall something else,
though maybe I'm
Quoted 1 line
mistaken.
I'm actually not really concerned about it's interaction with a demod.
I'm more worried about other products that have
saa711[345] that use
a bridge other than em28xx. The introduction of power management
could always expose bugs in those bridges (I had this problem in
several different cases where I had to fix problems in other drivers
because of the introduction of power management).Devin
Signature · 7 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Devin,
Quoted 6 lines
Quoted 1 line
I'm actually not really concerned about it's
interaction
Quoted 4 lines
with a demod.
I'm more worried about other products that have
saa711[345] that use
a bridge other than em28xx. The introduction of
Quoted 9 lines
power
Quoted 4 lines
management
could always expose bugs in those bridges (I had this problem in
several different cases where I had to fix problemsin
Quoted 3 lines
other drivers
because of the introduction of power management).
I retested my device and tried several different GPIO sequences but so far every time I change between the Analog and digital interface, the SAA7113 needs to be reinitialized. I tried leaving both the digital and analog interfaces enabled by setting the GPIO to 7c but then the LG demod does not initialize.
Either way it looks like I will have to reinitialize the device after switching between interfaces.
Other than that do you want me to remove the suspend GPIO? Since I don't have the equipment to measure the power, I don't know for a fact if the device really has been put in a suspend state or not.
Thanks,
Franklin Meng
Quoted 13 lines · Franklin Meng
Devin,
Quoted 11 lines
Quoted 1 line
I'm actually not really concerned about it's
interaction
Quoted 4 lines
with a demod.
I'm more worried about other products that have
saa711[345] that use
a bridge other than em28xx. The introduction ofpower
Quoted 4 lines
management
could always expose bugs in those bridges (I had this problem in
several different cases where I had to fix problems
Quoted 6 lines
Quoted 4 lines
in
Quoted 3 lines
other drivers
because of the introduction of power management).I retested my device and tried several different GPIO sequences but so far every time I change between the Analog and digital interface, the SAA7113 needs to be reinitialized.
This happens on several designs. In general, the gpio sequence will turn off either the analog or the digital part of the device, in order to save power and to avoid overheating the device.
Quoted 1 line
I tried leaving both the digital and analog interfaces enabled by setting the GPIO to 7c but then the LG demod does not initialize.
Don't do that. You may burn your device.
Quoted 1 line
Either way it looks like I will have to reinitialize the device after switching between interfaces.
The em28xx driver calls em28xx_set_mode(dev, EM28XX_ANALOG_MODE); when the device is opened in analog mode. It seems that we'll need some code there to also call the analog demod to re-initiate the device, after sending the gpio commands.
Quoted 3 lines
Other than that do you want me to remove the suspend GPIO? Since I don't have the equipment to measure the power, I don't know for a fact if the device really has been put in a suspend state or not.
In suspend state, it will be cooler than when in normal state. It is better to keep the suspend state to increase the lifetime of the device.
Quoted 10 lines
Thanks,
Franklin Meng--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Franklin Meng
I retested my device and tried several different GPIO sequences but so far every time I change between the Analog and digital interface, the SAA7113 needs to be reinitialized. I tried leaving both the digital and analog interfaces enabled by setting the GPIO to 7c but then the LG demod does not initialize.
Either way it looks like I will have to reinitialize the device after switching between interfaces.
Other than that do you want me to remove the suspend GPIO? Since I don't have the equipment to measure the power, I don't know for a fact if the device really has been put in a suspend state or not.
Hello Franklin,
Just to be clear, I'm not proposing that you remove the suspend logic.
I was suggesting that you should be breaking the change into three
separate patches, so that if a problem arises we can isolate whether it is a result of the power management changes. Having a separate patch is especially valuable because you are touching other drivers which are shared by other products.
Cheers,
Devin
Signature · 2 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com
OK.. I guess that was a misunderstanding on my part. I will split up the patch and re submit.
Thanks,
Franklin
Quoted 45 lines · Devin Heitmueller
From: Devin Heitmueller <[email protected]>
Subject: Re: Kworld 315U and SAA7113?
To: "Franklin Meng" <[email protected]>
Cc: [email protected]
Date: Sunday, January 17, 2010, 8:28 AMQuoted 1 line · Franklin Meng
I retested my device and tried several different GPIO
sequences but so far every time I change between the Analog and digital interface, the SAA7113 needs to be reinitialized. I tried leaving both the digital and analog interfaces enabled by setting the GPIO to 7c but then the LG demod does not initialize.
Quoted 2 lines
Either way it looks like I will have to reinitialize
the device after switching between interfaces.
Quoted 2 lines
Other than that do you want me to remove the suspend
GPIO? Since I don't have the equipment to measure the power, I don't know for a fact if the device really has been put in a suspend state or not.
Hello Franklin,
Just to be clear, I'm not proposing that you remove the suspend logic.
I was suggesting that you should be breaking the change
into three
separate patches, so that if a problem arises we can isolate whether
it is a result of the power management changes. Having a separate
patch is especially valuable because you are touching other drivers
which are shared by other products.Cheers,
Devin
Signature · 2 lines
Devin J. Heitmueller - Kernel Labs http://www.kernellabs.com