Re: kernel patch 2018-05-28 media: gspca_zc3xx: Implement proper autogain and exposure control for OV7648

2018-06-27 Thread Ondrej Zary
On 22/06/18 01:49, safocl wrote:
> This patch makes it impossible to configure the exposure on webcams, 
> specifically a4tech, with others was not checked. Seen from several users.
> link to the Russian forum archlinux: 
> https://archlinux.org.ru/forum/topic/18581/?page=1
> 
> was checked on webcam a4tech pk-910h idVendor = 0ac8, idProduct = 3500, 
> bcdDevice = 10.07
> 
> with the kernel before this commit, exposure adjustment is possible.
> 
> commit link: 
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=6f92c3a22ccd66604b8b528221a9d8e1b3fb4e39
> 

0ac8:3500 is an UVC camera. This patch does not affect UVC cameras in any way.

-- 
Ondrej Zary


[PATCH 3/3 v2] gspca_zc3xx: Enable short exposure times for OV7648

2018-05-25 Thread Ondrej Zary
The 50Hz and 60Hz power line frequency settings disable short (1/120s
and 1/100s) exposure times for banding filter (causing overexposed
image near lamps). No flicker setting enables them (when banding
filter is disabled and they're not used).

Seems that the logic is just the wrong way around.
(This bug came from the Windows driver.)

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index c72f2d9167d9..cf21991e3d99 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -3186,7 +3186,8 @@ static const struct usb_action ov7620_InitialScale[] = {  
/* 320x240 */
 static const struct usb_action ov7620_50HZ[] = {
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x0096},   /* 00,2b,96,aa */
-   {0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
+   /* enable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008e},
{0xaa, 0x2d, 0x0005},   /* 00,2d,05,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID},  /* 01,91,04,cc */
@@ -3202,7 +3203,8 @@ static const struct usb_action ov7620_50HZ[] = {
 static const struct usb_action ov7620_60HZ[] = {
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
-   {0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
+   /* enable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008e},
{0xaa, 0x2d, 0x0005},   /* 00,2d,05,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */
@@ -3221,7 +3223,8 @@ static const struct usb_action ov7620_60HZ[] = {
 static const struct usb_action ov7620_NoFliker[] = {
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
-   {0xaa, 0x75, 0x008e},   /* 00,75,8e,aa */
+   /* disable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008a},
{0xaa, 0x2d, 0x0001},   /* 00,2d,01,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */
-- 
Ondrej Zary



[PATCH 2/3 v2] gspca_zc3xx: Fix power line frequency settings for OV7648

2018-05-25 Thread Ondrej Zary
Power line frequency settings for OV7648 sensor contain autogain
and exposure commands, affecting unrelated controls. Remove them.

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 992918b3ad0c..c72f2d9167d9 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -3184,7 +3184,6 @@ static const struct usb_action ov7620_InitialScale[] = {  
/* 320x240 */
{}
 };
 static const struct usb_action ov7620_50HZ[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x0096},   /* 00,2b,96,aa */
{0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
@@ -3195,15 +3194,12 @@ static const struct usb_action ov7620_50HZ[] = {
{0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},   /* 01,95,00,cc */
{0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},/* 01,96,00,cc */
{0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW},/* 01,97,83,cc */
-   {0xaa, 0x10, 0x0082},   /* 00,10,82,aa */
{0xaa, 0x76, 0x0003},   /* 00,76,03,aa */
 /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT},* 00,02,40,cc
 * if mode0 (640x480) */
{}
 };
 static const struct usb_action ov7620_60HZ[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
-   /* (bug in zs211.inf) */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
{0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
@@ -3214,7 +3210,6 @@ static const struct usb_action ov7620_60HZ[] = {
{0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* 01,95,00,cc */
{0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* 01,96,00,cc */
{0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW}, /* 01,97,83,cc */
-   {0xaa, 0x10, 0x0020},   /* 00,10,20,aa */
{0xaa, 0x76, 0x0003},   /* 00,76,03,aa */
 /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT},* 00,02,40,cc
 * if mode0 (640x480) */
@@ -3224,8 +3219,6 @@ static const struct usb_action ov7620_60HZ[] = {
{}
 };
 static const struct usb_action ov7620_NoFliker[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
-   /* (bug in zs211.inf) */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
{0xaa, 0x75, 0x008e},   /* 00,75,8e,aa */
-- 
Ondrej Zary



[PATCH 1/3] gspca_zc3xx: Implement proper autogain and exposure control for OV7648

2018-05-25 Thread Ondrej Zary
The ZS0211 internal autogain causes pumping and flickering with OV7648
sensor on 0ac8:307b webcam.
Implement OV7648 autogain and exposure control and use that instead.

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 42 +
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 25b4dbe8e049..992918b3ad0c 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -5778,16 +5778,34 @@ static void setcontrast(struct gspca_dev *gspca_dev,
 
 static s32 getexposure(struct gspca_dev *gspca_dev)
 {
-   return (i2c_read(gspca_dev, 0x25) << 9)
-   | (i2c_read(gspca_dev, 0x26) << 1)
-   | (i2c_read(gspca_dev, 0x27) >> 7);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   switch (sd->sensor) {
+   case SENSOR_HV7131R:
+   return (i2c_read(gspca_dev, 0x25) << 9)
+   | (i2c_read(gspca_dev, 0x26) << 1)
+   | (i2c_read(gspca_dev, 0x27) >> 7);
+   case SENSOR_OV7620:
+   return i2c_read(gspca_dev, 0x10);
+   default:
+   return -1;
+   }
 }
 
 static void setexposure(struct gspca_dev *gspca_dev, s32 val)
 {
-   i2c_write(gspca_dev, 0x25, val >> 9, 0x00);
-   i2c_write(gspca_dev, 0x26, val >> 1, 0x00);
-   i2c_write(gspca_dev, 0x27, val << 7, 0x00);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   switch (sd->sensor) {
+   case SENSOR_HV7131R:
+   i2c_write(gspca_dev, 0x25, val >> 9, 0x00);
+   i2c_write(gspca_dev, 0x26, val >> 1, 0x00);
+   i2c_write(gspca_dev, 0x27, val << 7, 0x00);
+   break;
+   case SENSOR_OV7620:
+   i2c_write(gspca_dev, 0x10, val, 0x00);
+   break;
+   }
 }
 
 static void setquality(struct gspca_dev *gspca_dev)
@@ -5918,7 +5936,12 @@ static void setlightfreq(struct gspca_dev *gspca_dev, 
s32 val)
 
 static void setautogain(struct gspca_dev *gspca_dev, s32 val)
 {
-   reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   if (sd->sensor == SENSOR_OV7620)
+   i2c_write(gspca_dev, 0x13, val ? 0xa3 : 0x80, 0x00);
+   else
+   reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180);
 }
 
 /*
@@ -6439,6 +6462,9 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
if (sd->sensor == SENSOR_HV7131R)
sd->exposure = v4l2_ctrl_new_std(hdl, _ctrl_ops,
V4L2_CID_EXPOSURE, 0x30d, 0x493e, 1, 0x927);
+   else if (sd->sensor == SENSOR_OV7620)
+   sd->exposure = v4l2_ctrl_new_std(hdl, _ctrl_ops,
+   V4L2_CID_EXPOSURE, 0, 255, 1, 0x41);
sd->autogain = v4l2_ctrl_new_std(hdl, _ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
if (sd->sensor != SENSOR_OV7630C)
@@ -6458,7 +6484,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
return hdl->error;
}
v4l2_ctrl_cluster(3, >gamma);
-   if (sd->sensor == SENSOR_HV7131R)
+   if (sd->sensor == SENSOR_HV7131R || sd->sensor == SENSOR_OV7620)
v4l2_ctrl_auto_cluster(2, >autogain, 0, true);
return 0;
 }
-- 
Ondrej Zary



[PATCH 1/3] gspca_zc3xx: Implement proper autogain and exposure control for OV7648

2018-05-24 Thread Ondrej Zary
The ZS0211 internal autogain causes pumping and flickering with OV7648
sensor on 0ac8:307b webcam.
Implement OV7648 autogain and exposure control and use that instead.

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 42 +
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 25b4dbe8e049..992918b3ad0c 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -5778,16 +5778,34 @@ static void setcontrast(struct gspca_dev *gspca_dev,
 
 static s32 getexposure(struct gspca_dev *gspca_dev)
 {
-   return (i2c_read(gspca_dev, 0x25) << 9)
-   | (i2c_read(gspca_dev, 0x26) << 1)
-   | (i2c_read(gspca_dev, 0x27) >> 7);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   switch (sd->sensor) {
+   case SENSOR_HV7131R:
+   return (i2c_read(gspca_dev, 0x25) << 9)
+   | (i2c_read(gspca_dev, 0x26) << 1)
+   | (i2c_read(gspca_dev, 0x27) >> 7);
+   case SENSOR_OV7620:
+   return i2c_read(gspca_dev, 0x10);
+   default:
+   return -1;
+   }
 }
 
 static void setexposure(struct gspca_dev *gspca_dev, s32 val)
 {
-   i2c_write(gspca_dev, 0x25, val >> 9, 0x00);
-   i2c_write(gspca_dev, 0x26, val >> 1, 0x00);
-   i2c_write(gspca_dev, 0x27, val << 7, 0x00);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   switch (sd->sensor) {
+   case SENSOR_HV7131R:
+   i2c_write(gspca_dev, 0x25, val >> 9, 0x00);
+   i2c_write(gspca_dev, 0x26, val >> 1, 0x00);
+   i2c_write(gspca_dev, 0x27, val << 7, 0x00);
+   break;
+   case SENSOR_OV7620:
+   i2c_write(gspca_dev, 0x10, val, 0x00);
+   break;
+   }
 }
 
 static void setquality(struct gspca_dev *gspca_dev)
@@ -5918,7 +5936,12 @@ static void setlightfreq(struct gspca_dev *gspca_dev, 
s32 val)
 
 static void setautogain(struct gspca_dev *gspca_dev, s32 val)
 {
-   reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180);
+   struct sd *sd = (struct sd *) gspca_dev;
+
+   if (sd->sensor == SENSOR_OV7620)
+   i2c_write(gspca_dev, 0x13, val ? 0xa3 : 0x80, 0x00);
+   else
+   reg_w(gspca_dev, val ? 0x42 : 0x02, 0x0180);
 }
 
 /*
@@ -6439,6 +6462,9 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
if (sd->sensor == SENSOR_HV7131R)
sd->exposure = v4l2_ctrl_new_std(hdl, _ctrl_ops,
V4L2_CID_EXPOSURE, 0x30d, 0x493e, 1, 0x927);
+   else if (sd->sensor == SENSOR_OV7620)
+   sd->exposure = v4l2_ctrl_new_std(hdl, _ctrl_ops,
+   V4L2_CID_EXPOSURE, 0, 255, 1, 0x41);
sd->autogain = v4l2_ctrl_new_std(hdl, _ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
if (sd->sensor != SENSOR_OV7630C)
@@ -6458,7 +6484,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
return hdl->error;
}
v4l2_ctrl_cluster(3, >gamma);
-   if (sd->sensor == SENSOR_HV7131R)
+   if (sd->sensor == SENSOR_HV7131R || sd->sensor == SENSOR_OV7620)
v4l2_ctrl_auto_cluster(2, >autogain, 0, true);
return 0;
 }
-- 
Ondrej Zary



[PATCH 2/3] gspca_zc3xx: Fix power line frequency settings for OV7648

2018-05-24 Thread Ondrej Zary
Power line frequency settings for OV7648 sensor contain autogain
and exposure commands, affecting unrelated controls. Remove them.

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 992918b3ad0c..9a78420e8ad8 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -3184,7 +3184,8 @@ static const struct usb_action ov7620_InitialScale[] = {  
/* 320x240 */
{}
 };
 static const struct usb_action ov7620_50HZ[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
+/* {0xaa, 0x13, 0x00a3},* 00,13,a3,aa
+* don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x0096},   /* 00,2b,96,aa */
{0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
@@ -3195,15 +3196,16 @@ static const struct usb_action ov7620_50HZ[] = {
{0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},   /* 01,95,00,cc */
{0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},/* 01,96,00,cc */
{0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW},/* 01,97,83,cc */
-   {0xaa, 0x10, 0x0082},   /* 00,10,82,aa */
+/* {0xaa, 0x10, 0x0082},* 00,10,82,aa
+* don't change exposure */
{0xaa, 0x76, 0x0003},   /* 00,76,03,aa */
 /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT},* 00,02,40,cc
 * if mode0 (640x480) */
{}
 };
 static const struct usb_action ov7620_60HZ[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
-   /* (bug in zs211.inf) */
+/* {0xaa, 0x13, 0x00a3},* 00,13,a3,aa
+* don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
{0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
@@ -3214,7 +3216,8 @@ static const struct usb_action ov7620_60HZ[] = {
{0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* 01,95,00,cc */
{0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* 01,96,00,cc */
{0xa0, 0x83, ZC3XX_R197_ANTIFLICKERLOW}, /* 01,97,83,cc */
-   {0xaa, 0x10, 0x0020},   /* 00,10,20,aa */
+/* {0xaa, 0x10, 0x0020},* 00,10,20,aa
+* don't change exposure */
{0xaa, 0x76, 0x0003},   /* 00,76,03,aa */
 /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT},* 00,02,40,cc
 * if mode0 (640x480) */
@@ -3224,8 +3227,8 @@ static const struct usb_action ov7620_60HZ[] = {
{}
 };
 static const struct usb_action ov7620_NoFliker[] = {
-   {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
-   /* (bug in zs211.inf) */
+/* {0xaa, 0x13, 0x00a3},* 00,13,a3,aa
+* don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
{0xaa, 0x75, 0x008e},   /* 00,75,8e,aa */
-- 
Ondrej Zary



[PATCH 3/3] gspca_zc3xx: Fix exposure with power line frequency for OV7648

2018-05-24 Thread Ondrej Zary
The 50Hz and 60Hz power line frequency settings disable short (1/120s
and 1/100s) exposure times for banding filter, causing overexposed
image near lamps. No flicker setting enables them (when banding
filter is disabled and they're not used).

Seems that the logic is just the wrong way around. Fix it.
(This bug came from the Windows driver.)

Signed-off-by: Ondrej Zary <li...@rainbow-software.org>
---
 drivers/media/usb/gspca/zc3xx.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 9a78420e8ad8..299ea70bfb67 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -3188,7 +3188,9 @@ static const struct usb_action ov7620_50HZ[] = {
 * don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x0096},   /* 00,2b,96,aa */
-   {0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
+/* {0xaa, 0x75, 0x008a},* 00,75,8a,aa */
+   /* enable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008e},
{0xaa, 0x2d, 0x0005},   /* 00,2d,05,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID},  /* 01,91,04,cc */
@@ -3208,7 +3210,9 @@ static const struct usb_action ov7620_60HZ[] = {
 * don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
-   {0xaa, 0x75, 0x008a},   /* 00,75,8a,aa */
+/* {0xaa, 0x75, 0x008a},* 00,75,8a,aa */
+   /* enable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008e},
{0xaa, 0x2d, 0x0005},   /* 00,2d,05,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */
@@ -3231,7 +3235,9 @@ static const struct usb_action ov7620_NoFliker[] = {
 * don't change autoexposure */
{0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
{0xaa, 0x2b, 0x},   /* 00,2b,00,aa */
-   {0xaa, 0x75, 0x008e},   /* 00,75,8e,aa */
+/* {0xaa, 0x75, 0x008e},* 00,75,8e,aa */
+   /* disable 1/120s & 1/100s exposures for banding filter */
+   {0xaa, 0x75, 0x008a},
{0xaa, 0x2d, 0x0001},   /* 00,2d,01,aa */
{0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
{0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,04,cc */
-- 
Ondrej Zary



[PATCH 3/3 v2] bttv: Improve TEA575x support

2015-01-16 Thread Ondrej Zary
Improve g_tuner and add s_hw_freq_seek and enum_freq_bands support for cards
with TEA575x radio.

This allows signal/stereo detection and HW seek to work on these cards.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/bttv-driver.c |   31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index e7f8ade..4ec2a3c 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2515,6 +2515,8 @@ static int bttv_querycap(struct file *file, void  *priv,
if (btv-has_saa6588)
cap-device_caps |= V4L2_CAP_READWRITE |
V4L2_CAP_RDS_CAPTURE;
+   if (btv-has_tea575x)
+   cap-device_caps |= V4L2_CAP_HW_FREQ_SEEK;
}
return 0;
 }
@@ -3244,6 +3246,9 @@ static int radio_g_tuner(struct file *file, void *priv, 
struct v4l2_tuner *t)
if (btv-audio_mode_gpio)
btv-audio_mode_gpio(btv, t, 0);
 
+   if (btv-has_tea575x)
+   return snd_tea575x_g_tuner(btv-tea, t);
+
return 0;
 }
 
@@ -3261,6 +3266,30 @@ static int radio_s_tuner(struct file *file, void *priv,
return 0;
 }
 
+static int radio_s_hw_freq_seek(struct file *file, void *priv,
+   const struct v4l2_hw_freq_seek *a)
+{
+   struct bttv_fh *fh = priv;
+   struct bttv *btv = fh-btv;
+
+   if (btv-has_tea575x)
+   return snd_tea575x_s_hw_freq_seek(file, btv-tea, a);
+
+   return -ENOTTY;
+}
+
+static int radio_enum_freq_bands(struct file *file, void *priv,
+struct v4l2_frequency_band *band)
+{
+   struct bttv_fh *fh = priv;
+   struct bttv *btv = fh-btv;
+
+   if (btv-has_tea575x)
+   return snd_tea575x_enum_freq_bands(btv-tea, band);
+
+   return -ENOTTY;
+}
+
 static ssize_t radio_read(struct file *file, char __user *data,
 size_t count, loff_t *ppos)
 {
@@ -3318,6 +3347,8 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_s_tuner = radio_s_tuner,
.vidioc_g_frequency = bttv_g_frequency,
.vidioc_s_frequency = bttv_s_frequency,
+   .vidioc_s_hw_freq_seek  = radio_s_hw_freq_seek,
+   .vidioc_enum_freq_bands = radio_enum_freq_bands,
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] bttv: Improve TEA575x support

2015-01-15 Thread Ondrej Zary
Improve g_tuner and add s_hw_freq_seek and enum_freq_bands support for cards
with TEA575x radio.

This allows signal/stereo detection and HW seek to work on these cards.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/bttv-driver.c |   31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index e7f8ade..5476a7d 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2515,6 +2515,8 @@ static int bttv_querycap(struct file *file, void  *priv,
if (btv-has_saa6588)
cap-device_caps |= V4L2_CAP_READWRITE |
V4L2_CAP_RDS_CAPTURE;
+   if (btv-has_tea575x)
+   cap-device_caps |= V4L2_CAP_HW_FREQ_SEEK;
}
return 0;
 }
@@ -3244,6 +3246,9 @@ static int radio_g_tuner(struct file *file, void *priv, 
struct v4l2_tuner *t)
if (btv-audio_mode_gpio)
btv-audio_mode_gpio(btv, t, 0);
 
+   if (btv-has_tea575x)
+   return snd_tea575x_g_tuner(btv-tea, t);
+
return 0;
 }
 
@@ -3261,6 +3266,30 @@ static int radio_s_tuner(struct file *file, void *priv,
return 0;
 }
 
+static int radio_s_hw_freq_seek(struct file *file, void *priv,
+   const struct v4l2_hw_freq_seek *a)
+{
+   struct bttv_fh *fh = priv;
+   struct bttv *btv = fh-btv;
+
+   if (btv-has_tea575x)
+   return snd_tea575x_s_hw_freq_seek(file, btv-tea, a);
+   else
+   return -ENOTTY;
+}
+
+static int radio_enum_freq_bands(struct file *file, void *priv,
+struct v4l2_frequency_band *band)
+{
+   struct bttv_fh *fh = priv;
+   struct bttv *btv = fh-btv;
+
+   if (btv-has_tea575x)
+   return snd_tea575x_enum_freq_bands(btv-tea, band);
+   else
+   return -ENOTTY;
+}
+
 static ssize_t radio_read(struct file *file, char __user *data,
 size_t count, loff_t *ppos)
 {
@@ -3318,6 +3347,8 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_s_tuner = radio_s_tuner,
.vidioc_g_frequency = bttv_g_frequency,
.vidioc_s_frequency = bttv_s_frequency,
+   .vidioc_s_hw_freq_seek  = radio_s_hw_freq_seek,
+   .vidioc_enum_freq_bands = radio_enum_freq_bands,
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] bttv: Convert to generic TEA575x interface

2015-01-15 Thread Ondrej Zary
Remove tea575x-specific code from bttv and use the common driver instead.

Only set_frequency is implemented (signal/stereo detection or seek would
require more changes to bttv).

It works fine on Video Highway Xtreme (it actually makes the radio usable as
it currently cannot be tuned properly).

Miro/Pinnacle is untested but seems to be simple and should work.

However, I don't understand the Terratec Active Radio Upgrade code. The HW
seems to need IOR, IOW and CSEL signals that were taken from ISA bus on
older cards (IOR and IOW directly and CSEL from some address decoder) and
are emulated here using GPIOs. But the code manipulating these signals in
bttv seems to be broken - it never asserts the IOR signal. If anyone has
this HW, please test if I got that right.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/Kconfig   |3 +
 drivers/media/pci/bt8xx/bttv-cards.c  |  317 -
 drivers/media/pci/bt8xx/bttv-driver.c |6 +-
 drivers/media/pci/bt8xx/bttvp.h   |   14 +-
 4 files changed, 125 insertions(+), 215 deletions(-)

diff --git a/drivers/media/pci/bt8xx/Kconfig b/drivers/media/pci/bt8xx/Kconfig
index 496cf6b..4a93f6d 100644
--- a/drivers/media/pci/bt8xx/Kconfig
+++ b/drivers/media/pci/bt8xx/Kconfig
@@ -4,12 +4,15 @@ config VIDEO_BT848
select I2C_ALGOBIT
select VIDEOBUF_DMA_SG
depends on RC_CORE
+   depends on MEDIA_RADIO_SUPPORT
select VIDEO_TUNER
select VIDEO_TVEEPROM
select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TVAUDIO if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TDA7432 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_SAA6588 if MEDIA_SUBDRV_AUTOSELECT
+   select RADIO_ADAPTERS
+   select RADIO_TEA575X
---help---
  Support for BT848 based frame grabber/overlay boards. This includes
  the Miro, Hauppauge and STB boards. Please read the material in
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index c518677..4654fb6 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -84,8 +84,7 @@ static void gv800s_init(struct bttv *btv);
 static void td3116_muxsel(struct bttv *btv, unsigned int input);
 
 static int terratec_active_radio_upgrade(struct bttv *btv);
-static int tea5757_read(struct bttv *btv);
-static int tea5757_write(struct bttv *btv, int value);
+static int tea575x_init(struct bttv *btv);
 static void identify_by_eeprom(struct bttv *btv,
   unsigned char eeprom_data[256]);
 static int pvr_boot(struct bttv *btv);
@@ -3085,12 +3084,12 @@ static void miro_pinnacle_gpio(struct bttv *btv)
if (0 == (gpio  0x20)) {
btv-has_radio = 1;
if (!miro_fmtuner[id]) {
-   btv-has_matchbox = 1;
-   btv-mbox_we= (16);
-   btv-mbox_most  = (17);
-   btv-mbox_clk   = (18);
-   btv-mbox_data  = (19);
-   btv-mbox_mask  = (16)|(17)|(18)|(19);
+   btv-has_tea575x = 1;
+   btv-tea_gpio.wren = 6;
+   btv-tea_gpio.most = 7;
+   btv-tea_gpio.clk  = 8;
+   btv-tea_gpio.data = 9;
+   tea575x_init(btv);
}
} else {
btv-has_radio = 0;
@@ -3104,7 +3103,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
pr_info(%d: miro: id=%d tuner=%d radio=%s stereo=%s\n,
btv-c.nr, id+1, btv-tuner_type,
!btv-has_radio ? no :
-   (btv-has_matchbox ? matchbox : fmtuner),
+   (btv-has_tea575x ? tea575x : fmtuner),
(-1 == msp) ? no : yes);
} else {
/* new cards with microtune tuner */
@@ -3382,12 +3381,12 @@ void bttv_init_card2(struct bttv *btv)
break;
case BTTV_BOARD_VHX:
btv-has_radio= 1;
-   btv-has_matchbox = 1;
-   btv-mbox_we  = 0x20;
-   btv-mbox_most= 0;
-   btv-mbox_clk = 0x08;
-   btv-mbox_data= 0x10;
-   btv-mbox_mask= 0x38;
+   btv-has_tea575x  = 1;
+   btv-tea_gpio.wren = 5;
+   btv-tea_gpio.most = 6;
+   btv-tea_gpio.clk  = 3;
+   btv-tea_gpio.data = 4;
+   tea575x_init(btv);
break;
case BTTV_BOARD_VOBIS_BOOSTAR:
case BTTV_BOARD_TERRATV:
@@ -3745,33 +3744,112 @@ static void hauppauge_eeprom(struct bttv *btv)
btv-radio_uses_msp_demodulator = 1;
 }
 
-static int

[PATCH 2/3] tea575x: split and export functions

2015-01-15 Thread Ondrej Zary
Split ioctl interface from enum_freq_bands, g_tuner and s_hw_freq_seek
functions and export them to be used in other drivers like bttv.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/tea575x.c |   41 -
 include/media/tea575x.h   |5 +
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
index f1a0867..43d1ea5 100644
--- a/drivers/media/radio/tea575x.c
+++ b/drivers/media/radio/tea575x.c
@@ -247,10 +247,9 @@ static int vidioc_querycap(struct file *file, void  *priv,
return 0;
 }
 
-static int vidioc_enum_freq_bands(struct file *file, void *priv,
-struct v4l2_frequency_band *band)
+int snd_tea575x_enum_freq_bands(struct snd_tea575x *tea,
+   struct v4l2_frequency_band *band)
 {
-   struct snd_tea575x *tea = video_drvdata(file);
int index;
 
if (band-tuner != 0)
@@ -279,18 +278,25 @@ static int vidioc_enum_freq_bands(struct file *file, void 
*priv,
 
return 0;
 }
+EXPORT_SYMBOL(snd_tea575x_enum_freq_bands);
 
-static int vidioc_g_tuner(struct file *file, void *priv,
-   struct v4l2_tuner *v)
+static int vidioc_enum_freq_bands(struct file *file, void *priv,
+struct v4l2_frequency_band *band)
 {
struct snd_tea575x *tea = video_drvdata(file);
+
+   return snd_tea575x_enum_freq_bands(tea, band);
+}
+
+int snd_tea575x_g_tuner(struct snd_tea575x *tea, struct v4l2_tuner *v)
+{
struct v4l2_frequency_band band_fm = { 0, };
 
if (v-index  0)
return -EINVAL;
 
snd_tea575x_read(tea);
-   vidioc_enum_freq_bands(file, priv, band_fm);
+   snd_tea575x_enum_freq_bands(tea, band_fm);
 
memset(v, 0, sizeof(*v));
strlcpy(v-name, tea-has_am ? FM/AM : FM, sizeof(v-name));
@@ -304,6 +310,15 @@ static int vidioc_g_tuner(struct file *file, void *priv,
v-signal = tea-tuned ? 0x : 0;
return 0;
 }
+EXPORT_SYMBOL(snd_tea575x_g_tuner);
+
+static int vidioc_g_tuner(struct file *file, void *priv,
+   struct v4l2_tuner *v)
+{
+   struct snd_tea575x *tea = video_drvdata(file);
+
+   return snd_tea575x_g_tuner(tea, v);
+}
 
 static int vidioc_s_tuner(struct file *file, void *priv,
const struct v4l2_tuner *v)
@@ -356,10 +371,9 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
return 0;
 }
 
-static int vidioc_s_hw_freq_seek(struct file *file, void *fh,
-   const struct v4l2_hw_freq_seek *a)
+int snd_tea575x_s_hw_freq_seek(struct file *file, struct snd_tea575x *tea,
+   const struct v4l2_hw_freq_seek *a)
 {
-   struct snd_tea575x *tea = video_drvdata(file);
unsigned long timeout;
int i, spacing;
 
@@ -442,6 +456,15 @@ static int vidioc_s_hw_freq_seek(struct file *file, void 
*fh,
snd_tea575x_set_freq(tea);
return -ENODATA;
 }
+EXPORT_SYMBOL(snd_tea575x_s_hw_freq_seek);
+
+static int vidioc_s_hw_freq_seek(struct file *file, void *fh,
+   const struct v4l2_hw_freq_seek *a)
+{
+   struct snd_tea575x *tea = video_drvdata(file);
+
+   return snd_tea575x_s_hw_freq_seek(file, tea, a);
+}
 
 static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl)
 {
diff --git a/include/media/tea575x.h b/include/media/tea575x.h
index 2d4fa59..5d09657 100644
--- a/include/media/tea575x.h
+++ b/include/media/tea575x.h
@@ -71,6 +71,11 @@ struct snd_tea575x {
int (*ext_init)(struct snd_tea575x *tea);
 };
 
+int snd_tea575x_enum_freq_bands(struct snd_tea575x *tea,
+   struct v4l2_frequency_band *band);
+int snd_tea575x_g_tuner(struct snd_tea575x *tea, struct v4l2_tuner *v);
+int snd_tea575x_s_hw_freq_seek(struct file *file, struct snd_tea575x *tea,
+   const struct v4l2_hw_freq_seek *a);
 int snd_tea575x_hw_init(struct snd_tea575x *tea);
 int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner);
 void snd_tea575x_exit(struct snd_tea575x *tea);
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] bttv: Convert to generic TEA575x interface

2015-01-13 Thread Ondrej Zary
Remove tea575x-specific code from bttv and use the common driver instead.

Only set_frequency is implemented (signal/stereo detection or seek would
require more changes to bttv).

It works fine on Video Highway Xtreme (it actually makes the radio usable as
it currently cannot be tuned properly).

Miro/Pinnacle is untested but seems to be simple and should work.

However, I don't understand the Terratec Active Radio Upgrade code. The HW
seems to need IOR, IOW and CSEL signals that were taken from ISA bus on
older cards (IOR and IOW directly and CSEL from some address decoder) and
are emulated here using GPIOs. But the code manipulating these signals in
bttv seems to be broken - it never asserts the IOR signal. If anyone has
this HW, please test if I got that right.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/Kconfig   |3 +
 drivers/media/pci/bt8xx/bttv-cards.c  |  317 -
 drivers/media/pci/bt8xx/bttv-driver.c |6 +-
 drivers/media/pci/bt8xx/bttvp.h   |   14 +-
 4 files changed, 125 insertions(+), 215 deletions(-)

diff --git a/drivers/media/pci/bt8xx/Kconfig b/drivers/media/pci/bt8xx/Kconfig
index 496cf6b..4a93f6d 100644
--- a/drivers/media/pci/bt8xx/Kconfig
+++ b/drivers/media/pci/bt8xx/Kconfig
@@ -4,12 +4,15 @@ config VIDEO_BT848
select I2C_ALGOBIT
select VIDEOBUF_DMA_SG
depends on RC_CORE
+   depends on MEDIA_RADIO_SUPPORT
select VIDEO_TUNER
select VIDEO_TVEEPROM
select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TVAUDIO if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TDA7432 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_SAA6588 if MEDIA_SUBDRV_AUTOSELECT
+   select RADIO_ADAPTERS
+   select RADIO_TEA575X
---help---
  Support for BT848 based frame grabber/overlay boards. This includes
  the Miro, Hauppauge and STB boards. Please read the material in
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index c518677..4654fb6 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -84,8 +84,7 @@ static void gv800s_init(struct bttv *btv);
 static void td3116_muxsel(struct bttv *btv, unsigned int input);
 
 static int terratec_active_radio_upgrade(struct bttv *btv);
-static int tea5757_read(struct bttv *btv);
-static int tea5757_write(struct bttv *btv, int value);
+static int tea575x_init(struct bttv *btv);
 static void identify_by_eeprom(struct bttv *btv,
   unsigned char eeprom_data[256]);
 static int pvr_boot(struct bttv *btv);
@@ -3085,12 +3084,12 @@ static void miro_pinnacle_gpio(struct bttv *btv)
if (0 == (gpio  0x20)) {
btv-has_radio = 1;
if (!miro_fmtuner[id]) {
-   btv-has_matchbox = 1;
-   btv-mbox_we= (16);
-   btv-mbox_most  = (17);
-   btv-mbox_clk   = (18);
-   btv-mbox_data  = (19);
-   btv-mbox_mask  = (16)|(17)|(18)|(19);
+   btv-has_tea575x = 1;
+   btv-tea_gpio.wren = 6;
+   btv-tea_gpio.most = 7;
+   btv-tea_gpio.clk  = 8;
+   btv-tea_gpio.data = 9;
+   tea575x_init(btv);
}
} else {
btv-has_radio = 0;
@@ -3104,7 +3103,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
pr_info(%d: miro: id=%d tuner=%d radio=%s stereo=%s\n,
btv-c.nr, id+1, btv-tuner_type,
!btv-has_radio ? no :
-   (btv-has_matchbox ? matchbox : fmtuner),
+   (btv-has_tea575x ? tea575x : fmtuner),
(-1 == msp) ? no : yes);
} else {
/* new cards with microtune tuner */
@@ -3382,12 +3381,12 @@ void bttv_init_card2(struct bttv *btv)
break;
case BTTV_BOARD_VHX:
btv-has_radio= 1;
-   btv-has_matchbox = 1;
-   btv-mbox_we  = 0x20;
-   btv-mbox_most= 0;
-   btv-mbox_clk = 0x08;
-   btv-mbox_data= 0x10;
-   btv-mbox_mask= 0x38;
+   btv-has_tea575x  = 1;
+   btv-tea_gpio.wren = 5;
+   btv-tea_gpio.most = 6;
+   btv-tea_gpio.clk  = 3;
+   btv-tea_gpio.data = 4;
+   tea575x_init(btv);
break;
case BTTV_BOARD_VOBIS_BOOSTAR:
case BTTV_BOARD_TERRATV:
@@ -3745,33 +3744,112 @@ static void hauppauge_eeprom(struct bttv *btv)
btv-radio_uses_msp_demodulator = 1;
 }
 
-static int

Re: Video resolution limited to 32x32 pixels in Skype with Syntek 1135 webcam

2015-01-02 Thread Ondrej Zary
On Friday 02 January 2015 11:07:09 Tibor MiĊĦuth wrote:
 Hello,

 I've installed Ubuntu 14.04 (kernel 3.13.0-43-generic) on an old Asus
 F5R laptop recently. It's equipped with an integrated Syntek 1135
 webcam for which the gspca_stk1135 module is loaded.

 lsusb:
 Bus 001 Device 005: ID 174f:6a31 Syntek Web Cam - Asus A8J, F3S, F5R, VX2S,
 V1S

 lsmod (extract):
 gspca_stk1135  13318  0
 gspca_main 27814  1 gspca_stk1135
 videodev  108503  2 gspca_stk1135,gspca_main

 The webcam works fine in guvcview and almost fine in cheese
 (resolutions are limited to square options, e.g. 1024x1024).

 Unfortunately there is an issue with Skype. It can detect the device
 /dev/video0 (once
 LD_PRELOAD=/usr/lib/i386-linux-gnu/libv4l/v4l2convert.so) but the
 resolution is limited to 32x32 pixels which is useless. I tried to set
 video size in Skype's config.xml, but then Skype didn't show anything
 (just black screen).

 I did a test with an external Genius USB webcam (gspca_sonixb module)
 that worked fine (resolution was 640x480 that is max for the camera).

 Is there any way to debug the driver (gspca_stk1135) and v4l to find
 out the root cause of the issue?

The driver supports variable resolution from 32x32 to 1280x1024 in 2 pixel 
steps. The problem is that some programs are crap and cannot handle that.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


CMYG support in V4L2

2014-12-29 Thread Ondrej Zary
Hello,
I'm working on an old driver called qcamvc for Connectix QuickCam VC webcams 
(parallel port and USB models), found here:
http://sourceforge.net/projects/usb-quickcam-vc/

Luckily, it was modified last year to compile with 3.x kernels.

After trivial modification (mfr and model), it works with parallel-port 
QuickCam Pro (sort of - only at 320x240 and with vertical lines on the left 
and blank part at the top). I don't have QuickCam VC (yet).

After removing a lot of code (it's now around 1200 [main] + 660 [parallel] + 
320 [usb] lines), one problem still remains: in-kernel colour conversion with 
software contrast, hue, saturation and gamma.

According to comments in the code, the camera sensor seems to have a CMYG 
filter, like no other linux-supported camera. So the proper way to support 
these cameras is to introduce a new pixel format, move the conversion to 
libv4lconvert and remove all controls not provided by hardware?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Deprecate drivers

2014-12-21 Thread Ondrej Zary
On Friday 12 December 2014 15:32:35 Hans Verkuil wrote:
 On 12/12/2014 03:29 PM, Ondrej Zary wrote:
  On Wednesday 10 December 2014, Hans Verkuil wrote:
  On 12/02/14 23:42, Ondrej Zary wrote:
  On Tuesday 02 December 2014 16:40:30 Hans Verkuil wrote:
  This patch series deprecates the vino/saa7191 video driver (ancient
  SGI Indy computer), the parallel port webcams bw-qcam, c-qcam and
  w9966, the ISA video capture driver pms and the USB video capture
  tlg2300 driver.
 
  Hardware for these devices is next to impossible to obtain, these
  drivers haven't seen any development in ages, they often use
  deprecated APIs and without hardware that's very difficult to port.
  And cheap alternative products are easily available today.
 
  Just bought a QuickCam Pro parallel and some unknown parallel port
  webcam. Will you accept patches? :)
 
  OK, so there is some confusion here. You aren't offering to work on any
  of the deprecated drivers, are you?
 
  I'm sure you meant this email as a joke, but before the drivers are
  deprecated it is good to get that confirmed.
 
  (Sorry for the delay, I somehow missed this e-mail.)
 
  I'll try to fix c-qcam driver (I suppose that it should work with
  QuickCam Pro). The webcams are still on the way so I don't know what's
  inside the unknown one.

 I'm pretty sure the QuickCam Pro won't work with the c-qcam driver, but
 I'll postpone moving these drivers to staging for the moment.

The cameras arrived and you were right: QuickCam Pro really does not work with 
c-qcam driver. The protocol is probably completely different. The camera 
supports PnP (Windows detects it and it's visible in Device Manager).
According to some web pages, the protocol should be similar to QuickCam VC 
(available with parallel or USB port). There is a qcamvc out-of-tree driver 
for that (even updated last year) but support for QuickCam Pro is missing. 
Maybe it wouldn't be hard to add it.

The other camera is marked Rookey Z and is probably the same as Todai 
TDC-01. It works in Windows 98 with wcah204e.exe software (probably 16-bit). 
There's no PnP support (Windows does not detect any device). Almost all chips 
inside are made by NEC, the biggest one is marked CAME3. This one probably 
never worked with Linux.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Deprecate drivers

2014-12-12 Thread Ondrej Zary
On Wednesday 10 December 2014, Hans Verkuil wrote:
 On 12/02/14 23:42, Ondrej Zary wrote:
  On Tuesday 02 December 2014 16:40:30 Hans Verkuil wrote:
  This patch series deprecates the vino/saa7191 video driver (ancient SGI
  Indy computer), the parallel port webcams bw-qcam, c-qcam and w9966, the
  ISA video capture driver pms and the USB video capture tlg2300 driver.
 
  Hardware for these devices is next to impossible to obtain, these
  drivers haven't seen any development in ages, they often use deprecated
  APIs and without hardware that's very difficult to port. And cheap
  alternative products are easily available today.
 
  Just bought a QuickCam Pro parallel and some unknown parallel port
  webcam. Will you accept patches? :)

 OK, so there is some confusion here. You aren't offering to work on any of
 the deprecated drivers, are you?

 I'm sure you meant this email as a joke, but before the drivers are
 deprecated it is good to get that confirmed.

(Sorry for the delay, I somehow missed this e-mail.)

I'll try to fix c-qcam driver (I suppose that it should work with QuickCam 
Pro). The webcams are still on the way so I don't know what's inside the 
unknown one.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Deprecate drivers

2014-12-02 Thread Ondrej Zary
On Tuesday 02 December 2014 16:40:30 Hans Verkuil wrote:
 This patch series deprecates the vino/saa7191 video driver (ancient SGI
 Indy computer), the parallel port webcams bw-qcam, c-qcam and w9966, the
 ISA video capture driver pms and the USB video capture tlg2300 driver.

 Hardware for these devices is next to impossible to obtain, these drivers
 haven't seen any development in ages, they often use deprecated APIs and
 without hardware that's very difficult to port. And cheap alternative
 products are easily available today.

Just bought a QuickCam Pro parallel and some unknown parallel port webcam.
Will you accept patches? :)

 So move these drivers to staging for 3.19 and plan on removing them in
 3.20.

 Regards,

   Hans

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] bttv: Convert to generic TEA575x interface

2013-11-22 Thread Ondrej Zary
Remove tea575x-specific code from bttv and use the common driver instead.
Only set_frequency is implemented (signal/stereo detection or seek would
require more changes to bttv).

Tested on Video Highway Xtreme.
I don't have the Miro/Pinnacle or Terratec Active Radio Upgrade to test.

Miro/Pinnacle seems to be simple and should work.

However, I don't understand the Terratec Active Radio Upgrade code. The HW
seems to need IOR, IOW and CSEL signals that were taken from ISA bus on
older cards (IOR and IOW directly and CSEL from some address decoder) and
are emulated here using GPIOs. But the code manipulating these signals in
bttv seems to be broken - it never asserts the IOR signal. If anyone has
this HW, please test if I got that right.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/Kconfig   |1 +
 drivers/media/pci/bt8xx/bttv-cards.c  |  317 -
 drivers/media/pci/bt8xx/bttv-driver.c |6 +-
 drivers/media/pci/bt8xx/bttvp.h   |   14 +-
 drivers/media/radio/Kconfig   |4 +-
 5 files changed, 125 insertions(+), 217 deletions(-)

diff --git a/drivers/media/pci/bt8xx/Kconfig b/drivers/media/pci/bt8xx/Kconfig
index 61d09e0..4936dcb1 100644
--- a/drivers/media/pci/bt8xx/Kconfig
+++ b/drivers/media/pci/bt8xx/Kconfig
@@ -11,6 +11,7 @@ config VIDEO_BT848
select VIDEO_TVAUDIO if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TDA7432 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_SAA6588 if MEDIA_SUBDRV_AUTOSELECT
+   select RADIO_TEA575X
---help---
  Support for BT848 based frame grabber/overlay boards. This includes
  the Miro, Hauppauge and STB boards. Please read the material in
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index d85cb0a..4a444e8 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -83,8 +83,7 @@ static void gv800s_init(struct bttv *btv);
 static void td3116_muxsel(struct bttv *btv, unsigned int input);
 
 static int terratec_active_radio_upgrade(struct bttv *btv);
-static int tea5757_read(struct bttv *btv);
-static int tea5757_write(struct bttv *btv, int value);
+static int tea575x_init(struct bttv *btv);
 static void identify_by_eeprom(struct bttv *btv,
   unsigned char eeprom_data[256]);
 static int pvr_boot(struct bttv *btv);
@@ -3053,12 +3052,12 @@ static void miro_pinnacle_gpio(struct bttv *btv)
if (0 == (gpio  0x20)) {
btv-has_radio = 1;
if (!miro_fmtuner[id]) {
-   btv-has_matchbox = 1;
-   btv-mbox_we= (16);
-   btv-mbox_most  = (17);
-   btv-mbox_clk   = (18);
-   btv-mbox_data  = (19);
-   btv-mbox_mask  = (16)|(17)|(18)|(19);
+   btv-has_tea575x = 1;
+   btv-tea_gpio.wren = 6;
+   btv-tea_gpio.most = 7;
+   btv-tea_gpio.clk  = 8;
+   btv-tea_gpio.data = 9;
+   tea575x_init(btv);
}
} else {
btv-has_radio = 0;
@@ -3072,7 +3071,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
pr_info(%d: miro: id=%d tuner=%d radio=%s stereo=%s\n,
btv-c.nr, id+1, btv-tuner_type,
!btv-has_radio ? no :
-   (btv-has_matchbox ? matchbox : fmtuner),
+   (btv-has_tea575x ? tea575x : fmtuner),
(-1 == msp) ? no : yes);
} else {
/* new cards with microtune tuner */
@@ -3347,12 +3346,12 @@ void bttv_init_card2(struct bttv *btv)
break;
case BTTV_BOARD_VHX:
btv-has_radio= 1;
-   btv-has_matchbox = 1;
-   btv-mbox_we  = 0x20;
-   btv-mbox_most= 0;
-   btv-mbox_clk = 0x08;
-   btv-mbox_data= 0x10;
-   btv-mbox_mask= 0x38;
+   btv-has_tea575x  = 1;
+   btv-tea_gpio.wren = 5;
+   btv-tea_gpio.most = 6;
+   btv-tea_gpio.clk  = 3;
+   btv-tea_gpio.data = 4;
+   tea575x_init(btv);
break;
case BTTV_BOARD_VOBIS_BOOSTAR:
case BTTV_BOARD_TERRATV:
@@ -3710,33 +3709,112 @@ static void hauppauge_eeprom(struct bttv *btv)
btv-radio_uses_msp_demodulator = 1;
 }
 
-static int terratec_active_radio_upgrade(struct bttv *btv)
+/* --- */
+
+static void bttv_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
+{
+   struct bttv *btv = tea-private_data;
+   struct

[PATCH] [RESEND] gspca-stk1135: Add delay after configuring clock

2013-11-11 Thread Ondrej Zary
Add a small delay at the end of configure_clock() to allow sensor to initialize.
This is needed by Asus VX2S laptop webcam to detect sensor type properly (the 
already-supported MT9M112).

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/usb/gspca/stk1135.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
index 8add2f7..d8a813c 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev 
*gspca_dev)
 
/* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */
reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
+
+   /* wait a while for sensor to catch up */
+   udelay(1000);
 }
 
 static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] gspca-stk1135: Add delay after configuring clock

2013-11-02 Thread Ondrej Zary
Add a small delay at the end of configure_clock() to allow sensor to initialize.
This is needed by Asus VX2S laptop webcam to detect sensor type properly (the 
already-supported MT9M112).

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/usb/gspca/stk1135.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
index 8add2f7..d8a813c 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev 
*gspca_dev)
 
/* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */
reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
+
+   /* wait a while for sensor to catch up */
+   udelay(1000);
 }
 
 static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] gspca-stk1135: Add variable resolution support

2013-08-30 Thread Ondrej Zary
Add variable resolution support to Syntek STK1135 subdriver.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/usb/gspca/stk1135.c |   68 ++--
 1 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
index 5a6ed49..8add2f7 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -48,42 +48,11 @@ struct sd {
 };
 
 static const struct v4l2_pix_format stk1135_modes[] = {
-   {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 160,
-   .sizeimage = 160 * 120,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 176,
-   .sizeimage = 176 * 144,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 320,
-   .sizeimage = 320 * 240,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 352,
-   .sizeimage = 352 * 288,
-   .colorspace = V4L2_COLORSPACE_SRGB},
+   /* default mode (this driver supports variable resolution) */
{640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480,
.colorspace = V4L2_COLORSPACE_SRGB},
-   {720, 576, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 720,
-   .sizeimage = 720 * 576,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 800,
-   .sizeimage = 800 * 600,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {1024, 768, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 1024,
-   .sizeimage = 1024 * 768,
-   .colorspace = V4L2_COLORSPACE_SRGB},
-   {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
-   .bytesperline = 1280,
-   .sizeimage = 1280 * 1024,
-   .colorspace = V4L2_COLORSPACE_SRGB},
 };
 
 /* -- read a register -- */
@@ -349,14 +318,14 @@ static void stk1135_configure_mt9m112(struct gspca_dev 
*gspca_dev)
/* set output size */
width = gspca_dev-pixfmt.width;
height = gspca_dev-pixfmt.height;
-   if (width = 640) { /* use context A (half readout speed by default) */
+   if (width = 640  height = 512) { /* context A (half readout speed)*/
sensor_write(gspca_dev, 0x1a7, width);
sensor_write(gspca_dev, 0x1aa, height);
/* set read mode context A */
sensor_write(gspca_dev, 0x0c8, 0x);
/* set resize, read mode, vblank, hblank context A */
sensor_write(gspca_dev, 0x2c8, 0x);
-   } else { /* use context B (full readout speed by default) */
+   } else { /* context B (full readout speed) */
sensor_write(gspca_dev, 0x1a1, width);
sensor_write(gspca_dev, 0x1a4, height);
/* set read mode context B */
@@ -643,6 +612,35 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
return 0;
 }
 
+void stk1135_try_fmt(struct gspca_dev *gspca_dev, struct v4l2_format *fmt)
+{
+   fmt-fmt.pix.width = clamp(fmt-fmt.pix.width, 32U, 1280U);
+   fmt-fmt.pix.height = clamp(fmt-fmt.pix.height, 32U, 1024U);
+   /* round up to even numbers */
+   fmt-fmt.pix.width += (fmt-fmt.pix.width  1);
+   fmt-fmt.pix.height += (fmt-fmt.pix.height  1);
+
+   fmt-fmt.pix.bytesperline = fmt-fmt.pix.width;
+   fmt-fmt.pix.sizeimage = fmt-fmt.pix.width * fmt-fmt.pix.height;
+}
+
+int stk1135_enum_framesizes(struct gspca_dev *gspca_dev,
+   struct v4l2_frmsizeenum *fsize)
+{
+   if (fsize-index != 0 || fsize-pixel_format != V4L2_PIX_FMT_SBGGR8)
+   return -EINVAL;
+
+   fsize-type = V4L2_FRMSIZE_TYPE_STEPWISE;
+   fsize-stepwise.min_width = 32;
+   fsize-stepwise.min_height = 32;
+   fsize-stepwise.max_width = 1280;
+   fsize-stepwise.max_height = 1024;
+   fsize-stepwise.step_width = 2;
+   fsize-stepwise.step_height = 2;
+
+   return 0;
+}
+
 /* sub-driver description */
 static const struct sd_desc sd_desc = {
.name = MODULE_NAME,
@@ -653,6 +651,8 @@ static const struct sd_desc sd_desc = {
.stopN = sd_stopN,
.pkt_scan = sd_pkt_scan,
.dq_callback = stk1135_dq_callback,
+   .try_fmt = stk1135_try_fmt,
+   .enum_framesizes = stk1135_enum_framesizes,
 };
 
 /* -- module initialisation -- */
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More

[PATCH 1/3] gspca: store current mode instead of individual parameters

2013-08-30 Thread Ondrej Zary
Store complete current mode (struct v4l2_pix_format) in struct gspca_dev
instead of separate pixfmt, width and height parameters.

This is a preparation for variable resolution support.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/usb/gspca/conex.c  |3 +-
 drivers/media/usb/gspca/cpia1.c  |4 +-
 drivers/media/usb/gspca/gspca.c  |   30 +
 drivers/media/usb/gspca/gspca.h  |4 +-
 drivers/media/usb/gspca/jeilinj.c|5 +-
 drivers/media/usb/gspca/jl2005bcd.c  |2 +-
 drivers/media/usb/gspca/m5602/m5602_mt9m111.c|2 +-
 drivers/media/usb/gspca/mars.c   |7 ++-
 drivers/media/usb/gspca/mr97310a.c   |6 +-
 drivers/media/usb/gspca/nw80x.c  |   11 +++--
 drivers/media/usb/gspca/ov519.c  |   51 --
 drivers/media/usb/gspca/ov534.c  |5 +-
 drivers/media/usb/gspca/pac207.c |4 +-
 drivers/media/usb/gspca/pac7311.c|6 +-
 drivers/media/usb/gspca/se401.c  |6 +-
 drivers/media/usb/gspca/sn9c20x.c|6 +-
 drivers/media/usb/gspca/sonixb.c |2 +-
 drivers/media/usb/gspca/sonixj.c |3 +-
 drivers/media/usb/gspca/spca1528.c   |3 +-
 drivers/media/usb/gspca/spca500.c|3 +-
 drivers/media/usb/gspca/sq905c.c |2 +-
 drivers/media/usb/gspca/sq930x.c |3 +-
 drivers/media/usb/gspca/stk014.c |5 +-
 drivers/media/usb/gspca/stk1135.c|8 ++--
 drivers/media/usb/gspca/stv06xx/stv06xx.c|2 +-
 drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c |2 +-
 drivers/media/usb/gspca/sunplus.c|3 +-
 drivers/media/usb/gspca/topro.c  |   13 +++---
 drivers/media/usb/gspca/tv8532.c |7 ++-
 drivers/media/usb/gspca/vicam.c  |8 ++--
 drivers/media/usb/gspca/w996Xcf.c|   28 ++--
 drivers/media/usb/gspca/xirlink_cit.c|   34 +++---
 drivers/media/usb/gspca/zc3xx.c  |3 +-
 33 files changed, 145 insertions(+), 136 deletions(-)

diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c
index 38714df..2e15c80 100644
--- a/drivers/media/usb/gspca/conex.c
+++ b/drivers/media/usb/gspca/conex.c
@@ -783,7 +783,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
struct sd *sd = (struct sd *) gspca_dev;
 
/* create the JPEG header */
-   jpeg_define(sd-jpeg_hdr, gspca_dev-height, gspca_dev-width,
+   jpeg_define(sd-jpeg_hdr, gspca_dev-pixfmt.height,
+   gspca_dev-pixfmt.width,
0x22);  /* JPEG 411 */
jpeg_set_qual(sd-jpeg_hdr, QUALITY);
 
diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 064b530..f23df4a 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -1553,9 +1553,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
sd-params.format.videoSize = VIDEOSIZE_CIF;
 
sd-params.roi.colEnd = sd-params.roi.colStart +
-   (gspca_dev-width  3);
+   (gspca_dev-pixfmt.width  3);
sd-params.roi.rowEnd = sd-params.roi.rowStart +
-   (gspca_dev-height  2);
+   (gspca_dev-pixfmt.height  2);
 
/* And now set the camera to a known state */
ret = do_command(gspca_dev, CPIA_COMMAND_SetGrabMode,
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index b7ae872..9ffcce6 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -504,8 +504,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev, struct 
file *file,
unsigned int frsz;
int i;
 
-   i = gspca_dev-curr_mode;
-   frsz = gspca_dev-cam.cam_mode[i].sizeimage;
+   frsz = gspca_dev-pixfmt.sizeimage;
PDEBUG(D_STREAM, frame alloc frsz: %d, frsz);
frsz = PAGE_ALIGN(frsz);
if (count = GSPCA_MAX_FRAMES)
@@ -627,16 +626,14 @@ static struct usb_host_endpoint *alt_xfer(struct 
usb_host_interface *alt,
 static u32 which_bandwidth(struct gspca_dev *gspca_dev)
 {
u32 bandwidth;
-   int i;
 
/* get the (max) image size */
-   i = gspca_dev-curr_mode;
-   bandwidth = gspca_dev-cam.cam_mode[i].sizeimage;
+   bandwidth = gspca_dev-pixfmt.sizeimage;
 
/* if the image is compressed, estimate its mean size */
if (!gspca_dev-cam.needs_full_bandwidth 
-   bandwidth  gspca_dev-cam.cam_mode[i].width *
-   gspca_dev-cam.cam_mode[i].height)
+   bandwidth  gspca_dev-pixfmt.width

[PATCH 2/3] gspca: Support variable resolution

2013-08-30 Thread Ondrej Zary
Add variable resolution support to gspca by allowing subdrivers to
specify try_fmt and enum_framesizes functions.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/usb/gspca/gspca.c |   20 ++--
 drivers/media/usb/gspca/gspca.h |6 ++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 9ffcce6..423c7c8 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1133,6 +1133,12 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
mode = mode2;
}
fmt-fmt.pix = gspca_dev-cam.cam_mode[mode];
+   if (gspca_dev-sd_desc-try_fmt) {
+   /* pass original resolution to subdriver try_fmt */
+   fmt-fmt.pix.width = w;
+   fmt-fmt.pix.height = h;
+   gspca_dev-sd_desc-try_fmt(gspca_dev, fmt);
+   }
/* some drivers use priv internally, zero it before giving it to
   userspace */
fmt-fmt.pix.priv = 0;
@@ -1171,17 +1177,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
goto out;
}
 
-   if (ret == gspca_dev-curr_mode) {
-   ret = 0;
-   goto out;   /* same mode */
-   }
-
if (gspca_dev-streaming) {
ret = -EBUSY;
goto out;
}
gspca_dev-curr_mode = ret;
-   gspca_dev-pixfmt = gspca_dev-cam.cam_mode[ret];
+   if (gspca_dev-sd_desc-try_fmt)
+   /* subdriver try_fmt can modify format parameters */
+   gspca_dev-pixfmt = fmt-fmt.pix;
+   else
+   gspca_dev-pixfmt = gspca_dev-cam.cam_mode[ret];
 
ret = 0;
 out:
@@ -1196,6 +1201,9 @@ static int vidioc_enum_framesizes(struct file *file, void 
*priv,
int i;
__u32 index = 0;
 
+   if (gspca_dev-sd_desc-enum_framesizes)
+   return gspca_dev-sd_desc-enum_framesizes(gspca_dev, fsize);
+
for (i = 0; i  gspca_dev-cam.nmodes; i++) {
if (fsize-pixel_format !=
gspca_dev-cam.cam_mode[i].pixelformat)
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index 0f3d150..300642d 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -88,6 +88,10 @@ typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
 typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev,
u8 *data,
int len);
+typedef void (*cam_format_op) (struct gspca_dev *gspca_dev,
+   struct v4l2_format *fmt);
+typedef int (*cam_frmsize_op) (struct gspca_dev *gspca_dev,
+   struct v4l2_frmsizeenum *fsize);
 
 /* subdriver description */
 struct sd_desc {
@@ -109,6 +113,8 @@ struct sd_desc {
cam_set_jpg_op set_jcomp;
cam_streamparm_op get_streamparm;
cam_streamparm_op set_streamparm;
+   cam_format_op try_fmt;
+   cam_frmsize_op enum_framesizes;
 #ifdef CONFIG_VIDEO_ADV_DEBUG
cam_set_reg_op set_register;
cam_get_reg_op get_register;
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] introduce gspca-stk1135: Syntek STK1135 driver

2013-08-20 Thread Ondrej Zary
Hello,
this is a new gspca driver for Syntek STK1135 webcams. The code is completely
new, but register values are based on Syntekdriver (stk11xx) by Nicolas VIVIEN
(http://syntekdriver.sourceforge.net).

Only one webcam type is supported now - vendor 0x174f, device 0x6a31.
It's Asus F5RL laptop flippable webcam with MT9M112.

The camera works better than in Windows - initializes much faster and
provides more resolutions (the sensor can do almost any resolution - just
add it to the stk1135_modes[] - could this feature be somehow used by
applications to avoid SW scaling?).

Autoflip works too - when the camera is flipped around, the image is flipped
automatically.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig
index 6345f93..4f0c6d5 100644
--- a/drivers/media/usb/gspca/Kconfig
+++ b/drivers/media/usb/gspca/Kconfig
@@ -338,6 +338,15 @@ config USB_GSPCA_STK014
  To compile this driver as a module, choose M here: the
  module will be called gspca_stk014.
 
+config USB_GSPCA_STK1135
+   tristate Syntek STK1135 USB Camera Driver
+   depends on VIDEO_V4L2  USB_GSPCA
+   help
+ Say Y here if you want support for cameras based on the STK1135 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gspca_stk1135.
+
 config USB_GSPCA_STV0680
tristate STV0680 USB Camera Driver
depends on VIDEO_V4L2  USB_GSPCA
diff --git a/drivers/media/usb/gspca/Makefile b/drivers/media/usb/gspca/Makefile
index c901da0..5855131 100644
--- a/drivers/media/usb/gspca/Makefile
+++ b/drivers/media/usb/gspca/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_GSPCA_SQ905C)   += gspca_sq905c.o
 obj-$(CONFIG_USB_GSPCA_SQ930X)   += gspca_sq930x.o
 obj-$(CONFIG_USB_GSPCA_SUNPLUS)  += gspca_sunplus.o
 obj-$(CONFIG_USB_GSPCA_STK014)   += gspca_stk014.o
+obj-$(CONFIG_USB_GSPCA_STK1135)  += gspca_stk1135.o
 obj-$(CONFIG_USB_GSPCA_STV0680)  += gspca_stv0680.o
 obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
 obj-$(CONFIG_USB_GSPCA_TOPRO)+= gspca_topro.o
@@ -78,6 +79,7 @@ gspca_sq905-objs:= sq905.o
 gspca_sq905c-objs   := sq905c.o
 gspca_sq930x-objs   := sq930x.o
 gspca_stk014-objs   := stk014.o
+gspca_stk1135-objs  := stk1135.o
 gspca_stv0680-objs  := stv0680.o
 gspca_sunplus-objs  := sunplus.o
 gspca_t613-objs := t613.o
diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
new file mode 100644
index 000..5858688
--- /dev/null
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -0,0 +1,685 @@
+/*
+ * Syntek STK1135 subdriver
+ *
+ * Copyright (c) 2013 Ondrej Zary
+ *
+ * Based on Syntekdriver (stk11xx) by Nicolas VIVIEN:
+ *   http://syntekdriver.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#define MODULE_NAME stk1135
+
+#include gspca.h
+#include stk1135.h
+
+MODULE_AUTHOR(Ondrej Zary);
+MODULE_DESCRIPTION(Syntek STK1135 USB Camera Driver);
+MODULE_LICENSE(GPL);
+
+
+/* specific webcam descriptor */
+struct sd {
+   struct gspca_dev gspca_dev; /* !! must be the first item */
+
+   u8 pkt_seq;
+   u8 sensor_page;
+
+   bool flip_status;
+   u8 flip_debounce;
+
+   struct v4l2_ctrl *hflip;
+   struct v4l2_ctrl *vflip;
+};
+
+static const struct v4l2_pix_format stk1135_modes[] = {
+   {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 160,
+   .sizeimage = 160 * 120,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 176,
+   .sizeimage = 176 * 144,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 320,
+   .sizeimage = 320 * 240,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 352,
+   .sizeimage = 352 * 288,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 640,
+   .sizeimage = 640 * 480,
+   .colorspace

Re: [RFC PATCH] introduce gspca-stk1135: Syntek STK1135 driver

2013-08-11 Thread Ondrej Zary


On Sunday 11 August 2013 11:26:18 Hans de Goede wrote:
 Hi,

 On 08/11/2013 12:10 AM, Ondrej Zary wrote:
  Hello,
  this is a new gspca driver for Syntek STK1135 webcams. The code is
  completely new, but register values are based on Syntekdriver (stk11xx)
  by Nicolas VIVIEN (http://syntekdriver.sourceforge.net).
 
  Only one webcam type is supported now - vendor 0x174f, device 0x6a31.
  It's Asus F5RL laptop flippable webcam with MT9M112.
 
  The camera works better than in Windows - initializes much faster and
  provides more resolutions

 You've certainly done this quickly, many thanks for working on this!

 Looks good. Any reason why this is RFC, iow any reason why I should not add
 this to my tree and include it in my next pullreq to Mauro ?

  Autoflip works too - when the camera is flipped around, the image is
  flipped automatically.

 Cool, but I've some comments on the implementation:

 1) It seems autoflip and manual flip with controls conflict, the manual
 setting will be overwritten as soon as the switch is debounced.
 I think it would be best to make the manual setting invert (when on) the
 setting detected from the switch

Yes, that's a problem. Too bad that there's no autorotate control in V4L2. 
Inverting seems like a good idea.

 2) You make the switch control both hflip and vflip, but the way the
 flipping works the sensor is not turned upside down, but rotated over its
 x-axis, so you should only set vflip based on the switch if I'm not
 mistaken. To verify this take a piece of paper, and write on it with large
 letters HELLO then hold it in front of the camera. It should read
 normally on the screen. I believe that in one of the 2 orientations of the
 camera it will be mirrored now since you set hflip while it should not be
 set

I thought that too at first - and changed only vflip. Then noticed that the 
image is mirrored when the camera is flipped to the back.

When the sensor is rotated over its x-axis, the left side of the sensor will 
be on the right side (when you look from the back of the laptop).

 3) Once debounced is over 100, you re-set hflip and vflip every frame, this
 causes expensive USB IO, so please cache the current setting and only
 change it if it actually needs to change

When debounce gets over 100, flip_status is inverted (so it matches the 
current state reported by camera). Thus, debounce is not incremented in 
sd_pkt_scan but reset to 0 instead.
Maybe the code could be re-arranged somehow to make this more clear.

 If you can do a new version with these 3 things fixed I'll happily pull it
 into my tree!

Working on it now.


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] introduce gspca-stk1135: Syntek STK1135 driver

2013-08-11 Thread Ondrej Zary
Hello,
this is a new gspca driver for Syntek STK1135 webcams. The code is completely
new, but register values are based on Syntekdriver (stk11xx) by Nicolas VIVIEN
(http://syntekdriver.sourceforge.net).

Only one webcam type is supported now - vendor 0x174f, device 0x6a31.
It's Asus F5RL laptop flippable webcam with MT9M112.

The camera works better than in Windows - initializes much faster and
provides more resolutions (the sensor can do almost any resolution - just
add it to the stk1135_modes[] - could this feature be somehow used by
applications to avoid SW scaling?).

Autoflip works too - when the camera is flipped around, the image is flipped
automatically.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig
index 6345f93..4f0c6d5 100644
--- a/drivers/media/usb/gspca/Kconfig
+++ b/drivers/media/usb/gspca/Kconfig
@@ -338,6 +338,15 @@ config USB_GSPCA_STK014
  To compile this driver as a module, choose M here: the
  module will be called gspca_stk014.
 
+config USB_GSPCA_STK1135
+   tristate Syntek STK1135 USB Camera Driver
+   depends on VIDEO_V4L2  USB_GSPCA
+   help
+ Say Y here if you want support for cameras based on the STK1135 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gspca_stk1135.
+
 config USB_GSPCA_STV0680
tristate STV0680 USB Camera Driver
depends on VIDEO_V4L2  USB_GSPCA
diff --git a/drivers/media/usb/gspca/Makefile b/drivers/media/usb/gspca/Makefile
index c901da0..5855131 100644
--- a/drivers/media/usb/gspca/Makefile
+++ b/drivers/media/usb/gspca/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_GSPCA_SQ905C)   += gspca_sq905c.o
 obj-$(CONFIG_USB_GSPCA_SQ930X)   += gspca_sq930x.o
 obj-$(CONFIG_USB_GSPCA_SUNPLUS)  += gspca_sunplus.o
 obj-$(CONFIG_USB_GSPCA_STK014)   += gspca_stk014.o
+obj-$(CONFIG_USB_GSPCA_STK1135)  += gspca_stk1135.o
 obj-$(CONFIG_USB_GSPCA_STV0680)  += gspca_stv0680.o
 obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
 obj-$(CONFIG_USB_GSPCA_TOPRO)+= gspca_topro.o
@@ -78,6 +79,7 @@ gspca_sq905-objs:= sq905.o
 gspca_sq905c-objs   := sq905c.o
 gspca_sq930x-objs   := sq930x.o
 gspca_stk014-objs   := stk014.o
+gspca_stk1135-objs  := stk1135.o
 gspca_stv0680-objs  := stv0680.o
 gspca_sunplus-objs  := sunplus.o
 gspca_t613-objs := t613.o
diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
new file mode 100644
index 000..5858688
--- /dev/null
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -0,0 +1,685 @@
+/*
+ * Syntek STK1135 subdriver
+ *
+ * Copyright (c) 2013 Ondrej Zary
+ *
+ * Based on Syntekdriver (stk11xx) by Nicolas VIVIEN:
+ *   http://syntekdriver.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#define MODULE_NAME stk1135
+
+#include gspca.h
+#include stk1135.h
+
+MODULE_AUTHOR(Ondrej Zary);
+MODULE_DESCRIPTION(Syntek STK1135 USB Camera Driver);
+MODULE_LICENSE(GPL);
+
+
+/* specific webcam descriptor */
+struct sd {
+   struct gspca_dev gspca_dev; /* !! must be the first item */
+
+   u8 pkt_seq;
+   u8 sensor_page;
+
+   bool flip_status;
+   u8 flip_debounce;
+
+   struct v4l2_ctrl *hflip;
+   struct v4l2_ctrl *vflip;
+};
+
+static const struct v4l2_pix_format stk1135_modes[] = {
+   {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 160,
+   .sizeimage = 160 * 120,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 176,
+   .sizeimage = 176 * 144,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 320,
+   .sizeimage = 320 * 240,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 352,
+   .sizeimage = 352 * 288,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 640,
+   .sizeimage = 640 * 480,
+   .colorspace

[RFC PATCH] introduce gspca-stk1135: Syntek STK1135 driver

2013-08-10 Thread Ondrej Zary
Hello,
this is a new gspca driver for Syntek STK1135 webcams. The code is completely
new, but register values are based on Syntekdriver (stk11xx) by Nicolas VIVIEN
(http://syntekdriver.sourceforge.net).

Only one webcam type is supported now - vendor 0x174f, device 0x6a31.
It's Asus F5RL laptop flippable webcam with MT9M112.

The camera works better than in Windows - initializes much faster and
provides more resolutions (the sensor can do almost any resolution - just
add it to the stk1135_modes[] - could this feature be somehow used by
applications to avoid SW scaling?).

Autoflip works too - when the camera is flipped around, the image is flipped
automatically.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig
index 6345f93..4f0c6d5 100644
--- a/drivers/media/usb/gspca/Kconfig
+++ b/drivers/media/usb/gspca/Kconfig
@@ -338,6 +338,15 @@ config USB_GSPCA_STK014
  To compile this driver as a module, choose M here: the
  module will be called gspca_stk014.
 
+config USB_GSPCA_STK1135
+   tristate Syntek STK1135 USB Camera Driver
+   depends on VIDEO_V4L2  USB_GSPCA
+   help
+ Say Y here if you want support for cameras based on the STK1135 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gspca_stk1135.
+
 config USB_GSPCA_STV0680
tristate STV0680 USB Camera Driver
depends on VIDEO_V4L2  USB_GSPCA
diff --git a/drivers/media/usb/gspca/Makefile b/drivers/media/usb/gspca/Makefile
index c901da0..5855131 100644
--- a/drivers/media/usb/gspca/Makefile
+++ b/drivers/media/usb/gspca/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_GSPCA_SQ905C)   += gspca_sq905c.o
 obj-$(CONFIG_USB_GSPCA_SQ930X)   += gspca_sq930x.o
 obj-$(CONFIG_USB_GSPCA_SUNPLUS)  += gspca_sunplus.o
 obj-$(CONFIG_USB_GSPCA_STK014)   += gspca_stk014.o
+obj-$(CONFIG_USB_GSPCA_STK1135)  += gspca_stk1135.o
 obj-$(CONFIG_USB_GSPCA_STV0680)  += gspca_stv0680.o
 obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
 obj-$(CONFIG_USB_GSPCA_TOPRO)+= gspca_topro.o
@@ -78,6 +79,7 @@ gspca_sq905-objs:= sq905.o
 gspca_sq905c-objs   := sq905c.o
 gspca_sq930x-objs   := sq930x.o
 gspca_stk014-objs   := stk014.o
+gspca_stk1135-objs  := stk1135.o
 gspca_stv0680-objs  := stv0680.o
 gspca_sunplus-objs  := sunplus.o
 gspca_t613-objs := t613.o
diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
new file mode 100644
index 000..0921491
--- /dev/null
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -0,0 +1,671 @@
+/*
+ * Syntek STK1135 subdriver
+ *
+ * Copyright (c) 2013 Ondrej Zary
+ *
+ * Based on Syntekdriver (stk11xx) by Nicolas VIVIEN:
+ *   http://syntekdriver.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#define MODULE_NAME stk1135
+
+#include gspca.h
+#include stk1135.h
+
+MODULE_AUTHOR(Ondrej Zary);
+MODULE_DESCRIPTION(Syntek STK1135 USB Camera Driver);
+MODULE_LICENSE(GPL);
+
+
+/* specific webcam descriptor */
+struct sd {
+   struct gspca_dev gspca_dev; /* !! must be the first item */
+
+   u8 pkt_seq;
+   u8 sensor_page;
+
+   bool flip_status;
+   u8 flip_debounce;
+};
+
+static const struct v4l2_pix_format stk1135_modes[] = {
+   {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 160,
+   .sizeimage = 160 * 120,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 176,
+   .sizeimage = 176 * 144,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 320,
+   .sizeimage = 320 * 240,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 352,
+   .sizeimage = 352 * 288,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+   .bytesperline = 640,
+   .sizeimage = 640 * 480,
+   .colorspace = V4L2_COLORSPACE_SRGB},
+   {720, 576, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE

Re: Syntek webcams and out-of-tree driver

2013-08-07 Thread Ondrej Zary
On Tuesday 06 August 2013 08:10:38 Hans de Goede wrote:
 Hi,

 On 08/05/2013 11:19 PM, Ondrej Zary wrote:
  Hello,
  the in-kernel stkwebcam driver (by Jaime Velasco Juan and Nicolas VIVIEN)
  supports only two webcam types (USB IDs 0x174f:0xa311 and 0x05e1:0x0501).
  There are many other Syntek webcam types that are not supported by this
  driver (such as 0x174f:0x6a31 in Asus F5RL laptop).
 
  There is an out-of-tree GPL driver called stk11xx (by Martin Roos and
  also Nicolas VIVIEN) at http://sourceforge.net/projects/syntekdriver/
  which supports more webcams. It can be even compiled for the latest
  kernels using the patch below and seems to work somehow (slow and buggy
  but better than nothing) with the Asus F5RL.

 I took a quick look and there are a number of issues with this driver:

 1) It conflicts usb-id wise with the new stk1160 driver (which supports
 usb-id 05e1:0408) so support for that usb-id, and any code only used for
 that id will need to be removed

 2) seems to work somehow (slow and buggy) is not really the quality
 we aim for with in kernel drivers. We definitely will want to remove
 any usb-ids, and any code only used for those ids, where there is overlap
 with the existing stkwebcam driver, to avoid regressions

 3) It does in kernel bayer decoding, this is not acceptable, it needs to
 be modified to produce buffers with raw bayer data (libv4l will take care
 of the bater decoding in userspace).

 4) It is not using any of the new kernel infrastructure we have been adding
 over time, like the control-framework, videobuf2, etc. It would be best
 to convert this to a gspca sub driver (of which there are many already,
 which can serve as examples), so that it will use all the existing
 framework code.

Here's a proof of concept that this can be done. HW dependent code copied from
stk11xx and modified a bit. Userspace bayer decoding works fine - I get
correct image in cheese (or mplayer with LD_PRELOAD)!

I've also found the STK1135 datasheet!
http://wenku.baidu.com/view/028c3459be23482fb4da4c5d
https://anonfiles.com/file/3b813f8e4c848ed26aaec804e0afa092

So I can clean up the driver now.

---
 drivers/media/usb/gspca/Kconfig   |9 +
 drivers/media/usb/gspca/Makefile  |2 +
 drivers/media/usb/gspca/stk1135.c |  968 +
 3 files changed, 979 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/usb/gspca/stk1135.c

diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig
index 6345f93..4f0c6d5 100644
--- a/drivers/media/usb/gspca/Kconfig
+++ b/drivers/media/usb/gspca/Kconfig
@@ -338,6 +338,15 @@ config USB_GSPCA_STK014
  To compile this driver as a module, choose M here: the
  module will be called gspca_stk014.
 
+config USB_GSPCA_STK1135
+   tristate Syntek STK1135 USB Camera Driver
+   depends on VIDEO_V4L2  USB_GSPCA
+   help
+ Say Y here if you want support for cameras based on the STK1135 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called gspca_stk1135.
+
 config USB_GSPCA_STV0680
tristate STV0680 USB Camera Driver
depends on VIDEO_V4L2  USB_GSPCA
diff --git a/drivers/media/usb/gspca/Makefile b/drivers/media/usb/gspca/Makefile
index c901da0..5855131 100644
--- a/drivers/media/usb/gspca/Makefile
+++ b/drivers/media/usb/gspca/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_GSPCA_SQ905C)   += gspca_sq905c.o
 obj-$(CONFIG_USB_GSPCA_SQ930X)   += gspca_sq930x.o
 obj-$(CONFIG_USB_GSPCA_SUNPLUS)  += gspca_sunplus.o
 obj-$(CONFIG_USB_GSPCA_STK014)   += gspca_stk014.o
+obj-$(CONFIG_USB_GSPCA_STK1135)  += gspca_stk1135.o
 obj-$(CONFIG_USB_GSPCA_STV0680)  += gspca_stv0680.o
 obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
 obj-$(CONFIG_USB_GSPCA_TOPRO)+= gspca_topro.o
@@ -78,6 +79,7 @@ gspca_sq905-objs:= sq905.o
 gspca_sq905c-objs   := sq905c.o
 gspca_sq930x-objs   := sq930x.o
 gspca_stk014-objs   := stk014.o
+gspca_stk1135-objs  := stk1135.o
 gspca_stv0680-objs  := stv0680.o
 gspca_sunplus-objs  := sunplus.o
 gspca_t613-objs := t613.o
diff --git a/drivers/media/usb/gspca/stk1135.c 
b/drivers/media/usb/gspca/stk1135.c
new file mode 100644
index 000..ce17202
--- /dev/null
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -0,0 +1,968 @@
+/*
+ * Syntek STK1135 subdriver
+ *
+ * Copyright (c) 2013 Ondrej Zary
+ *
+ * Based on Syntekdriver by Nicolas VIVIEN:
+ *   http://syntekdriver.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have

Re: Syntek webcams and out-of-tree driver

2013-08-06 Thread Ondrej Zary
On Tuesday 06 August 2013, Hans de Goede wrote:
 Hi,

 On 08/05/2013 11:19 PM, Ondrej Zary wrote:
  Hello,
  the in-kernel stkwebcam driver (by Jaime Velasco Juan and Nicolas VIVIEN)
  supports only two webcam types (USB IDs 0x174f:0xa311 and 0x05e1:0x0501).
  There are many other Syntek webcam types that are not supported by this
  driver (such as 0x174f:0x6a31 in Asus F5RL laptop).
 
  There is an out-of-tree GPL driver called stk11xx (by Martin Roos and
  also Nicolas VIVIEN) at http://sourceforge.net/projects/syntekdriver/
  which supports more webcams. It can be even compiled for the latest
  kernels using the patch below and seems to work somehow (slow and buggy
  but better than nothing) with the Asus F5RL.

 I took a quick look and there are a number of issues with this driver:

 1) It conflicts usb-id wise with the new stk1160 driver (which supports
 usb-id 05e1:0408) so support for that usb-id, and any code only used for
 that id will need to be removed

 2) seems to work somehow (slow and buggy) is not really the quality
 we aim for with in kernel drivers. We definitely will want to remove
 any usb-ids, and any code only used for those ids, where there is overlap
 with the existing stkwebcam driver, to avoid regressions

 3) It does in kernel bayer decoding, this is not acceptable, it needs to
 be modified to produce buffers with raw bayer data (libv4l will take care
 of the bater decoding in userspace).

 4) It is not using any of the new kernel infrastructure we have been adding
 over time, like the control-framework, videobuf2, etc. It would be best
 to convert this to a gspca sub driver (of which there are many already,
 which can serve as examples), so that it will use all the existing
 framework code.

Yes, this would be the best way - only extract the HW-dependent parts.

 As a minimum issues 1-3 needs to be addressed before this can be merged. An
 alternative /  better approach might be to simply only lift the code for
 your camera, and add a new gspca driver supporting only your camera.

 Either way since non of the v4l developers have a laptop which such a
 camera, you will need to do most of the work yourself, as we cannot test.

 So congratulations, you've just become a v4l kernel developer :)

Unfortunately the laptop isn't mine. I'll have it only for a while but will 
try to do something.

 Regards,

 Hans

  Is there any possibility that this driver could be merged into the
  kernel? The code could probably be simplified a lot and integrated into
  gspca.
 
 
  diff -urp syntekdriver-code-107-trunk-orig/driver/stk11xx.h
  syntekdriver-code-107-trunk//driver/stk11xx.h ---
  syntekdriver-code-107-trunk-orig/driver/stk11xx.h   2012-03-10
  10:03:12.0 +0100 +++
  syntekdriver-code-107-trunk//driver/stk11xx.h   2013-08-05
  22:50:00.0 +0200 @@ -33,6 +33,7 @@
 
#ifndef STK11XX_H
#define STK11XX_H
  +#include media/v4l2-device.h
 
#define DRIVER_NAME   stk11xx   
  /** Name of this driver */
#define DRIVER_VERSIONv3.0.0
  /** Version of this driver */
  @@ -316,6 +317,7 @@ struct stk11xx_video {
 * @struct usb_stk11xx
 */
struct usb_stk11xx {
  +   struct v4l2_device v4l2_dev;
  struct video_device *vdev;  /** Pointer on a V4L2 
  video device */
  struct usb_device *udev;/** Pointer on a USB 
  device */
  struct usb_interface *interface;/** Pointer on a USB interface 
  */
  diff -urp syntekdriver-code-107-trunk-orig/driver/stk11xx-v4l.c
  syntekdriver-code-107-trunk//driver/stk11xx-v4l.c ---
  syntekdriver-code-107-trunk-orig/driver/stk11xx-v4l.c   2012-03-10
  09:54:57.0 +0100 +++
  syntekdriver-code-107-trunk//driver/stk11xx-v4l.c   2013-08-05
  22:51:12.0 +0200 @@ -1498,9 +1498,17 @@ int
  v4l_stk11xx_register_video_device(st
{
  int err;
 
  +   err = v4l2_device_register(dev-interface-dev, dev-v4l2_dev);
  +   if (err  0) {
  +   STK_ERROR(couldn't register v4l2_device\n);
  +   kfree(dev);
  +   return err;
  +   }
  +
  strcpy(dev-vdev-name, DRIVER_DESC);
 
  -   dev-vdev-parent = dev-interface-dev;
  +// dev-vdev-parent = dev-interface-dev;
  +   dev-vdev-v4l2_dev = dev-v4l2_dev;
  dev-vdev-fops = v4l_stk11xx_fops;
  dev-vdev-release = video_device_release;
  dev-vdev-minor = -1;
  @@ -1533,6 +1541,7 @@ int v4l_stk11xx_unregister_video_device(
 
  video_set_drvdata(dev-vdev, NULL);
  video_unregister_device(dev-vdev);
  +   v4l2_device_unregister(dev-v4l2_dev);
 
  return 0;
}



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Syntek webcams and out-of-tree driver

2013-08-05 Thread Ondrej Zary
Hello,
the in-kernel stkwebcam driver (by Jaime Velasco Juan and Nicolas VIVIEN)
supports only two webcam types (USB IDs 0x174f:0xa311 and 0x05e1:0x0501).
There are many other Syntek webcam types that are not supported by this
driver (such as 0x174f:0x6a31 in Asus F5RL laptop).

There is an out-of-tree GPL driver called stk11xx (by Martin Roos and also
Nicolas VIVIEN) at http://sourceforge.net/projects/syntekdriver/ which
supports more webcams. It can be even compiled for the latest kernels using
the patch below and seems to work somehow (slow and buggy but better than
nothing) with the Asus F5RL.

Is there any possibility that this driver could be merged into the kernel?
The code could probably be simplified a lot and integrated into gspca.


diff -urp syntekdriver-code-107-trunk-orig/driver/stk11xx.h 
syntekdriver-code-107-trunk//driver/stk11xx.h
--- syntekdriver-code-107-trunk-orig/driver/stk11xx.h   2012-03-10 
10:03:12.0 +0100
+++ syntekdriver-code-107-trunk//driver/stk11xx.h   2013-08-05 
22:50:00.0 +0200
@@ -33,6 +33,7 @@
 
 #ifndef STK11XX_H
 #define STK11XX_H
+#include media/v4l2-device.h
 
 #define DRIVER_NAMEstk11xx   
/** Name of this driver */
 #define DRIVER_VERSION v3.0.0
/** Version of this driver */
@@ -316,6 +317,7 @@ struct stk11xx_video {
  * @struct usb_stk11xx
  */
 struct usb_stk11xx {
+   struct v4l2_device v4l2_dev;
struct video_device *vdev;  /** Pointer on a V4L2 
video device */
struct usb_device *udev;/** Pointer on a USB 
device */
struct usb_interface *interface;/** Pointer on a USB interface 
*/
diff -urp syntekdriver-code-107-trunk-orig/driver/stk11xx-v4l.c 
syntekdriver-code-107-trunk//driver/stk11xx-v4l.c
--- syntekdriver-code-107-trunk-orig/driver/stk11xx-v4l.c   2012-03-10 
09:54:57.0 +0100
+++ syntekdriver-code-107-trunk//driver/stk11xx-v4l.c   2013-08-05 
22:51:12.0 +0200
@@ -1498,9 +1498,17 @@ int v4l_stk11xx_register_video_device(st
 {
int err;
 
+   err = v4l2_device_register(dev-interface-dev, dev-v4l2_dev);
+   if (err  0) {
+   STK_ERROR(couldn't register v4l2_device\n);
+   kfree(dev);
+   return err;
+   }
+
strcpy(dev-vdev-name, DRIVER_DESC);
 
-   dev-vdev-parent = dev-interface-dev;
+// dev-vdev-parent = dev-interface-dev;
+   dev-vdev-v4l2_dev = dev-v4l2_dev;
dev-vdev-fops = v4l_stk11xx_fops;
dev-vdev-release = video_device_release;
dev-vdev-minor = -1;
@@ -1533,6 +1541,7 @@ int v4l_stk11xx_unregister_video_device(
 
video_set_drvdata(dev-vdev, NULL);
video_unregister_device(dev-vdev);
+   v4l2_device_unregister(dev-v4l2_dev);
 
return 0;
 }



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] tea575x: Move header from sound to media

2013-07-28 Thread Ondrej Zary
Move include/sound/tea575x-tuner.h to include/media/tea575x.h and update files 
that include it.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-maxiradio.c |2 +-
 drivers/media/radio/radio-sf16fmr2.c  |2 +-
 drivers/media/radio/radio-shark.c |2 +-
 include/media/tea575x.h   |   79 +
 include/sound/tea575x-tuner.h |   79 -
 sound/i2c/other/tea575x-tuner.c   |2 +-
 sound/pci/es1968.c|2 +-
 sound/pci/fm801.c |2 +-
 8 files changed, 85 insertions(+), 85 deletions(-)
 create mode 100644 include/media/tea575x.h
 delete mode 100644 include/sound/tea575x-tuner.h

diff --git a/drivers/media/radio/radio-maxiradio.c 
b/drivers/media/radio/radio-maxiradio.c
index 1d1c9e1..5236035 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -42,7 +42,7 @@
 #include linux/videodev2.h
 #include linux/io.h
 #include linux/slab.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-fh.h
diff --git a/drivers/media/radio/radio-sf16fmr2.c 
b/drivers/media/radio/radio-sf16fmr2.c
index 9c09904..f1e3714 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -14,7 +14,7 @@
 #include linux/io.h  /* outb, outb_p */
 #include linux/isa.h
 #include linux/pnp.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 
 MODULE_AUTHOR(Ondrej Zary);
 MODULE_DESCRIPTION(MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver);
diff --git a/drivers/media/radio/radio-shark.c 
b/drivers/media/radio/radio-shark.c
index 8fa18ab..b914772 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -33,7 +33,7 @@
 #include linux/usb.h
 #include linux/workqueue.h
 #include media/v4l2-device.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 
 #if defined(CONFIG_LEDS_CLASS) || \
 (defined(CONFIG_LEDS_CLASS_MODULE)  defined(CONFIG_RADIO_SHARK_MODULE))
diff --git a/include/media/tea575x.h b/include/media/tea575x.h
new file mode 100644
index 000..2d4fa59
--- /dev/null
+++ b/include/media/tea575x.h
@@ -0,0 +1,79 @@
+#ifndef __SOUND_TEA575X_TUNER_H
+#define __SOUND_TEA575X_TUNER_H
+
+/*
+ *   ALSA driver for TEA5757/5759 Philips AM/FM tuner chips
+ *
+ * Copyright (c) 2004 Jaroslav Kysela pe...@perex.cz
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+#include linux/videodev2.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-dev.h
+#include media/v4l2-device.h
+
+#define TEA575X_FMIF   10700
+#define TEA575X_AMIF 450
+
+#define TEA575X_DATA   (1  0)
+#define TEA575X_CLK(1  1)
+#define TEA575X_WREN   (1  2)
+#define TEA575X_MOST   (1  3)
+
+struct snd_tea575x;
+
+struct snd_tea575x_ops {
+   /* Drivers using snd_tea575x must either define read_ and write_val */
+   void (*write_val)(struct snd_tea575x *tea, u32 val);
+   u32 (*read_val)(struct snd_tea575x *tea);
+   /* Or define the 3 pin functions */
+   void (*set_pins)(struct snd_tea575x *tea, u8 pins);
+   u8 (*get_pins)(struct snd_tea575x *tea);
+   void (*set_direction)(struct snd_tea575x *tea, bool output);
+};
+
+struct snd_tea575x {
+   struct v4l2_device *v4l2_dev;
+   struct v4l2_file_operations fops;
+   struct video_device vd; /* video device */
+   int radio_nr;   /* radio_nr */
+   bool tea5759;   /* 5759 chip is present */
+   bool has_am;/* Device can tune to AM freqs */
+   bool cannot_read_data;  /* Device cannot read the data pin */
+   bool cannot_mute;   /* Device cannot mute */
+   bool mute;  /* Device is muted? */
+   bool stereo;/* receiving stereo */
+   bool tuned; /* tuned to a station */
+   unsigned int val;   /* hw value */
+   u32 band;   /* 0: FM, 1: FM-Japan, 2: AM */
+   u32 freq;   /* frequency */
+   struct mutex mutex;
+   struct snd_tea575x_ops

[PATCH 0/2] tea575x: Move from sound to media

2013-07-28 Thread Ondrej Zary

Hello,
TEA575x is neither a sound device nor an i2c device. Let's finally move it 
from sound/i2c/other to drivers/media/radio.

Tested with snd-es1968, snd-fm801 and radio-sf16fmr2.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] tea575x: Move from sound to media

2013-07-28 Thread Ondrej Zary
Move tea575x from sound/i2c/other to drivers/media/radio
Includes Kconfig changes by Hans Verkuil.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/Kconfig |   12 +-
 drivers/media/radio/Makefile|1 +
 drivers/media/radio/tea575x.c   |  584 +++
 sound/i2c/other/Makefile|2 -
 sound/i2c/other/tea575x-tuner.c |  584 ---
 sound/pci/Kconfig   |9 +-
 6 files changed, 598 insertions(+), 594 deletions(-)
 create mode 100644 drivers/media/radio/tea575x.c
 delete mode 100644 sound/i2c/other/tea575x-tuner.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index d529ba7..39882dd 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -12,6 +12,9 @@ menuconfig RADIO_ADAPTERS
 
 if RADIO_ADAPTERS  VIDEO_V4L2
 
+config RADIO_TEA575X
+   tristate
+
 config RADIO_SI470X
bool Silicon Labs Si470x FM Radio Receiver support
depends on VIDEO_V4L2
@@ -61,7 +64,8 @@ config USB_DSBR
 
 config RADIO_MAXIRADIO
tristate Guillemot MAXI Radio FM 2000 radio
-   depends on VIDEO_V4L2  PCI  SND
+   depends on VIDEO_V4L2  PCI
+   select RADIO_TEA575X
---help---
  Choose Y here if you have this radio card.  This card may also be
  found as Gemtek PCI FM.
@@ -76,7 +80,8 @@ config RADIO_MAXIRADIO
 
 config RADIO_SHARK
tristate Griffin radioSHARK USB radio receiver
-   depends on USB  SND
+   depends on USB
+   select RADIO_TEA575X
---help---
  Choose Y here if you have this radio receiver.
 
@@ -393,7 +398,8 @@ config RADIO_SF16FMI
 
 config RADIO_SF16FMR2
tristate SF16-FMR2/SF16-FMD2 Radio
-   depends on ISA  VIDEO_V4L2  SND
+   depends on ISA  VIDEO_V4L2
+   select RADIO_TEA575X
---help---
  Choose Y here if you have one of these FM radio cards.
 
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 0dcdb32..3b64560 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
 obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
 obj-$(CONFIG_RADIO_WL128X) += wl128x/
+obj-$(CONFIG_RADIO_TEA575X) += tea575x.o
 
 shark2-objs := radio-shark2.o radio-tea5777.o
 
diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
new file mode 100644
index 000..cef0698
--- /dev/null
+++ b/drivers/media/radio/tea575x.c
@@ -0,0 +1,584 @@
+/*
+ *   ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips
+ *
+ * Copyright (c) 2004 Jaroslav Kysela pe...@perex.cz
+ *
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+#include asm/io.h
+#include linux/delay.h
+#include linux/module.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/sched.h
+#include media/v4l2-device.h
+#include media/v4l2-dev.h
+#include media/v4l2-fh.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-event.h
+#include media/tea575x.h
+
+MODULE_AUTHOR(Jaroslav Kysela pe...@perex.cz);
+MODULE_DESCRIPTION(Routines for control of TEA5757/5759 Philips AM/FM radio 
tuner chips);
+MODULE_LICENSE(GPL);
+
+/*
+ * definitions
+ */
+
+#define TEA575X_BIT_SEARCH (124) /* 1 = search action, 0 = tuned 
*/
+#define TEA575X_BIT_UPDOWN (123) /* 0 = search down, 1 = search 
up */
+#define TEA575X_BIT_MONO   (122) /* 0 = stereo, 1 = mono */
+#define TEA575X_BIT_BAND_MASK  (320)
+#define TEA575X_BIT_BAND_FM(020)
+#define TEA575X_BIT_BAND_MW(120)
+#define TEA575X_BIT_BAND_LW(220)
+#define TEA575X_BIT_BAND_SW(320)
+#define TEA575X_BIT_PORT_0 (119) /* user bit */
+#define TEA575X_BIT_PORT_1 (118) /* user bit */
+#define TEA575X_BIT_SEARCH_MASK(316) /* search level */
+#define TEA575X_BIT_SEARCH_5_28 (016)/* FM 5uV, AM 28uV */
+#define TEA575X_BIT_SEARCH_10_40 (116)   /* FM 10uV, AM  40uV */
+#define TEA575X_BIT_SEARCH_30_63 (216)   /* FM 30uV, AM  63uV */
+#define TEA575X_BIT_SEARCH_150_1000  (316)   /* FM  150uV, AM  1000uV */
+#define TEA575X_BIT_DUMMY

[PATCH 2/2] radio-aztech: Implement signal strength detection and fix stereo detection

2013-07-19 Thread Ondrej Zary
Current stereo detection code is wrong - it reads TUNED bit instead of STEREO 
bit.
Fix that and implement signal strength detection too.
Also remove useless s_stereo functionn.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-aztech.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/media/radio/radio-aztech.c 
b/drivers/media/radio/radio-aztech.c
index 2f5671f..705dd6f 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -94,21 +94,16 @@ static int aztech_s_frequency(struct radio_isa_card *isa, 
u32 freq)
return 0;
 }
 
-/* thanks to Michael Dwyer for giving me a dose of clues in
- * the signal strength department..
- *
- * This card has a stereo bit - bit 0 set = mono, not set = stereo
- */
 static u32 aztech_g_rxsubchans(struct radio_isa_card *isa)
 {
-   if (inb(isa-io)  1)
+   if (inb(isa-io)  AZTECH_BIT_MONO)
return V4L2_TUNER_SUB_MONO;
return V4L2_TUNER_SUB_STEREO;
 }
 
-static int aztech_s_stereo(struct radio_isa_card *isa, bool stereo)
+static u32 aztech_g_signal(struct radio_isa_card *isa)
 {
-   return aztech_s_frequency(isa, isa-freq);
+   return (inb(isa-io)  AZTECH_BIT_NOT_TUNED) ? 0 : 0x;
 }
 
 static int aztech_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol)
@@ -126,8 +121,8 @@ static const struct radio_isa_ops aztech_ops = {
.alloc = aztech_alloc,
.s_mute_volume = aztech_s_mute_volume,
.s_frequency = aztech_s_frequency,
-   .s_stereo = aztech_s_stereo,
.g_rxsubchans = aztech_g_rxsubchans,
+   .g_signal = aztech_g_signal,
 };
 
 static const int aztech_ioports[] = { 0x350, 0x358 };
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] radio-aztech: Convert to generic lm7000 implementation

2013-07-19 Thread Ondrej Zary
Aztech radio card is based on LM7001 chip which is (software) compatible with 
LM7000.
So remove the LM7000-specific code from the driver and use generic code.

Also found that the card does not have A0..A2 ISA pins connected, which means 
that the region size is 8 bytes.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-aztech.c |   68 +---
 1 files changed, 24 insertions(+), 44 deletions(-)

diff --git a/drivers/media/radio/radio-aztech.c 
b/drivers/media/radio/radio-aztech.c
index 177bcbd..2f5671f 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -26,6 +26,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include radio-isa.h
+#include lm7000.h
 
 MODULE_AUTHOR(Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott 
McGrath, William McGrath);
 MODULE_DESCRIPTION(A driver for the Aztech radio card.);
@@ -54,18 +55,29 @@ struct aztech {
int curvol;
 };
 
-static void send_0_byte(struct aztech *az)
-{
-   udelay(radio_wait_time);
-   outb_p(2 + az-curvol, az-isa.io);
-   outb_p(64 + 2 + az-curvol, az-isa.io);
-}
+/* bit definitions for register read */
+#define AZTECH_BIT_NOT_TUNED   (1  0)
+#define AZTECH_BIT_MONO(1  1)
+/* bit definitions for register write */
+#define AZTECH_BIT_TUN_CE  (1  1)
+#define AZTECH_BIT_TUN_CLK (1  6)
+#define AZTECH_BIT_TUN_DATA(1  7)
+/* bits 0 and 2 are volume control, bits 3..5 are not connected */
 
-static void send_1_byte(struct aztech *az)
+static void aztech_set_pins(void *handle, u8 pins)
 {
-   udelay(radio_wait_time);
-   outb_p(128 + 2 + az-curvol, az-isa.io);
-   outb_p(128 + 64 + 2 + az-curvol, az-isa.io);
+   struct radio_isa_card *isa = handle;
+   struct aztech *az = container_of(isa, struct aztech, isa);
+   u8 bits = az-curvol;
+
+   if (pins  LM7000_DATA)
+   bits |= AZTECH_BIT_TUN_DATA;
+   if (pins  LM7000_CLK)
+   bits |= AZTECH_BIT_TUN_CLK;
+   if (pins  LM7000_CE)
+   bits |= AZTECH_BIT_TUN_CE;
+
+   outb_p(bits, az-isa.io);
 }
 
 static struct radio_isa_card *aztech_alloc(void)
@@ -77,39 +89,7 @@ static struct radio_isa_card *aztech_alloc(void)
 
 static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq)
 {
-   struct aztech *az = container_of(isa, struct aztech, isa);
-   int  i;
-
-   freq += 171200; /* Add 10.7 MHz IF  */
-   freq /= 800;/* Convert to 50 kHz units  */
-
-   send_0_byte(az);/*  0: LSB of frequency   */
-
-   for (i = 0; i  13; i++)/*   : frequency bits (1-13)  */
-   if (freq  (1  i))
-   send_1_byte(az);
-   else
-   send_0_byte(az);
-
-   send_0_byte(az);/* 14: test bit - always 0*/
-   send_0_byte(az);/* 15: test bit - always 0*/
-   send_0_byte(az);/* 16: band data 0 - always 0 */
-   if (isa-stereo)/* 17: stereo (1 to enable)   */
-   send_1_byte(az);
-   else
-   send_0_byte(az);
-
-   send_1_byte(az);/* 18: band data 1 - unknown  */
-   send_0_byte(az);/* 19: time base - always 0   */
-   send_0_byte(az);/* 20: spacing (0 = 25 kHz)   */
-   send_1_byte(az);/* 21: spacing (1 = 25 kHz)   */
-   send_0_byte(az);/* 22: spacing (0 = 25 kHz)   */
-   send_1_byte(az);/* 23: AM/FM (FM = 1, always) */
-
-   /* latch frequency */
-
-   udelay(radio_wait_time);
-   outb_p(128 + 64 + az-curvol, az-isa.io);
+   lm7000_set_freq(freq, isa, aztech_set_pins);
 
return 0;
 }
@@ -165,7 +145,7 @@ static struct radio_isa_driver aztech_driver = {
.radio_nr_params = radio_nr,
.io_ports = aztech_ioports,
.num_of_io_ports = ARRAY_SIZE(aztech_ioports),
-   .region_size = 2,
+   .region_size = 8,
.card = Aztech Radio,
.ops = aztech_ops,
.has_stereo = true,
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] radio-sf16fmi: Add module name to bus_info

2013-06-14 Thread Ondrej Zary
Fix v4l2-compliance in VIDIOC_QUERYCAP by changing ISA to ISA:radio-sf16fmi.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-sf16fmi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/radio/radio-sf16fmi.c 
b/drivers/media/radio/radio-sf16fmi.c
index 9e712c8..ed7299d 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -123,7 +123,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
 {
strlcpy(v-driver, radio-sf16fmi, sizeof(v-driver));
strlcpy(v-card, SF16-FMI/FMP/FMD radio, sizeof(v-card));
-   strlcpy(v-bus_info, ISA, sizeof(v-bus_info));
+   strlcpy(v-bus_info, ISA:radio-sf16fmi, sizeof(v-bus_info));
v-device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
v-capabilities = v-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] radio-sf16fmi: Fix remaining v4l2-compliance problems

2013-06-14 Thread Ondrej Zary

These patches fix two remaining v4l2-compliance problems of radio-sf16fmi 
driver after
control framework conversion:
http://www.mail-archive.com/linux-media%40vger.kernel.org/msg62772.html

Tested with SF16-FMI card.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] radio-sf16fmi: Set frequency during init

2013-06-14 Thread Ondrej Zary
Set freqency during initialization to fix v4l2-compliance error.
This also fixes VIDIOC_G_FREQUENCY always returning zero (broken by me during 
LM7000 conversion).

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-sf16fmi.c |   25 +
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/media/radio/radio-sf16fmi.c 
b/drivers/media/radio/radio-sf16fmi.c
index ed7299d..6f4318f 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -50,7 +50,7 @@ struct fmi
struct video_device vdev;
int io;
bool mute;
-   unsigned long curfreq; /* freq in kHz */
+   u32 curfreq; /* freq in kHz */
struct mutex lock;
 };
 
@@ -118,6 +118,14 @@ static inline int fmi_getsigstr(struct fmi *fmi)
return (res  2) ? 0 : 0x;
 }
 
+static void fmi_set_freq(struct fmi *fmi)
+{
+   fmi-curfreq = clamp(fmi-curfreq, RSF16_MINFREQ, RSF16_MAXFREQ);
+   /* rounding in steps of 800 to match the freq
+  that will be used */
+   lm7000_set_freq((fmi-curfreq / 800) * 800, fmi, fmi_set_pins);
+}
+
 static int vidioc_querycap(struct file *file, void  *priv,
struct v4l2_capability *v)
 {
@@ -158,14 +166,13 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
const struct v4l2_frequency *f)
 {
struct fmi *fmi = video_drvdata(file);
-   unsigned freq = f-frequency;
 
if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
return -EINVAL;
-   clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ);
-   /* rounding in steps of 800 to match the freq
-  that will be used */
-   lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins);
+
+   fmi-curfreq = f-frequency;
+   fmi_set_freq(fmi);
+
return 0;
 }
 
@@ -342,8 +349,10 @@ static int __init fmi_init(void)
 
mutex_init(fmi-lock);
 
-   /* mute card - prevents noisy bootups */
-   fmi_mute(fmi);
+   /* mute card and set default frequency */
+   fmi-mute = 1;
+   fmi-curfreq = RSF16_MINFREQ;
+   fmi_set_freq(fmi);
 
if (video_register_device(fmi-vdev, VFL_TYPE_RADIO, radio_nr)  0) {
v4l2_ctrl_handler_free(hdl);
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 1/2] tea575x: Move header from sound to media

2013-06-13 Thread Ondrej Zary
Move include/sound/tea575x-tuner.h to include/media/tea575x.h and update files 
that include it.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/radio-maxiradio.c |2 +-
 drivers/media/radio/radio-sf16fmr2.c  |2 +-
 drivers/media/radio/radio-shark.c |2 +-
 include/media/tea575x.h   |   78 +
 include/sound/tea575x-tuner.h |   78 -
 sound/i2c/other/tea575x-tuner.c   |2 +-
 sound/pci/es1968.c|2 +-
 sound/pci/fm801.c |2 +-
 8 files changed, 84 insertions(+), 84 deletions(-)
 create mode 100644 include/media/tea575x.h
 delete mode 100644 include/sound/tea575x-tuner.h

diff --git a/drivers/media/radio/radio-maxiradio.c 
b/drivers/media/radio/radio-maxiradio.c
index bd4d3a7..a76712a 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -42,7 +42,7 @@
 #include linux/videodev2.h
 #include linux/io.h
 #include linux/slab.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-fh.h
diff --git a/drivers/media/radio/radio-sf16fmr2.c 
b/drivers/media/radio/radio-sf16fmr2.c
index 9c09904..f1e3714 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -14,7 +14,7 @@
 #include linux/io.h  /* outb, outb_p */
 #include linux/isa.h
 #include linux/pnp.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 
 MODULE_AUTHOR(Ondrej Zary);
 MODULE_DESCRIPTION(MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver);
diff --git a/drivers/media/radio/radio-shark.c 
b/drivers/media/radio/radio-shark.c
index 8fa18ab..b914772 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -33,7 +33,7 @@
 #include linux/usb.h
 #include linux/workqueue.h
 #include media/v4l2-device.h
-#include sound/tea575x-tuner.h
+#include media/tea575x.h
 
 #if defined(CONFIG_LEDS_CLASS) || \
 (defined(CONFIG_LEDS_CLASS_MODULE)  defined(CONFIG_RADIO_SHARK_MODULE))
diff --git a/include/media/tea575x.h b/include/media/tea575x.h
new file mode 100644
index 000..098c4de
--- /dev/null
+++ b/include/media/tea575x.h
@@ -0,0 +1,78 @@
+#ifndef __SOUND_TEA575X_TUNER_H
+#define __SOUND_TEA575X_TUNER_H
+
+/*
+ *   ALSA driver for TEA5757/5759 Philips AM/FM tuner chips
+ *
+ * Copyright (c) 2004 Jaroslav Kysela pe...@perex.cz
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+#include linux/videodev2.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-dev.h
+#include media/v4l2-device.h
+
+#define TEA575X_FMIF   10700
+#define TEA575X_AMIF 450
+
+#define TEA575X_DATA   (1  0)
+#define TEA575X_CLK(1  1)
+#define TEA575X_WREN   (1  2)
+#define TEA575X_MOST   (1  3)
+
+struct snd_tea575x;
+
+struct snd_tea575x_ops {
+   /* Drivers using snd_tea575x must either define read_ and write_val */
+   void (*write_val)(struct snd_tea575x *tea, u32 val);
+   u32 (*read_val)(struct snd_tea575x *tea);
+   /* Or define the 3 pin functions */
+   void (*set_pins)(struct snd_tea575x *tea, u8 pins);
+   u8 (*get_pins)(struct snd_tea575x *tea);
+   void (*set_direction)(struct snd_tea575x *tea, bool output);
+};
+
+struct snd_tea575x {
+   struct v4l2_device *v4l2_dev;
+   struct v4l2_file_operations fops;
+   struct video_device vd; /* video device */
+   int radio_nr;   /* radio_nr */
+   bool tea5759;   /* 5759 chip is present */
+   bool has_am;/* Device can tune to AM freqs */
+   bool cannot_read_data;  /* Device cannot read the data pin */
+   bool cannot_mute;   /* Device cannot mute */
+   bool mute;  /* Device is muted? */
+   bool stereo;/* receiving stereo */
+   bool tuned; /* tuned to a station */
+   unsigned int val;   /* hw value */
+   u32 band;   /* 0: FM, 1: FM-Japan, 2: AM */
+   u32 freq;   /* frequency */
+   struct mutex mutex;
+   struct snd_tea575x_ops

[RFC PATCH 2/2] tea575x: Move from sound to media

2013-06-13 Thread Ondrej Zary
Move tea575x from sound/i2c/other to drivers/media/radio

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/radio/Kconfig |5 +
 drivers/media/radio/Makefile|1 +
 drivers/media/radio/tea575x.c   |  577 +++
 sound/i2c/other/Makefile|2 -
 sound/i2c/other/tea575x-tuner.c |  577 ---
 sound/pci/Kconfig   |5 -
 6 files changed, 583 insertions(+), 584 deletions(-)
 create mode 100644 drivers/media/radio/tea575x.c
 delete mode 100644 sound/i2c/other/tea575x-tuner.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index c0beee2..0f6341d 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -12,6 +12,11 @@ menuconfig RADIO_ADAPTERS
 
 if RADIO_ADAPTERS  VIDEO_V4L2
 
+config RADIO_TEA575X
+   tristate
+   depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO || RADIO_SF16FMR2 
|| RADIO_MAXIRADIO || RADIO_SHARK
+   default SND_FM801 || SND_ES1968 || RADIO_SF16FMR2 || RADIO_MAXIRADIO || 
RADIO_SHARK
+
 config RADIO_SI470X
bool Silicon Labs Si470x FM Radio Receiver support
depends on VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 0dcdb32..3b64560 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
 obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
 obj-$(CONFIG_RADIO_WL128X) += wl128x/
+obj-$(CONFIG_RADIO_TEA575X) += tea575x.o
 
 shark2-objs := radio-shark2.o radio-tea5777.o
 
diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
new file mode 100644
index 000..a1cb208
--- /dev/null
+++ b/drivers/media/radio/tea575x.c
@@ -0,0 +1,577 @@
+/*
+ *   ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips
+ *
+ * Copyright (c) 2004 Jaroslav Kysela pe...@perex.cz
+ *
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+#include asm/io.h
+#include linux/delay.h
+#include linux/module.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/sched.h
+#include media/v4l2-device.h
+#include media/v4l2-dev.h
+#include media/v4l2-fh.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-event.h
+#include media/tea575x.h
+
+MODULE_AUTHOR(Jaroslav Kysela pe...@perex.cz);
+MODULE_DESCRIPTION(Routines for control of TEA5757/5759 Philips AM/FM radio 
tuner chips);
+MODULE_LICENSE(GPL);
+
+/*
+ * definitions
+ */
+
+#define TEA575X_BIT_SEARCH (124) /* 1 = search action, 0 = tuned 
*/
+#define TEA575X_BIT_UPDOWN (123) /* 0 = search down, 1 = search 
up */
+#define TEA575X_BIT_MONO   (122) /* 0 = stereo, 1 = mono */
+#define TEA575X_BIT_BAND_MASK  (320)
+#define TEA575X_BIT_BAND_FM(020)
+#define TEA575X_BIT_BAND_MW(120)
+#define TEA575X_BIT_BAND_LW(220)
+#define TEA575X_BIT_BAND_SW(320)
+#define TEA575X_BIT_PORT_0 (119) /* user bit */
+#define TEA575X_BIT_PORT_1 (118) /* user bit */
+#define TEA575X_BIT_SEARCH_MASK(316) /* search level */
+#define TEA575X_BIT_SEARCH_5_28 (016)/* FM 5uV, AM 28uV */
+#define TEA575X_BIT_SEARCH_10_40 (116)   /* FM 10uV, AM  40uV */
+#define TEA575X_BIT_SEARCH_30_63 (216)   /* FM 30uV, AM  63uV */
+#define TEA575X_BIT_SEARCH_150_1000  (316)   /* FM  150uV, AM  1000uV */
+#define TEA575X_BIT_DUMMY  (115) /* buffer */
+#define TEA575X_BIT_FREQ_MASK  0x7fff
+
+enum { BAND_FM, BAND_FM_JAPAN, BAND_AM };
+
+static const struct v4l2_frequency_band bands[] = {
+   {
+   .type = V4L2_TUNER_RADIO,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
+ V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  87500 * 16,
+   .rangehigh  = 108000 * 16,
+   .modulation = V4L2_BAND_MODULATION_FM,
+   },
+   {
+   .type = V4L2_TUNER_RADIO,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
+ V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = 76000 * 16

[RFC PATCH 0/2] tea575x: Move from sound to media

2013-06-13 Thread Ondrej Zary
Hello,
TEA575x is neither a sound device nor an i2c device. Let's finally move it 
from sound/i2c/other to drivers/media/radio.

Tested with snd-es1968, snd-fm801 and radio-sf16fmr2.

I guess the Kconfig dependencies are not correct.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] bttv: stop abusing mbox_we for sw_status

2013-05-14 Thread Ondrej Zary
Kodicom 4400R and Geovision GV-800 code in bttv driver abuses mbox_we (int)
in struct bttv as char *.
Remove this hack and add a proper sw_status array to struct bttv instead.
This is a a preparation to remove mbox_we.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/bttv-cards.c |   26 +-
 drivers/media/pci/bt8xx/bttvp.h  |3 +++
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index b7dc921..24c7511 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -4401,9 +4401,7 @@ static void tibetCS16_init(struct bttv *btv)
  * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical
  * unit 3, the second (which is the master) is logical unit 0, etc.
  * We need to maintain the status of the analog switch (which of the 16
- * cameras is connected to which of the 4 controllers).  Rather than
- * add to the bttv structure for this, we use the data reserved for
- * the mbox (unused for this card type).
+ * cameras is connected to which of the 4 controllers) in sw_status array.
  */
 
 /*
@@ -4438,7 +4436,6 @@ static void kodicom4400r_write(struct bttv *btv,
  */
 static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
 {
-   char *sw_status;
int xaddr, yaddr;
struct bttv *mctlr;
static unsigned char map[4] = {3, 0, 2, 1};
@@ -4449,14 +4446,13 @@ static void kodicom4400r_muxsel(struct bttv *btv, 
unsigned int input)
}
yaddr = (btv-c.nr - mctlr-c.nr + 1)  3; /* the '' is for safety */
yaddr = map[yaddr];
-   sw_status = (char *)(mctlr-mbox_we);
xaddr = input  0xf;
/* Check if the controller/camera pair has changed, else ignore */
-   if (sw_status[yaddr] != xaddr)
+   if (mctlr-sw_status[yaddr] != xaddr)
{
/* open the old switch, close the new one, save the new */
-   kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0);
-   sw_status[yaddr] = xaddr;
+   kodicom4400r_write(mctlr, mctlr-sw_status[yaddr], yaddr, 0);
+   mctlr-sw_status[yaddr] = xaddr;
kodicom4400r_write(mctlr, xaddr, yaddr, 1);
}
 }
@@ -4469,7 +4465,6 @@ static void kodicom4400r_muxsel(struct bttv *btv, 
unsigned int input)
  */
 static void kodicom4400r_init(struct bttv *btv)
 {
-   char *sw_status = (char *)(btv-mbox_we);
int ix;
 
gpio_inout(0x0003ff, 0x0003ff);
@@ -4477,7 +4472,7 @@ static void kodicom4400r_init(struct bttv *btv)
gpio_write(0);
/* Preset camera 0 to the 4 controllers */
for (ix = 0; ix  4; ix++) {
-   sw_status[ix] = ix;
+   btv-sw_status[ix] = ix;
kodicom4400r_write(btv, ix, ix, 1);
}
/*
@@ -4754,7 +4749,6 @@ static void gv800s_write(struct bttv *btv,
 static void gv800s_muxsel(struct bttv *btv, unsigned int input)
 {
struct bttv *mctlr;
-   char *sw_status;
int xaddr, yaddr;
static unsigned int map[4][4] = { { 0x0, 0x4, 0xa, 0x6 },
  { 0x1, 0x5, 0xb, 0x7 },
@@ -4767,14 +4761,13 @@ static void gv800s_muxsel(struct bttv *btv, unsigned 
int input)
return;
}
yaddr = (btv-c.nr - mctlr-c.nr)  3;
-   sw_status = (char *)(mctlr-mbox_we);
xaddr = map[yaddr][input]  0xf;
 
/* Check if the controller/camera pair has changed, ignore otherwise */
-   if (sw_status[yaddr] != xaddr) {
+   if (mctlr-sw_status[yaddr] != xaddr) {
/* disable the old switch, enable the new one and save status */
-   gv800s_write(mctlr, sw_status[yaddr], yaddr, 0);
-   sw_status[yaddr] = xaddr;
+   gv800s_write(mctlr, mctlr-sw_status[yaddr], yaddr, 0);
+   mctlr-sw_status[yaddr] = xaddr;
gv800s_write(mctlr, xaddr, yaddr, 1);
}
 }
@@ -4782,7 +4775,6 @@ static void gv800s_muxsel(struct bttv *btv, unsigned int 
input)
 /* GeoVision GV-800(S) master chip init */
 static void gv800s_init(struct bttv *btv)
 {
-   char *sw_status = (char *)(btv-mbox_we);
int ix;
 
gpio_inout(0xf107f, 0xf107f);
@@ -4791,7 +4783,7 @@ static void gv800s_init(struct bttv *btv)
 
/* Preset camera 0 to the 4 controllers */
for (ix = 0; ix  4; ix++) {
-   sw_status[ix] = ix;
+   btv-sw_status[ix] = ix;
gv800s_write(btv, ix, ix, 1);
}
 
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 9c1cc2c..6eefb59 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -459,6 +459,9 @@ struct bttv {
int mbox_iow;
int mbox_csel;
 
+   /* switch status for multi-controller cards */
+   char sw_status[4];
+
/* risc memory

[PATCH 1/3] tea575x-tuner: move HW init to a separate function

2013-05-14 Thread Ondrej Zary
Move HW initialization to separate function to allow using the code without
the v4l parts. This is needed for use in the bttv driver.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 include/sound/tea575x-tuner.h   |1 +
 sound/i2c/other/tea575x-tuner.c |   19 +--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h
index 098c4de..2d4fa59 100644
--- a/include/sound/tea575x-tuner.h
+++ b/include/sound/tea575x-tuner.h
@@ -71,6 +71,7 @@ struct snd_tea575x {
int (*ext_init)(struct snd_tea575x *tea);
 };
 
+int snd_tea575x_hw_init(struct snd_tea575x *tea);
 int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner);
 void snd_tea575x_exit(struct snd_tea575x *tea);
 void snd_tea575x_set_freq(struct snd_tea575x *tea);
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 8a36a1d..46ec4dff 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -486,13 +486,9 @@ static const struct v4l2_ctrl_ops tea575x_ctrl_ops = {
.s_ctrl = tea575x_s_ctrl,
 };
 
-/*
- * initialize all the tea575x chips
- */
-int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner)
-{
-   int retval;
 
+int snd_tea575x_hw_init(struct snd_tea575x *tea)
+{
tea-mute = true;
 
/* Not all devices can or know how to read the data back.
@@ -507,6 +503,17 @@ int snd_tea575x_init(struct snd_tea575x *tea, struct 
module *owner)
tea-freq = 90500 * 16; /* 90.5Mhz default */
snd_tea575x_set_freq(tea);
 
+   return 0;
+}
+EXPORT_SYMBOL(snd_tea575x_hw_init);
+
+int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner)
+{
+   int retval = snd_tea575x_hw_init(tea);
+
+   if (retval)
+   return retval;
+
tea-vd = tea575x_radio;
video_set_drvdata(tea-vd, tea);
mutex_init(tea-mutex);
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 0/3] bttv: convert to generic TEA575x interface

2013-05-14 Thread Ondrej Zary

Hello,
this patch series removes the tea575x code from bttv and uses the common
tea575x driver instead. Only set_frequency is implemented (signal/stereo
detection or seek would require more changes to bttv).

It works fine on Video Highway Xtreme but I don't have the Miro/Pinnacle or
Terratec Active Radio Upgrade to test.

Miro/Pinnacle seems to be simple and should work.

However, I don't understand the Terratec Active Radio Upgrade code. The HW
seems to need IOR, IOW and CSEL signals that were taken from ISA bus on
older cards (IOR and IOW directly and CSEL from some address decoder) and
are emulated here using GPIOs. But the code manipulating these signals in
bttv seems to be broken - it never asserts the IOR signal. If anyone has
this HW, please test if I got that right.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] bttv: Convert to generic TEA575x interface

2013-05-14 Thread Ondrej Zary
Remove tea575x-specific code from bttv and use the common driver instead.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/bt8xx/bttv-cards.c  |  317 -
 drivers/media/pci/bt8xx/bttv-driver.c |6 +-
 drivers/media/pci/bt8xx/bttvp.h   |   14 +-
 sound/pci/Kconfig |4 +-
 4 files changed, 124 insertions(+), 217 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index 24c7511..8044df9 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -83,8 +83,7 @@ static void gv800s_init(struct bttv *btv);
 static void td3116_muxsel(struct bttv *btv, unsigned int input);
 
 static int terratec_active_radio_upgrade(struct bttv *btv);
-static int tea5757_read(struct bttv *btv);
-static int tea5757_write(struct bttv *btv, int value);
+static int tea575x_init(struct bttv *btv);
 static void identify_by_eeprom(struct bttv *btv,
   unsigned char eeprom_data[256]);
 static int pvr_boot(struct bttv *btv);
@@ -3023,12 +3022,12 @@ static void miro_pinnacle_gpio(struct bttv *btv)
if (0 == (gpio  0x20)) {
btv-has_radio = 1;
if (!miro_fmtuner[id]) {
-   btv-has_matchbox = 1;
-   btv-mbox_we= (16);
-   btv-mbox_most  = (17);
-   btv-mbox_clk   = (18);
-   btv-mbox_data  = (19);
-   btv-mbox_mask  = (16)|(17)|(18)|(19);
+   btv-has_tea575x = 1;
+   btv-tea_gpio.wren = 6;
+   btv-tea_gpio.most = 7;
+   btv-tea_gpio.clk  = 8;
+   btv-tea_gpio.data = 9;
+   tea575x_init(btv);
}
} else {
btv-has_radio = 0;
@@ -3042,7 +3041,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
pr_info(%d: miro: id=%d tuner=%d radio=%s stereo=%s\n,
btv-c.nr, id+1, btv-tuner_type,
!btv-has_radio ? no :
-   (btv-has_matchbox ? matchbox : fmtuner),
+   (btv-has_tea575x ? tea575x : fmtuner),
(-1 == msp) ? no : yes);
} else {
/* new cards with microtune tuner */
@@ -3317,12 +3316,12 @@ void bttv_init_card2(struct bttv *btv)
break;
case BTTV_BOARD_VHX:
btv-has_radio= 1;
-   btv-has_matchbox = 1;
-   btv-mbox_we  = 0x20;
-   btv-mbox_most= 0;
-   btv-mbox_clk = 0x08;
-   btv-mbox_data= 0x10;
-   btv-mbox_mask= 0x38;
+   btv-has_tea575x  = 1;
+   btv-tea_gpio.wren = 5;
+   btv-tea_gpio.most = 6;
+   btv-tea_gpio.clk  = 3;
+   btv-tea_gpio.data = 4;
+   tea575x_init(btv);
break;
case BTTV_BOARD_VOBIS_BOOSTAR:
case BTTV_BOARD_TERRATV:
@@ -3670,33 +3669,112 @@ static void hauppauge_eeprom(struct bttv *btv)
btv-radio_uses_msp_demodulator = 1;
 }
 
-static int terratec_active_radio_upgrade(struct bttv *btv)
+/* --- */
+
+static void bttv_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
+{
+   struct bttv *btv = tea-private_data;
+   struct bttv_tea575x_gpio gpio = btv-tea_gpio;
+   u16 val = 0;
+
+   val |= (pins  TEA575X_DATA) ? (1  gpio.data) : 0;
+   val |= (pins  TEA575X_CLK)  ? (1  gpio.clk)  : 0;
+   val |= (pins  TEA575X_WREN) ? (1  gpio.wren) : 0;
+
+   gpio_bits((1  gpio.data) | (1  gpio.clk) | (1  gpio.wren), val);
+   if (btv-mbox_ior) {
+   /* IOW and CSEL active */
+   gpio_bits(btv-mbox_iow | btv-mbox_csel, 0);
+   udelay(5);
+   /* all inactive */
+   gpio_bits(btv-mbox_ior | btv-mbox_iow | btv-mbox_csel,
+ btv-mbox_ior | btv-mbox_iow | btv-mbox_csel);
+   }
+}
+
+static u8 bttv_tea575x_get_pins(struct snd_tea575x *tea)
 {
-   int freq;
+   struct bttv *btv = tea-private_data;
+   struct bttv_tea575x_gpio gpio = btv-tea_gpio;
+   u8 ret = 0;
+   u16 val;
+
+   if (btv-mbox_ior) {
+   /* IOR and CSEL active */
+   gpio_bits(btv-mbox_ior | btv-mbox_csel, 0);
+   udelay(5);
+   }
+   val = gpio_read();
+   if (btv-mbox_ior) {
+   /* all inactive */
+   gpio_bits(btv-mbox_ior | btv-mbox_iow | btv-mbox_csel,
+ btv-mbox_ior | btv-mbox_iow | btv-mbox_csel);
+   }
+
+   if (val  (1

Re: [PATCH] bttv: Add CyberVision CV06

2013-04-15 Thread Ondrej Zary
On Sunday 14 April 2013 23:26:21 Ondrej Zary wrote:
 Add CyberVision CV06 4-camera card (from CyberVision SV card kit):
 http://www.cybervision.com.tw/products-swcard_kits-sv.html

 There are some interesting things on the card but they're not supported:
 4 LEDs, a connector with 4 IN and 4 OUT pins, RESET IN and RESET OUT
 connectors, a relay and CyberVision CV8088-SV16 chip

As there's no documentation and even no driver for any OS available, I've 
measured the GPIO connections on the card:
GPIO[00..11] - CV8088-SV16 (probably a relabelled MCU)
GPIO[12..15] - VIN1..VIN4 odd/even field (probably for camera disconnect 
detection - detected by a LM1881 chip for each input)
GPIO[16..19] - IN1..IN4 pins on connector
GPIO[20..23] - OUT1..OUT4 pins on connector


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] bttv: Add noname Bt848 capture card with 14MHz xtal

2013-04-14 Thread Ondrej Zary
Add support for noname Bt848 capture-only card (3x composite, 1x S-VHS)
with 14MHz crystal: 
http://www.rainbow-software.org/images/hardware/bt848_.jpg

14MHz PLL was not supported by bttv driver until now.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index b7dc921..8bcf638 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -131,7 +131,7 @@ MODULE_PARM_DESC(vsfx,set VSFX pci config bit 
 [yet another chipset flaw workaround]);
 MODULE_PARM_DESC(latency,pci latency timer);
 MODULE_PARM_DESC(card,specify TV/grabber card model, see CARDLIST file for a 
list);
-MODULE_PARM_DESC(pll,specify installed crystal (0=none, 28=28 MHz, 35=35 
MHz));
+MODULE_PARM_DESC(pll,specify installed crystal (0=none, 28=28 MHz, 35=35 MHz, 
14=14 MHz));
 MODULE_PARM_DESC(tuner,specify installed tuner type);
 MODULE_PARM_DESC(autoload, obsolete option, please do not use anymore);
 MODULE_PARM_DESC(audiodev, specify audio device:\n
@@ -2825,6 +2825,14 @@ struct tvcard bttv_tvcards[] = {
.muxsel = MUXSEL(2, 3, 1, 0),
.tuner_type = TUNER_ABSENT,
},
+   [BTTV_BOARD_BT848_CAP_14] = {
+   .name   = Bt848 Capture 14MHz,
+   .video_inputs   = 4,
+   .svhs   = 2,
+   .muxsel = MUXSEL(2, 3, 1, 0),
+   .pll= PLL_14,
+   .tuner_type = TUNER_ABSENT,
+   },
 
 };
 
@@ -3390,6 +3398,10 @@ void bttv_init_card2(struct bttv *btv)
btv-pll.pll_ifreq=35468950;
btv-pll.pll_crystal=BT848_IFORM_XT1;
}
+   if (PLL_14 == bttv_tvcards[btv-c.type].pll) {
+   btv-pll.pll_ifreq=14318181;
+   btv-pll.pll_crystal=BT848_IFORM_XT0;
+   }
/* insmod options can override */
switch (pll[btv-c.nr]) {
case 0: /* none */
@@ -3409,6 +3421,12 @@ void bttv_init_card2(struct bttv *btv)
btv-pll.pll_ofreq   = 0;
btv-pll.pll_crystal = BT848_IFORM_XT1;
break;
+   case 3: /* 14 MHz */
+   case 14:
+   btv-pll.pll_ifreq   = 14318181;
+   btv-pll.pll_ofreq   = 0;
+   btv-pll.pll_crystal = BT848_IFORM_XT0;
+   break;
}
}
btv-pll.pll_current = -1;
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index 6139ce2..2d4b466 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -185,6 +185,7 @@
 #define BTTV_BOARD_PV183   0x9f
 #define BTTV_BOARD_TVT_TD3116 0xa0
 #define BTTV_BOARD_APOSONIC_WDVR   0xa1
+#define BTTV_BOARD_BT848_CAP_140xa2
 
 /* more card-specific defines */
 #define PT2254_L_CHANNEL 0x10
@@ -232,6 +233,7 @@ struct tvcard {
 #define PLL_NONE 0
 #define PLL_28   1
 #define PLL_35   2
+#define PLL_14   3
 
/* i2c audio flags */
unsigned int no_msp34xx:1;


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bttv: Add noname Bt848 capture card with 14MHz xtal

2013-04-14 Thread Ondrej Zary
On Sunday 14 April 2013 18:39:09 Ondrej Zary wrote:
 Add support for noname Bt848 capture-only card (3x composite, 1x S-VHS)
 with 14MHz crystal:
 http://www.rainbow-software.org/images/hardware/bt848_.jpg

Noticed that it takes ages to load the bttv module (about 30 seconds).
If disable_ir=1 parameter is used, it loads immediately.
I wonder why the bttv driver probes for IR chips even when the has_remote 
flag is not set?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] bttv: Add CyberVision CV06

2013-04-14 Thread Ondrej Zary
Add CyberVision CV06 4-camera card (from CyberVision SV card kit):
http://www.cybervision.com.tw/products-swcard_kits-sv.html

There are some interesting things on the card but they're not supported:
4 LEDs, a connector with 4 IN and 4 OUT pins, RESET IN and RESET OUT
connectors, a relay and CyberVision CV8088-SV16 chip

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index 8bcf638..7bce09f 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -2833,6 +2833,16 @@ struct tvcard bttv_tvcards[] = {
.pll= PLL_14,
.tuner_type = TUNER_ABSENT,
},
+   [BTTV_BOARD_CYBERVISION_CV06] = {
+   .name   = CyberVision CV06 (SV),
+   .video_inputs   = 4,
+   /* .audio_inputs= 0, */
+   .svhs   = NO_SVHS,
+   .muxsel = MUXSEL(2, 3, 1, 0),
+   .pll= PLL_28,
+   .tuner_type = TUNER_ABSENT,
+   .tuner_addr = ADDR_UNSET,
+   },
 
 };
 
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index 2d4b466..bd35114 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -186,6 +186,7 @@
 #define BTTV_BOARD_TVT_TD3116 0xa0
 #define BTTV_BOARD_APOSONIC_WDVR   0xa1
 #define BTTV_BOARD_BT848_140xa2
+#define BTTV_BOARD_CYBERVISION_CV060xa3
 
 /* more card-specific defines */
 #define PT2254_L_CHANNEL 0x10


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


My patches for AverMedia A706

2013-04-05 Thread Ondrej Zary
Hello,
another month has passed and it seems that nothing has changed about my 
patches to support AverMedia A706 card. Is there anything I can do to help 
these patches to be merged?

Patch list:
tda8290: Allow disabling I2C gate
tda8290: Allow custom std_map for tda18271
tuner-core: Change config from unsigned int to void *
tda8290: change magic LNA config values to enum
saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-03-06 Thread Ondrej Zary
On Monday 18 February 2013 03:57:01 Michael Krufky wrote:
 On Sat, Feb 16, 2013 at 11:39 AM, Ondrej Zary

 li...@rainbow-software.org wrote:
  On Friday 01 February 2013 21:21:23 Ondrej Zary wrote:
  Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.
 
  This requires some changes to tda8290 - disabling I2C gate control and
  passing custom std_map to tda18271.
  Also tuner-core needs to be changed because there's currently no way to
  pass any complex configuration to analog tuners.
 
  What's the status of this patch series?
 
  The two tda8290 patches are in Michael's dvb tree.
  I've sent an additional clean-up patch (on Mauro's suggestion) for the
  tuner-core change.
  I guess that the final AverMedia A706 patch would be easily merged once
  the tda8290 and tuner-core changess are done.
 
  Should I resend something?

 I've just been a bit busier lately that I had foreseen, but no need to
 resend anything - I have your patches.  You'll hear back from me
 shortly.

Any news about these patches?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-02-16 Thread Ondrej Zary
On Friday 01 February 2013 21:21:23 Ondrej Zary wrote:
 Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.

 This requires some changes to tda8290 - disabling I2C gate control and
 passing custom std_map to tda18271.
 Also tuner-core needs to be changed because there's currently no way to
 pass any complex configuration to analog tuners.

What's the status of this patch series?

The two tda8290 patches are in Michael's dvb tree.
I've sent an additional clean-up patch (on Mauro's suggestion) for the 
tuner-core change.
I guess that the final AverMedia A706 patch would be easily merged once the 
tda8290 and tuner-core changess are done.

Should I resend something?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] tda8290: Allow disabling I2C gate

2013-02-04 Thread Ondrej Zary
On Monday 04 February 2013 03:19:37 Michael Krufky wrote:
 On Fri, Feb 1, 2013 at 3:21 PM, Ondrej Zary li...@rainbow-software.org 
wrote:
  Allow disabling I2C gate handling by external configuration.
  This is required by cards that have all devices on a single I2C bus,
  like AverMedia A706.
 
  Signed-off-by: Ondrej Zary li...@rainbow-software.org
  ---
   drivers/media/tuners/tda8290.c |   49
  +++ drivers/media/tuners/tda8290.h | 
1 +
   2 files changed, 30 insertions(+), 20 deletions(-)
 
  diff --git a/drivers/media/tuners/tda8290.c
  b/drivers/media/tuners/tda8290.c index 8c48521..a2b7a9f 100644
  --- a/drivers/media/tuners/tda8290.c
  +++ b/drivers/media/tuners/tda8290.c
  @@ -233,7 +233,8 @@ static void tda8290_set_params(struct dvb_frontend
  *fe, }
 
 
  -   tda8290_i2c_bridge(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
  if (fe-ops.tuner_ops.set_analog_params)
  fe-ops.tuner_ops.set_analog_params(fe, params);
  @@ -302,7 +303,8 @@ static void tda8290_set_params(struct dvb_frontend
  *fe, }
  }
 
  -   tda8290_i2c_bridge(fe, 0);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
  tuner_i2c_xfer_send(priv-i2c_props, if_agc_set, 2);
   }
 
  @@ -424,7 +426,8 @@ static void tda8295_set_params(struct dvb_frontend
  *fe, tuner_i2c_xfer_send(priv-i2c_props, blanking_mode, 2); msleep(20);
 
  -   tda8295_i2c_bridge(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
  if (fe-ops.tuner_ops.set_analog_params)
  fe-ops.tuner_ops.set_analog_params(fe, params);
  @@ -437,7 +440,8 @@ static void tda8295_set_params(struct dvb_frontend
  *fe, else
  tuner_dbg(tda8295 not locked, no signal?\n);
 
  -   tda8295_i2c_bridge(fe, 0);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
   }
 
  
  /*-*/
  @@ -465,11 +469,13 @@ static void tda8290_standby(struct dvb_frontend
  *fe) unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
  struct i2c_msg msg = {.addr = priv-tda827x_addr, .flags=0,
  .buf=cb1, .len = 2};
 
  -   tda8290_i2c_bridge(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
  if (priv-ver  TDA8275A)
  cb1[1] = 0x90;
  i2c_transfer(priv-i2c_props.adap, msg, 1);
  -   tda8290_i2c_bridge(fe, 0);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
  tuner_i2c_xfer_send(priv-i2c_props, tda8290_agc_tri, 2);
  tuner_i2c_xfer_send(priv-i2c_props, tda8290_standby, 2);
   }
  @@ -537,9 +543,11 @@ static void tda8290_init_tuner(struct dvb_frontend
  *fe) if (priv-ver  TDA8275A)
  msg.buf = tda8275a_init;
 
  -   tda8290_i2c_bridge(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
  i2c_transfer(priv-i2c_props.adap, msg, 1);
  -   tda8290_i2c_bridge(fe, 0);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
   }
 
  
  /*-*/
  @@ -565,19 +573,13 @@ static struct tda18271_config
  tda829x_tda18271_config = { static int tda829x_find_tuner(struct
  dvb_frontend *fe)
   {
  struct tda8290_priv *priv = fe-analog_demod_priv;
  -   struct analog_demod_ops *analog_ops = fe-ops.analog_ops;
  int i, ret, tuners_found;
  u32 tuner_addrs;
  u8 data;
  struct i2c_msg msg = { .flags = I2C_M_RD, .buf = data, .len = 1
  };
 
  -   if (!analog_ops-i2c_gate_ctrl) {
  -   printk(KERN_ERR tda8290: no gate control were
  provided!\n); -
  -   return -EINVAL;
  -   }
  -
  -   analog_ops-i2c_gate_ctrl(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
  /* probe for tuner chip */
  tuners_found = 0;
  @@ -595,7 +597,8 @@ static int tda829x_find_tuner(struct dvb_frontend
  *fe) give a response now
   */
 
  -   analog_ops-i2c_gate_ctrl(fe, 0);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
 
  if (tuners_found  1)
  for (i = 0; i  tuners_found; i++) {
  @@ -618,12 +621,14 @@ static int tda829x_find_tuner(struct dvb_frontend
  *fe) priv-tda827x_addr = tuner_addrs;
  msg.addr = tuner_addrs;
 
  -   analog_ops-i2c_gate_ctrl(fe, 1);
  +   if (fe-ops.analog_ops.i2c_gate_ctrl)
  +   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
  ret

[PATCH] tda8290: change magic LNA config values to enum

2013-02-04 Thread Ondrej Zary
Use enum instead of magic values for LNA config in tda8290.
Update tda827x, tda18271 and saa7134 to use the enum too.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-cards.c |   41 +++--
 drivers/media/tuners/tda18271-fe.c|9 +++---
 drivers/media/tuners/tda827x.c|   10 +++---
 drivers/media/tuners/tda827x.h|3 +-
 drivers/media/tuners/tda8290.c|3 +-
 drivers/media/tuners/tda8290.h|9 +-
 6 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index c603064..f8069f5 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -2765,7 +2765,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 0 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3296,7 +3296,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 1 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_ON },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x00020,
.inputs = {{
@@ -3400,7 +3400,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 1 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_ON },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x0200100,
.inputs = {{
@@ -3431,7 +3431,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 3 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_ON_BRIDGE },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.ts_force_val   = 1,
@@ -3464,7 +3464,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 3 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_ON_BRIDGE },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.gpiomask   = 0x0800100, /* GPIO 21 is an INPUT */
@@ -3688,7 +3688,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 2 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3741,7 +3741,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 2 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3759,7 +3759,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 2 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
.gpiomask   = 1  21,
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
@@ -3892,7 +3892,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tda829x_conf   = { .lna_cfg = 0 },
+   .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
.name   = name_tv, /* FIXME: analog tv untested */
@@ -3908,7 +3908,7 @@ struct

[PATCH v2 0/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-02-01 Thread Ondrej Zary

Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.

This requires some changes to tda8290 - disabling I2C gate control and
passing custom std_map to tda18271.
Also tuner-core needs to be changed because there's currently no way to pass
any complex configuration to analog tuners.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] tda8290: Allow disabling I2C gate

2013-02-01 Thread Ondrej Zary
Allow disabling I2C gate handling by external configuration.
This is required by cards that have all devices on a single I2C bus,
like AverMedia A706.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/tuners/tda8290.c |   49 +++
 drivers/media/tuners/tda8290.h |1 +
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c48521..a2b7a9f 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -233,7 +233,8 @@ static void tda8290_set_params(struct dvb_frontend *fe,
}
 
 
-   tda8290_i2c_bridge(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
if (fe-ops.tuner_ops.set_analog_params)
fe-ops.tuner_ops.set_analog_params(fe, params);
@@ -302,7 +303,8 @@ static void tda8290_set_params(struct dvb_frontend *fe,
}
}
 
-   tda8290_i2c_bridge(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
tuner_i2c_xfer_send(priv-i2c_props, if_agc_set, 2);
 }
 
@@ -424,7 +426,8 @@ static void tda8295_set_params(struct dvb_frontend *fe,
tuner_i2c_xfer_send(priv-i2c_props, blanking_mode, 2);
msleep(20);
 
-   tda8295_i2c_bridge(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
if (fe-ops.tuner_ops.set_analog_params)
fe-ops.tuner_ops.set_analog_params(fe, params);
@@ -437,7 +440,8 @@ static void tda8295_set_params(struct dvb_frontend *fe,
else
tuner_dbg(tda8295 not locked, no signal?\n);
 
-   tda8295_i2c_bridge(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
 }
 
 /*-*/
@@ -465,11 +469,13 @@ static void tda8290_standby(struct dvb_frontend *fe)
unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
struct i2c_msg msg = {.addr = priv-tda827x_addr, .flags=0, .buf=cb1, 
.len = 2};
 
-   tda8290_i2c_bridge(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
if (priv-ver  TDA8275A)
cb1[1] = 0x90;
i2c_transfer(priv-i2c_props.adap, msg, 1);
-   tda8290_i2c_bridge(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
tuner_i2c_xfer_send(priv-i2c_props, tda8290_agc_tri, 2);
tuner_i2c_xfer_send(priv-i2c_props, tda8290_standby, 2);
 }
@@ -537,9 +543,11 @@ static void tda8290_init_tuner(struct dvb_frontend *fe)
if (priv-ver  TDA8275A)
msg.buf = tda8275a_init;
 
-   tda8290_i2c_bridge(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
i2c_transfer(priv-i2c_props.adap, msg, 1);
-   tda8290_i2c_bridge(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
 }
 
 /*-*/
@@ -565,19 +573,13 @@ static struct tda18271_config tda829x_tda18271_config = {
 static int tda829x_find_tuner(struct dvb_frontend *fe)
 {
struct tda8290_priv *priv = fe-analog_demod_priv;
-   struct analog_demod_ops *analog_ops = fe-ops.analog_ops;
int i, ret, tuners_found;
u32 tuner_addrs;
u8 data;
struct i2c_msg msg = { .flags = I2C_M_RD, .buf = data, .len = 1 };
 
-   if (!analog_ops-i2c_gate_ctrl) {
-   printk(KERN_ERR tda8290: no gate control were provided!\n);
-
-   return -EINVAL;
-   }
-
-   analog_ops-i2c_gate_ctrl(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
 
/* probe for tuner chip */
tuners_found = 0;
@@ -595,7 +597,8 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
   give a response now
 */
 
-   analog_ops-i2c_gate_ctrl(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 0);
 
if (tuners_found  1)
for (i = 0; i  tuners_found; i++) {
@@ -618,12 +621,14 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
priv-tda827x_addr = tuner_addrs;
msg.addr = tuner_addrs;
 
-   analog_ops-i2c_gate_ctrl(fe, 1);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe-ops.analog_ops.i2c_gate_ctrl(fe, 1);
ret = i2c_transfer(priv-i2c_props.adap, msg, 1);
 
if (ret != 1) {
tuner_warn(tuner access failed!\n);
-   analog_ops-i2c_gate_ctrl(fe, 0);
+   if (fe-ops.analog_ops.i2c_gate_ctrl)
+   fe

[PATCH 2/4] tda8290: Allow custom std_map for tda18271

2013-02-01 Thread Ondrej Zary
Allow specifying a custom std_map for tda18271 by external configuration.
This is required by cards that require custom std_map for analog TV or radio,
like AverMedia A706.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/tuners/tda8290.c |8 ++--
 drivers/media/tuners/tda8290.h |2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index a2b7a9f..c1ade88 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -54,6 +54,7 @@ struct tda8290_priv {
 #define TDA18271 16
 
struct tda827x_config cfg;
+   struct tda18271_std_map *tda18271_std_map;
 };
 
 /*-*/
@@ -635,6 +636,7 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
if ((data == 0x83) || (data == 0x84)) {
priv-ver |= TDA18271;
tda829x_tda18271_config.config = priv-cfg.config;
+   tda829x_tda18271_config.std_map = priv-tda18271_std_map;
dvb_attach(tda18271_attach, fe, priv-tda827x_addr,
   priv-i2c_props.adap, tda829x_tda18271_config);
} else {
@@ -746,8 +748,10 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend 
*fe,
priv-i2c_props.addr = i2c_addr;
priv-i2c_props.adap = i2c_adap;
priv-i2c_props.name = tda829x;
-   if (cfg)
-   priv-cfg.config = cfg-lna_cfg;
+   if (cfg) {
+   priv-cfg.config = cfg-lna_cfg;
+   priv-tda18271_std_map = cfg-tda18271_std_map;
+   }
 
if (tda8290_probe(priv-i2c_props) == 0) {
priv-ver = TDA8290;
diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
index 9959cc8..280b70d 100644
--- a/drivers/media/tuners/tda8290.h
+++ b/drivers/media/tuners/tda8290.h
@@ -19,6 +19,7 @@
 
 #include linux/i2c.h
 #include dvb_frontend.h
+#include tda18271.h
 
 struct tda829x_config {
unsigned int lna_cfg;
@@ -27,6 +28,7 @@ struct tda829x_config {
 #define TDA829X_PROBE_TUNER 0
 #define TDA829X_DONT_PROBE  1
unsigned int no_i2c_gate:1;
+   struct tda18271_std_map *tda18271_std_map;
 };
 
 #if defined(CONFIG_MEDIA_TUNER_TDA8290) || 
(defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE)  defined(MODULE))
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] tuner-core: Change config from unsigned int to void *

2013-02-01 Thread Ondrej Zary
config looks like a hack that was added to tuner-core to allow some
configuration of TDA8290 tuner (it's not used by any other driver).
But with the new configuration options of tda8290 driver (no_i2c_gate
and std_map), it's no longer sufficient.

Change config to be void * instead, which allows passing tuner-dependent
config struct to drivers.

Also update saa7134 driver to reflect this change (no other driver uses this).

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-cards.c |   40 ++--
 drivers/media/pci/saa7134/saa7134.h   |3 +-
 drivers/media/v4l2-core/tuner-core.c  |   20 +-
 include/media/tuner.h |2 +-
 4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index bc08f1d..fe54f88 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -2760,7 +2760,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 0,
+   .tda829x_conf   = { .lna_cfg = 0 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3291,7 +3291,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 1,
+   .tda829x_conf   = { .lna_cfg = 1 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x00020,
.inputs = {{
@@ -3395,7 +3395,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 1,
+   .tda829x_conf   = { .lna_cfg = 1 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x0200100,
.inputs = {{
@@ -3426,7 +3426,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 3,
+   .tda829x_conf   = { .lna_cfg = 3 },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.ts_force_val   = 1,
@@ -3459,7 +3459,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 3,
+   .tda829x_conf   = { .lna_cfg = 3 },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.gpiomask   = 0x0800100, /* GPIO 21 is an INPUT */
@@ -3683,7 +3683,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3736,7 +3736,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3754,7 +3754,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.gpiomask   = 1  21,
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
@@ -3887,7 +3887,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 0,
+   .tda829x_conf   = { .lna_cfg = 0 },
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
.name   = name_tv, /* FIXME: analog tv untested */
@@ -3903,7 +3903,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr

[PATCH 4/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-02-01 Thread Ondrej Zary
Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.
Working: analog inputs, TV, FM radio and IR remote control.
Untested: DVB-S.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/i2c/ir-kbd-i2c.c  |   13 ++-
 drivers/media/pci/saa7134/saa7134-cards.c   |   53 +++
 drivers/media/pci/saa7134/saa7134-dvb.c |   23 
 drivers/media/pci/saa7134/saa7134-i2c.c |1 +
 drivers/media/pci/saa7134/saa7134-input.c   |3 ++
 drivers/media/pci/saa7134/saa7134-tvaudio.c |1 +
 drivers/media/pci/saa7134/saa7134.h |1 +
 7 files changed, 94 insertions(+), 1 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 08ae067..c1f6e7c 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -230,7 +230,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
return 0;
 
dprintk(1, read key 0x%02x/0x%02x\n, key, keygroup);
-   if (keygroup  2 || keygroup  3) {
+   if (keygroup  2 || keygroup  4) {
/* Only a warning */
dprintk(1, warning: invalid key group 0x%02x for key 0x%02x\n,
keygroup, key);
@@ -239,6 +239,10 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
 
*ir_key = key;
*ir_raw = key;
+   if (!strcmp(ir-ir_codes, RC_MAP_AVERMEDIA_M733A_RM_K6)) {
+   *ir_key |= keygroup  8;
+   *ir_raw |= keygroup  8;
+   }
return 1;
 }
 
@@ -332,6 +336,13 @@ static int ir_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
rc_type = RC_BIT_OTHER;
ir_codes= RC_MAP_AVERMEDIA_CARDBUS;
break;
+   case 0x41:
+   name= AVerMedia EM78P153;
+   ir-get_key = get_key_avermedia_cardbus;
+   rc_type = RC_BIT_OTHER;
+   /* RM-KV remote, seems to be same as RM-K6 */
+   ir_codes= RC_MAP_AVERMEDIA_M733A_RM_K6;
+   break;
case 0x71:
name= Hauppauge/Zilog Z8;
ir-get_key = get_key_haup_xvr;
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index fe54f88..c603064 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -50,6 +50,11 @@ static char name_svideo[]  = S-Video;
 /* -- */
 /* board config info  */
 
+static struct tda18271_std_map aver_a706_std_map = {
+   .fm_radio = { .if_freq = 5500, .fm_rfn = 0, .agc_mode = 3, .std = 0,
+ .if_lvl = 0, .rfagc_top = 0x2c, },
+};
+
 /* If radio_type !=UNSET, radio_addr should be specified
  */
 
@@ -5773,6 +5778,37 @@ struct saa7134_board saa7134_boards[] = {
.gpio   = 0x000,
},
},
+   [SAA7134_BOARD_AVERMEDIA_A706] = {
+   .name   = AverMedia AverTV Satellite Hybrid+FM A706,
+   .audio_clock= 0x00187de7,
+   .tuner_type = TUNER_PHILIPS_TDA8290,
+   .radio_type = UNSET,
+   .tuner_addr = ADDR_UNSET,
+   .radio_addr = ADDR_UNSET,
+   .tda829x_conf   = { .lna_cfg = 0, .no_i2c_gate = 1,
+   .tda18271_std_map = aver_a706_std_map },
+   .gpiomask   = 1  11,
+   .mpeg   = SAA7134_MPEG_DVB,
+   .inputs = {{
+   .name = name_tv,
+   .vmux = 1,
+   .amux = TV,
+   .tv   = 1,
+   }, {
+   .name = name_comp,
+   .vmux = 4,
+   .amux = LINE1,
+   }, {
+   .name = name_svideo,
+   .vmux = 8,
+   .amux = LINE1,
+   } },
+   .radio = {
+   .name = name_radio,
+   .amux = TV,
+   .gpio = 0x800,
+   },
+   },
 
 };
 
@@ -7020,6 +7056,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice= 0x0911,
.driver_data  = SAA7134_BOARD_SENSORAY811_911,
}, {
+   .vendor   = PCI_VENDOR_ID_PHILIPS,
+   .device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+   .subvendor= 0x1461, /* Avermedia Technologies Inc */
+   .subdevice= 0x2055, /* AverTV Satellite Hybrid+FM A706 */
+   .driver_data  = SAA7134_BOARD_AVERMEDIA_A706,
+   }, {
/* --- boards without eeprom + subsystem ID --- */
.vendor

[PATCH 0/8] saa7134: improve v4l2-compliance

2013-02-01 Thread Ondrej Zary

This patch series improves v4l2-compliance of saa7134 driver. This includes only
easy-to-fix things. More work is needed to fix the other problems.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/8] saa7134: v4l2-compliance: implement V4L2_CAP_DEVICE_CAPS

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: implement V4L2_CAP_DEVICE_CAPS support
and fix all capabilities problems reported by v4l2-compliance.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |   58 +
 1 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 3abf527..c8ed685 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1805,6 +1805,8 @@ static int saa7134_querycap(struct file *file, void  
*priv,
 {
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh-dev;
+   struct video_device *vdev = video_devdata(file);
+   u32 radio_caps, video_caps, vbi_caps;
 
unsigned int tuner_type = dev-tuner_type;
 
@@ -1812,19 +1814,40 @@ static int saa7134_querycap(struct file *file, void  
*priv,
strlcpy(cap-card, saa7134_boards[dev-board].name,
sizeof(cap-card));
sprintf(cap-bus_info, PCI:%s, pci_name(dev-pci));
-   cap-capabilities =
-   V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_VBI_CAPTURE |
-   V4L2_CAP_READWRITE |
-   V4L2_CAP_STREAMING |
-   V4L2_CAP_TUNER;
+
+   cap-device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
+   if ((tuner_type != TUNER_ABSENT)  (tuner_type != UNSET))
+   cap-device_caps |= V4L2_CAP_TUNER;
+
+   radio_caps = V4L2_CAP_RADIO;
if (dev-has_rds)
-   cap-capabilities |= V4L2_CAP_RDS_CAPTURE;
+   radio_caps |= V4L2_CAP_RDS_CAPTURE;
+
+   video_caps = V4L2_CAP_VIDEO_CAPTURE;
if (saa7134_no_overlay = 0)
-   cap-capabilities |= V4L2_CAP_VIDEO_OVERLAY;
+   video_caps |= V4L2_CAP_VIDEO_OVERLAY;
+
+   vbi_caps = V4L2_CAP_VBI_CAPTURE;
+
+   switch (vdev-vfl_type) {
+   case VFL_TYPE_RADIO:
+   cap-device_caps |= radio_caps;
+   break;
+   case VFL_TYPE_GRABBER:
+   cap-device_caps |= video_caps;
+   break;
+   case VFL_TYPE_VBI:
+   cap-device_caps |= vbi_caps;
+   break;
+   }
+   cap-capabilities = radio_caps | video_caps | vbi_caps |
+   cap-device_caps | V4L2_CAP_DEVICE_CAPS;
+   if (vdev-vfl_type == VFL_TYPE_RADIO) {
+   cap-device_caps = ~V4L2_CAP_STREAMING;
+   if (!dev-has_rds)
+   cap-device_caps = ~V4L2_CAP_READWRITE;
+   }
 
-   if ((tuner_type == TUNER_ABSENT) || (tuner_type == UNSET))
-   cap-capabilities = ~V4L2_CAP_TUNER;
return 0;
 }
 
@@ -2299,19 +2322,6 @@ static int vidioc_s_register (struct file *file, void 
*priv,
 }
 #endif
 
-static int radio_querycap(struct file *file, void *priv,
-   struct v4l2_capability *cap)
-{
-   struct saa7134_fh *fh = file-private_data;
-   struct saa7134_dev *dev = fh-dev;
-
-   strcpy(cap-driver, saa7134);
-   strlcpy(cap-card, saa7134_boards[dev-board].name, sizeof(cap-card));
-   sprintf(cap-bus_info, PCI:%s, pci_name(dev-pci));
-   cap-capabilities = V4L2_CAP_TUNER;
-   return 0;
-}
-
 static int radio_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *t)
 {
@@ -2473,7 +2483,7 @@ static const struct v4l2_file_operations radio_fops = {
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
-   .vidioc_querycap= radio_querycap,
+   .vidioc_querycap= saa7134_querycap,
.vidioc_g_tuner = radio_g_tuner,
.vidioc_enum_input  = radio_enum_input,
.vidioc_g_audio = radio_g_audio,
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] saa7134: v4l2-compliance: don't report invalid audio modes for radio

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: filter audio modes that came from
tuner - keep only MONO/STEREO in radio mode

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index c8ed685..62b6f6c 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2336,6 +2336,7 @@ static int radio_g_tuner(struct file *file, void *priv,
t-type = V4L2_TUNER_RADIO;
 
saa_call_all(dev, tuner, g_tuner, t);
+   t-audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO;
if (dev-input-amux == TV) {
t-signal = 0xf800 - ((saa_readb(0x581)  0x1f)  11);
t-rxsubchans = (saa_readb(0x529)  0x08) ?
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8] saa7134: v4l2-compliance: use v4l2_fh to fix priority handling

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: remove broken priority handling
and use v4l2_fh instead

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-core.c  |3 +-
 drivers/media/pci/saa7134/saa7134-video.c |   61 +++-
 drivers/media/pci/saa7134/saa7134.h   |4 +-
 3 files changed, 10 insertions(+), 58 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-core.c 
b/drivers/media/pci/saa7134/saa7134-core.c
index 8976d0e..ba08bd6 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -805,6 +805,7 @@ static struct video_device *vdev_init(struct saa7134_dev 
*dev,
vfd-debug   = video_debug;
snprintf(vfd-name, sizeof(vfd-name), %s %s (%s),
 dev-name, type, saa7134_boards[dev-board].name);
+   set_bit(V4L2_FL_USE_FH_PRIO, vfd-flags);
video_set_drvdata(vfd, dev);
return vfd;
 }
@@ -1028,8 +1029,6 @@ static int __devinit saa7134_initdev(struct pci_dev 
*pci_dev,
}
}
 
-   v4l2_prio_init(dev-prio);
-
mutex_lock(saa7134_devlist_lock);
list_for_each_entry(mops, mops_list, next)
mpeg_ops_attach(mops, dev);
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 62b6f6c..cd4959e 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1176,14 +1176,6 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev,  
struct saa7134_fh *fh, str
int restart_overlay = 0;
int err;
 
-   /* When called from the empress code fh == NULL.
-  That needs to be fixed somehow, but for now this is
-  good enough. */
-   if (fh) {
-   err = v4l2_prio_check(dev-prio, fh-prio);
-   if (0 != err)
-   return err;
-   }
err = -EINVAL;
 
mutex_lock(dev-lock);
@@ -1352,6 +1344,7 @@ static int video_open(struct file *file)
if (NULL == fh)
return -ENOMEM;
 
+   v4l2_fh_init(fh-fh, vdev);
file-private_data = fh;
fh-dev  = dev;
fh-radio= radio;
@@ -1359,7 +1352,6 @@ static int video_open(struct file *file)
fh-fmt  = format_by_fourcc(V4L2_PIX_FMT_BGR24);
fh-width= 720;
fh-height   = 576;
-   v4l2_prio_open(dev-prio, fh-prio);
 
videobuf_queue_sg_init(fh-cap, video_qops,
dev-pci-dev, dev-slock,
@@ -1384,6 +1376,8 @@ static int video_open(struct file *file)
/* switch to video/vbi mode */
video_mux(dev,dev-ctl_input);
}
+   v4l2_fh_add(fh-fh);
+
return 0;
 }
 
@@ -1504,7 +1498,8 @@ static int video_release(struct file *file)
saa7134_pgtable_free(dev-pci,fh-pt_cap);
saa7134_pgtable_free(dev-pci,fh-pt_vbi);
 
-   v4l2_prio_close(dev-prio, fh-prio);
+   v4l2_fh_del(fh-fh);
+   v4l2_fh_exit(fh-fh);
file-private_data = NULL;
kfree(fh);
return 0;
@@ -1784,11 +1779,6 @@ static int saa7134_s_input(struct file *file, void 
*priv, unsigned int i)
 {
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh-dev;
-   int err;
-
-   err = v4l2_prio_check(dev-prio, fh-prio);
-   if (0 != err)
-   return err;
 
if (i = SAA7134_INPUT_MAX)
return -EINVAL;
@@ -1856,16 +1846,8 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, 
struct saa7134_fh *fh, v4l2_
unsigned long flags;
unsigned int i;
v4l2_std_id fixup;
-   int err;
 
-   /* When called from the empress code fh == NULL.
-  That needs to be fixed somehow, but for now this is
-  good enough. */
-   if (fh) {
-   err = v4l2_prio_check(dev-prio, fh-prio);
-   if (0 != err)
-   return err;
-   } else if (res_locked(dev, RESOURCE_OVERLAY)) {
+   if (!fh  res_locked(dev, RESOURCE_OVERLAY)) {
/* Don't change the std from the mpeg device
   if overlay is active. */
return -EBUSY;
@@ -2050,11 +2032,7 @@ static int saa7134_s_tuner(struct file *file, void *priv,
 {
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh-dev;
-   int rx, mode, err;
-
-   err = v4l2_prio_check(dev-prio, fh-prio);
-   if (0 != err)
-   return err;
+   int rx, mode;
 
mode = dev-thread.mode;
if (UNSET == mode) {
@@ -2084,11 +2062,6 @@ static int saa7134_s_frequency(struct file *file, void 
*priv,
 {
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh-dev;
-   int err;
-
-   err = v4l2_prio_check(dev-prio, fh-prio);
-   if (0 != err)
-   return err;
 
if (0 != f-tuner)
return -EINVAL;
@@ -2117,24 +2090,6 @@ static int

[PATCH 4/8] saa7134: v4l2-compliance: return real frequency

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: don't cache frequency in
s_frequency/g_frequency but return real one instead

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |6 --
 drivers/media/pci/saa7134/saa7134.h   |1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index cd4959e..c8d3180 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2051,8 +2051,11 @@ static int saa7134_g_frequency(struct file *file, void 
*priv,
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh-dev;
 
+   if (0 != f-tuner)
+   return -EINVAL;
+
f-type = fh-radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
-   f-frequency = dev-ctl_freq;
+   saa_call_all(dev, tuner, g_frequency, f);
 
return 0;
 }
@@ -2070,7 +2073,6 @@ static int saa7134_s_frequency(struct file *file, void 
*priv,
if (1 == fh-radio  V4L2_TUNER_RADIO != f-type)
return -EINVAL;
mutex_lock(dev-lock);
-   dev-ctl_freq = f-frequency;
 
saa_call_all(dev, tuner, s_frequency, f);
 
diff --git a/drivers/media/pci/saa7134/saa7134.h 
b/drivers/media/pci/saa7134/saa7134.h
index 2ffe069..d0ee05e 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -604,7 +604,6 @@ struct saa7134_dev {
intctl_contrast;
intctl_hue;
intctl_saturation;
-   intctl_freq;
intctl_mute; /* audio */
intctl_volume;
intctl_invert;   /* private */
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/8] saa7134: v4l2-compliance: fix g_tuner/s_tuner

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: return real frequency range in
g_tuner and fail in s_tuner for non-zero tuner

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index c8d3180..3274994 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2014,11 +2014,11 @@ static int saa7134_g_tuner(struct file *file, void 
*priv,
if (NULL != card_in(dev, n).name) {
strcpy(t-name, Television);
t-type = V4L2_TUNER_ANALOG_TV;
+   saa_call_all(dev, tuner, g_tuner, t);
t-capability = V4L2_TUNER_CAP_NORM |
V4L2_TUNER_CAP_STEREO |
V4L2_TUNER_CAP_LANG1 |
V4L2_TUNER_CAP_LANG2;
-   t-rangehigh = 0xUL;
t-rxsubchans = saa7134_tvaudio_getstereo(dev);
t-audmode = saa7134_tvaudio_rx2mode(t-rxsubchans);
}
@@ -2034,6 +2034,9 @@ static int saa7134_s_tuner(struct file *file, void *priv,
struct saa7134_dev *dev = fh-dev;
int rx, mode;
 
+   if (0 != t-index)
+   return -EINVAL;
+
mode = dev-thread.mode;
if (UNSET == mode) {
rx   = saa7134_tvaudio_getstereo(dev);
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] saa7134: v4l2-compliance: remove bogus audio input support

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: remove empty g_audio and s_audio
functions and don't set audioset in enum_input

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |   30 -
 1 files changed, 0 insertions(+), 30 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 3274994..f7e6d5c 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1750,7 +1750,6 @@ static int saa7134_enum_input(struct file *file, void 
*priv,
strcpy(i-name, card_in(dev, n).name);
if (card_in(dev, n).tv)
i-type = V4L2_INPUT_TYPE_TUNER;
-   i-audioset = 1;
if (n == dev-ctl_input) {
int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
@@ -2084,17 +2083,6 @@ static int saa7134_s_frequency(struct file *file, void 
*priv,
return 0;
 }
 
-static int saa7134_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
-{
-   strcpy(a-name, audio);
-   return 0;
-}
-
-static int saa7134_s_audio(struct file *file, void *priv, const struct 
v4l2_audio *a)
-{
-   return 0;
-}
-
 static int saa7134_enum_fmt_vid_cap(struct file *file, void  *priv,
struct v4l2_fmtdesc *f)
 {
@@ -2335,20 +2323,6 @@ static int radio_g_input(struct file *filp, void *priv, 
unsigned int *i)
return 0;
 }
 
-static int radio_g_audio(struct file *file, void *priv,
-   struct v4l2_audio *a)
-{
-   memset(a, 0, sizeof(*a));
-   strcpy(a-name, Radio);
-   return 0;
-}
-
-static int radio_s_audio(struct file *file, void *priv,
-   const struct v4l2_audio *a)
-{
-   return 0;
-}
-
 static int radio_s_input(struct file *filp, void *priv, unsigned int i)
 {
return 0;
@@ -2399,8 +2373,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_g_fmt_vbi_cap   = saa7134_try_get_set_fmt_vbi_cap,
.vidioc_try_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
.vidioc_s_fmt_vbi_cap   = saa7134_try_get_set_fmt_vbi_cap,
-   .vidioc_g_audio = saa7134_g_audio,
-   .vidioc_s_audio = saa7134_s_audio,
.vidioc_cropcap = saa7134_cropcap,
.vidioc_reqbufs = saa7134_reqbufs,
.vidioc_querybuf= saa7134_querybuf,
@@ -2445,9 +2417,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_querycap= saa7134_querycap,
.vidioc_g_tuner = radio_g_tuner,
.vidioc_enum_input  = radio_enum_input,
-   .vidioc_g_audio = radio_g_audio,
.vidioc_s_tuner = radio_s_tuner,
-   .vidioc_s_audio = radio_s_audio,
.vidioc_s_input = radio_s_input,
.vidioc_s_std   = radio_s_std,
.vidioc_queryctrl   = radio_queryctrl,
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] saa7134: v4l2-compliance: remove bogus g_parm

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: remove empty g_parm function

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index f7e6d5c..8b4 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2237,12 +2237,6 @@ static int saa7134_streamoff(struct file *file, void 
*priv,
return 0;
 }
 
-static int saa7134_g_parm(struct file *file, void *fh,
-   struct v4l2_streamparm *parm)
-{
-   return 0;
-}
-
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static int vidioc_g_register (struct file *file, void *priv,
  struct v4l2_dbg_register *reg)
@@ -2395,7 +2389,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_g_fbuf  = saa7134_g_fbuf,
.vidioc_s_fbuf  = saa7134_s_fbuf,
.vidioc_overlay = saa7134_overlay,
-   .vidioc_g_parm  = saa7134_g_parm,
.vidioc_g_frequency = saa7134_g_frequency,
.vidioc_s_frequency = saa7134_s_frequency,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8] saa7134: v4l2-compliance: clear reserved part of VBI structure

2013-02-01 Thread Ondrej Zary
Make saa7134 driver more V4L2 compliant: clear reserved space of VBI
structure to make sure no garbage is left there

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-video.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 8b4..0b23fc8 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1552,6 +1552,7 @@ static int saa7134_try_get_set_fmt_vbi_cap(struct file 
*file, void *priv,
struct saa7134_dev *dev = fh-dev;
struct saa7134_tvnorm *norm = dev-tvnorm;
 
+   memset(f-fmt.vbi.reserved, 0, sizeof(f-fmt.vbi.reserved));
f-fmt.vbi.sampling_rate = 675 * 4;
f-fmt.vbi.samples_per_line = 2048 /* VBI_LINE_LENGTH */;
f-fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 0/7] saa7134: improve v4l2-compliance

2013-01-28 Thread Ondrej Zary
On Monday 28 January 2013 11:56:59 Hans Verkuil wrote:
 On Sun January 27 2013 20:45:05 Ondrej Zary wrote:
  Hello,
  this patch series improves v4l2-compliance of saa7134 driver. There are
  still some problems. Controls require conversion to control framework
  which I was unable to finish (because the driver accesses other controls
  and also the file handle from within s_ctrl).

 To convert to the control framework this driver needs quite a bit of work:
 the saa6752hs driver should be done first (and moved to media/i2c as well
 as it really doesn't belong here).

 The filehandle shouldn't be a problem, I think after the prio conversion
 that's no longer needed at all.

  Radio is now OK except for controls.
  Video has problems with controls, debugging, formats and buffers:
  Debug ioctls:
  test VIDIOC_DBG_G_CHIP_IDENT: OK (Not Supported)
  fail: v4l2-test-debug.cpp(84): doioctl(node,
  VIDIOC_DBG_G_CHIP_IDENT, chip) Format ioctls:
  test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
  fail: v4l2-test-formats.cpp(836): !cap-readbuffers

 That should be easy to fix. It's a pretty bogus field and I usually set it
 to the minimum number of buffers (which is 2 for this driver).

  test VIDIOC_G/S_PARM: FAIL
  fail: v4l2-test-formats.cpp(335): !fmt.width ||
  !fmt.height test VIDIOC_G_FBUF: FAIL
  fail: v4l2-test-formats.cpp(382): !pix.colorspace

 That's easy enough to solve. Typically this should be set to
 V4L2_COLORSPACE_SMPTE170M.

 But after solving this you'll probably get a bunch of other issues due to
 a problem this driver shared with quite a few other related drivers: the
 format state is stored in struct saa7134_fh instead of in the top-level
 struct. These format states are all global and should never have been
 placed in this struct.

Got this after setting colorspace:
   fail: v4l2-test-formats.cpp(460): win.field == V4L2_FIELD_ANY

I don't know what win.field is supposed to be and where the value should came 
from. It's now taken from fh-win which is probably all zeros because no 
overlay is running?
The same problem is with g_fbuf - what should fmt.width and fmt.height be?

 In fact if I look at the fields in saa7134_fh then:

 - radio and type can be removed (this info can be obtained from existing
 fields elsewhere)
 - the fields win until pt_vbi should all be global fields
 - I suspect resources and qos_request should also be global, but you would
 have to analyze that.

There are two resources variables - one in saa7134_fh and one in 
saa7134_dev. They're used for some kind of double-locking (global and per 
file handle).

 In fact, it is likely that the whole structure can be removed and only
 v4l2_fh be used instead.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] tda8290: Allow disabling I2C gate

2013-01-21 Thread Ondrej Zary
On Monday 21 January 2013, Antti Palosaari wrote:
 On 01/20/2013 11:22 PM, Ondrej Zary wrote:
  Allow disabling I2C gate handling by external configuration.
  This is required by cards that have all devices on a single I2C bus,
  like AverMedia A706.

 My personal opinion is that I2C gate control should be disabled setting
 callback to NULL (same for the other unwanted callbacks too). There is
 checks for callback existence in DVB-core, it does not call callback if
 it is NULL.

This is TDA8290 internal I2C gate which is used by tda8290 internally and also 
by tda827x or tda18271.


 regards
 Antti

  Signed-off-by: Ondrej Zary li...@rainbow-software.org
  ---
drivers/media/tuners/tda8290.c |   13 +++--
drivers/media/tuners/tda8290.h |1 +
2 files changed, 12 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/media/tuners/tda8290.c
  b/drivers/media/tuners/tda8290.c index 8c48521..16dfbf2 100644
  --- a/drivers/media/tuners/tda8290.c
  +++ b/drivers/media/tuners/tda8290.c
  @@ -54,6 +54,7 @@ struct tda8290_priv {
#define TDA18271 16
 
  struct tda827x_config cfg;
  +   bool no_i2c_gate;
};
 
   
  /*-*/
  @@ -66,6 +67,9 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe,
  int close) unsigned char disable[2] = { 0x21, 0x00 };
  unsigned char *msg;
 
  +   if (priv-no_i2c_gate)
  +   return 0;
  +
  if (close) {
  msg = enable;
  tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
  @@ -88,6 +92,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe,
  int close) unsigned char buf[3] = { 0x45, 0x01, 0x00 };
  unsigned char *msg;
 
  +   if (priv-no_i2c_gate)
  +   return 0;
  +
  if (close) {
  msg = enable;
  tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
  @@ -740,8 +747,10 @@ struct dvb_frontend *tda829x_attach(struct
  dvb_frontend *fe, priv-i2c_props.addr = i2c_addr;
  priv-i2c_props.adap = i2c_adap;
  priv-i2c_props.name = tda829x;
  -   if (cfg)
  -   priv-cfg.config = cfg-lna_cfg;
  +   if (cfg) {
  +   priv-cfg.config = cfg-lna_cfg;
  +   priv-no_i2c_gate = cfg-no_i2c_gate;
  +   }
 
  if (tda8290_probe(priv-i2c_props) == 0) {
  priv-ver = TDA8290;
  diff --git a/drivers/media/tuners/tda8290.h
  b/drivers/media/tuners/tda8290.h index 7e288b2..9959cc8 100644
  --- a/drivers/media/tuners/tda8290.h
  +++ b/drivers/media/tuners/tda8290.h
  @@ -26,6 +26,7 @@ struct tda829x_config {
  unsigned int probe_tuner:1;
#define TDA829X_PROBE_TUNER 0
#define TDA829X_DONT_PROBE  1
  +   unsigned int no_i2c_gate:1;
};
 
#if defined(CONFIG_MEDIA_TUNER_TDA8290) ||
  (defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE)  defined(MODULE))



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-01-20 Thread Ondrej Zary

Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.

This requires some changes to tda8290 - disabling I2C gate control and
passing custom std_map to tda18271.
Also tuner-core needs to be changed because there's currently no way to pass
any complex configuration to analog tuners.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] tda8290: Allow disabling I2C gate

2013-01-20 Thread Ondrej Zary
Allow disabling I2C gate handling by external configuration.
This is required by cards that have all devices on a single I2C bus,
like AverMedia A706.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/tuners/tda8290.c |   13 +++--
 drivers/media/tuners/tda8290.h |1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c48521..16dfbf2 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -54,6 +54,7 @@ struct tda8290_priv {
 #define TDA18271 16
 
struct tda827x_config cfg;
+   bool no_i2c_gate;
 };
 
 /*-*/
@@ -66,6 +67,9 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char disable[2] = { 0x21, 0x00 };
unsigned char *msg;
 
+   if (priv-no_i2c_gate)
+   return 0;
+
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -88,6 +92,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char buf[3] = { 0x45, 0x01, 0x00 };
unsigned char *msg;
 
+   if (priv-no_i2c_gate)
+   return 0;
+
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -740,8 +747,10 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend 
*fe,
priv-i2c_props.addr = i2c_addr;
priv-i2c_props.adap = i2c_adap;
priv-i2c_props.name = tda829x;
-   if (cfg)
-   priv-cfg.config = cfg-lna_cfg;
+   if (cfg) {
+   priv-cfg.config = cfg-lna_cfg;
+   priv-no_i2c_gate = cfg-no_i2c_gate;
+   }
 
if (tda8290_probe(priv-i2c_props) == 0) {
priv-ver = TDA8290;
diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
index 7e288b2..9959cc8 100644
--- a/drivers/media/tuners/tda8290.h
+++ b/drivers/media/tuners/tda8290.h
@@ -26,6 +26,7 @@ struct tda829x_config {
unsigned int probe_tuner:1;
 #define TDA829X_PROBE_TUNER 0
 #define TDA829X_DONT_PROBE  1
+   unsigned int no_i2c_gate:1;
 };
 
 #if defined(CONFIG_MEDIA_TUNER_TDA8290) || 
(defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE)  defined(MODULE))
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] tda8290: Allow custom std_map for tda18271

2013-01-20 Thread Ondrej Zary
Allow specifying a custom std_map for tda18271 by external configuration.
This is required by cards that require custom std_map for analog TV or radio,
like AverMedia A706.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/tuners/tda8290.c |3 +++
 drivers/media/tuners/tda8290.h |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 16dfbf2..45fdb46 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -55,6 +55,7 @@ struct tda8290_priv {
 
struct tda827x_config cfg;
bool no_i2c_gate;
+   struct tda18271_std_map *tda18271_std_map;
 };
 
 /*-*/
@@ -637,6 +638,7 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
if ((data == 0x83) || (data == 0x84)) {
priv-ver |= TDA18271;
tda829x_tda18271_config.config = priv-cfg.config;
+   tda829x_tda18271_config.std_map = priv-tda18271_std_map;
dvb_attach(tda18271_attach, fe, priv-tda827x_addr,
   priv-i2c_props.adap, tda829x_tda18271_config);
} else {
@@ -750,6 +752,7 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
if (cfg) {
priv-cfg.config = cfg-lna_cfg;
priv-no_i2c_gate = cfg-no_i2c_gate;
+   priv-tda18271_std_map = cfg-tda18271_std_map;
}
 
if (tda8290_probe(priv-i2c_props) == 0) {
diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
index 9959cc8..280b70d 100644
--- a/drivers/media/tuners/tda8290.h
+++ b/drivers/media/tuners/tda8290.h
@@ -19,6 +19,7 @@
 
 #include linux/i2c.h
 #include dvb_frontend.h
+#include tda18271.h
 
 struct tda829x_config {
unsigned int lna_cfg;
@@ -27,6 +28,7 @@ struct tda829x_config {
 #define TDA829X_PROBE_TUNER 0
 #define TDA829X_DONT_PROBE  1
unsigned int no_i2c_gate:1;
+   struct tda18271_std_map *tda18271_std_map;
 };
 
 #if defined(CONFIG_MEDIA_TUNER_TDA8290) || 
(defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE)  defined(MODULE))
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] tuner-core: Change config from unsigned int to void *

2013-01-20 Thread Ondrej Zary
config looks like a hack that was added to tuner-core to allow some
configuration of TDA8290 tuner (it's not used by any other driver).
But with the new configuration options of tda8290 driver (no_i2c_gate
and std_map), it's no longer sufficient.

Change config to be void * instead, which allows passing tuner-dependent
config struct to drivers.

Also update saa7134 driver to reflect this change (no other driver uses this).

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/pci/saa7134/saa7134-cards.c |   40 ++--
 drivers/media/pci/saa7134/saa7134.h   |3 +-
 drivers/media/v4l2-core/tuner-core.c  |   20 +-
 include/media/tuner.h |2 +-
 4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index bc08f1d..fe54f88 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -2760,7 +2760,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 0,
+   .tda829x_conf   = { .lna_cfg = 0 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3291,7 +3291,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 1,
+   .tda829x_conf   = { .lna_cfg = 1 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x00020,
.inputs = {{
@@ -3395,7 +3395,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 1,
+   .tda829x_conf   = { .lna_cfg = 1 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x0200100,
.inputs = {{
@@ -3426,7 +3426,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 3,
+   .tda829x_conf   = { .lna_cfg = 3 },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.ts_force_val   = 1,
@@ -3459,7 +3459,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 3,
+   .tda829x_conf   = { .lna_cfg = 3 },
.mpeg   = SAA7134_MPEG_DVB,
.ts_type= SAA7134_MPEG_TS_SERIAL,
.gpiomask   = 0x0800100, /* GPIO 21 is an INPUT */
@@ -3683,7 +3683,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3736,7 +3736,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.mpeg   = SAA7134_MPEG_DVB,
.gpiomask   = 0x020,
.inputs = {{
@@ -3754,7 +3754,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 2,
+   .tda829x_conf   = { .lna_cfg = 2 },
.gpiomask   = 1  21,
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
@@ -3887,7 +3887,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
-   .tuner_config   = 0,
+   .tda829x_conf   = { .lna_cfg = 0 },
.mpeg   = SAA7134_MPEG_DVB,
.inputs = {{
.name   = name_tv, /* FIXME: analog tv untested */
@@ -3903,7 +3903,7 @@ struct saa7134_board saa7134_boards[] = {
.radio_type = UNSET,
.tuner_addr

[PATCH 4/4] saa7134: Add AverMedia A706 AverTV Satellite Hybrid+FM

2013-01-20 Thread Ondrej Zary
Add AverMedia AverTV Satellite Hybrid+FM (A706) card to saa7134 driver.
Working: analog inputs, TV, FM radio and IR remote control.
Untested: DVB-S.

Signed-off-by: Ondrej Zary li...@rainbow-software.org
---
 drivers/media/i2c/ir-kbd-i2c.c  |   13 ++-
 drivers/media/pci/saa7134/saa7134-cards.c   |   53 +++
 drivers/media/pci/saa7134/saa7134-dvb.c |   22 +++
 drivers/media/pci/saa7134/saa7134-i2c.c |1 +
 drivers/media/pci/saa7134/saa7134-input.c   |3 ++
 drivers/media/pci/saa7134/saa7134-tvaudio.c |1 +
 drivers/media/pci/saa7134/saa7134.h |1 +
 7 files changed, 93 insertions(+), 1 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 08ae067..c1f6e7c 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -230,7 +230,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
return 0;
 
dprintk(1, read key 0x%02x/0x%02x\n, key, keygroup);
-   if (keygroup  2 || keygroup  3) {
+   if (keygroup  2 || keygroup  4) {
/* Only a warning */
dprintk(1, warning: invalid key group 0x%02x for key 0x%02x\n,
keygroup, key);
@@ -239,6 +239,10 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
 
*ir_key = key;
*ir_raw = key;
+   if (!strcmp(ir-ir_codes, RC_MAP_AVERMEDIA_M733A_RM_K6)) {
+   *ir_key |= keygroup  8;
+   *ir_raw |= keygroup  8;
+   }
return 1;
 }
 
@@ -332,6 +336,13 @@ static int ir_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
rc_type = RC_BIT_OTHER;
ir_codes= RC_MAP_AVERMEDIA_CARDBUS;
break;
+   case 0x41:
+   name= AVerMedia EM78P153;
+   ir-get_key = get_key_avermedia_cardbus;
+   rc_type = RC_BIT_OTHER;
+   /* RM-KV remote, seems to be same as RM-K6 */
+   ir_codes= RC_MAP_AVERMEDIA_M733A_RM_K6;
+   break;
case 0x71:
name= Hauppauge/Zilog Z8;
ir-get_key = get_key_haup_xvr;
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c
index fe54f88..c603064 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -50,6 +50,11 @@ static char name_svideo[]  = S-Video;
 /* -- */
 /* board config info  */
 
+static struct tda18271_std_map aver_a706_std_map = {
+   .fm_radio = { .if_freq = 5500, .fm_rfn = 0, .agc_mode = 3, .std = 0,
+ .if_lvl = 0, .rfagc_top = 0x2c, },
+};
+
 /* If radio_type !=UNSET, radio_addr should be specified
  */
 
@@ -5773,6 +5778,37 @@ struct saa7134_board saa7134_boards[] = {
.gpio   = 0x000,
},
},
+   [SAA7134_BOARD_AVERMEDIA_A706] = {
+   .name   = AverMedia AverTV Satellite Hybrid+FM A706,
+   .audio_clock= 0x00187de7,
+   .tuner_type = TUNER_PHILIPS_TDA8290,
+   .radio_type = UNSET,
+   .tuner_addr = ADDR_UNSET,
+   .radio_addr = ADDR_UNSET,
+   .tda829x_conf   = { .lna_cfg = 0, .no_i2c_gate = 1,
+   .tda18271_std_map = aver_a706_std_map },
+   .gpiomask   = 1  11,
+   .mpeg   = SAA7134_MPEG_DVB,
+   .inputs = {{
+   .name = name_tv,
+   .vmux = 1,
+   .amux = TV,
+   .tv   = 1,
+   }, {
+   .name = name_comp,
+   .vmux = 4,
+   .amux = LINE1,
+   }, {
+   .name = name_svideo,
+   .vmux = 8,
+   .amux = LINE1,
+   } },
+   .radio = {
+   .name = name_radio,
+   .amux = TV,
+   .gpio = 0x800,
+   },
+   },
 
 };
 
@@ -7020,6 +7056,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice= 0x0911,
.driver_data  = SAA7134_BOARD_SENSORAY811_911,
}, {
+   .vendor   = PCI_VENDOR_ID_PHILIPS,
+   .device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+   .subvendor= 0x1461, /* Avermedia Technologies Inc */
+   .subdevice= 0x2055, /* AverTV Satellite Hybrid+FM A706 */
+   .driver_data  = SAA7134_BOARD_AVERMEDIA_A706,
+   }, {
/* --- boards without eeprom + subsystem ID --- */
.vendor

Re: [RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-17 Thread Ondrej Zary
On Tuesday 15 January 2013 23:37:58 Ondrej Zary wrote:
 On Tuesday 15 January 2013 22:57:06 Ondrej Zary wrote:
  On Monday 14 January 2013 22:29:58 Ondrej Zary wrote:
   On Saturday 12 January 2013 21:24:50 Ondrej Zary wrote:
Partially working: FM radio
Radio seems to be a long-standing problem with saa7134 cards using
silicon tuners (according to various mailing lists).
   
On this card, GPIO11 controls 74HC4052 MUX. It switches two things:
something at TDA18271 V_IFAGC pin and something that goes to
SAA7131E. GPIO11 is enabled for radio and disabled for TV in Windows.
I did the same thing in this patch.
   
Windows INF file says:
; Setting FM radio of the Silicon tuner via SIF (GPIO 21 in use/
5.5MHz) HKR, Audio, FM Radio IF, 0x00010001, 0xDEEAAB
   
But that seems not to be true. GPIO21 does nothing and RegSpy (from
DScaler, modified to include 0x42c register) says that the register
is 0x80729555. That matches the value present in saa7134-tvaudio.c
(except the first 0x80).
   
With this value, the radio stations are off by about 4.2-4.3 MHz,
e.g.: station at 97.90 MHz is tuned as 102.20 MHz
station at 101.80 MHz is tuned as 106.0 MHz
   
I also tried 0xDEEAAB. With this, the offset is different, about 0.4
MHz: station at 101.80 MHz is tuned as 102.2 MHz
  
   The offset seems bogus, maybe affected by my TV antenna (cable).
  
   For debugging, tried another card with similar chips: Pinnacle PCTV
   40i/50i/110i. It has SAA7131E chip too, but different tuner - TDA8275A.
   And the radio problem is the same as found first on the A706 - the
   tuned station sound starts but then turns into noise. So it seems that
   the problem is not in tda18271 but in tda8290 or saa7134.
  
   With tda8290.debug=1, I see this:
   tda829x 2-004b: tda8290 not locked, no signal?
   tda829x 2-004b: tda8290 not locked, no signal?
   tda829x 2-004b: tda8290 not locked, no signal?
   tda829x 2-004b: adjust gain, step 1. Agc: 193, ADC stat: 255, lock: 0
   tda829x 2-004b: adjust gain, step 2. Agc: 255, lock: 0
   tda829x 2-004b: adjust gain, step 3. Agc: 173
  
   During that, the sound is good. Then it turns into noise.
   When I increased the number of lock detections in tda8290_set_params()
   from 3 to (e.g.) 10, it works longer. And when I'm quick enough to stop
   the console output using scroll lock, the radio remains working.
 
  Pinnacle radio problems turned out to be a different bug - the driver
  turns off tuners when the radio device is closed - and I was testing
  using v4l2-ctl. Fixing that allows Pinnacle to work fine.
 
  But it's not enough for A706 to work. When I disable gain adjust in
  tda8290 (by putting a return before), strong stations work somehow (with
  noise).

 Changing IF frequency from 1.25MHz (1250) to 5.5MHz (5500) in
 tda18271-maps.c allows the radio to work without disabling gain adjust.
 Seems that IF mismatch between tda18271 and saa7134 is causing problems.
 However, only strong stations work.

Got it finally! With .if_freq=5500 and .fm_rfn=0, the radio works perfectly. 
Now only to find a way how to set a custom std_map...

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-15 Thread Ondrej Zary
On Monday 14 January 2013 22:29:58 Ondrej Zary wrote:
 On Saturday 12 January 2013 21:24:50 Ondrej Zary wrote:
  Partially working: FM radio
  Radio seems to be a long-standing problem with saa7134 cards using
  silicon tuners (according to various mailing lists).
 
  On this card, GPIO11 controls 74HC4052 MUX. It switches two things:
  something at TDA18271 V_IFAGC pin and something that goes to SAA7131E.
  GPIO11 is enabled for radio and disabled for TV in Windows. I did the
  same thing in this patch.
 
  Windows INF file says:
  ; Setting FM radio of the Silicon tuner via SIF (GPIO 21 in use/ 5.5MHz)
  HKR, Audio, FM Radio IF, 0x00010001, 0xDEEAAB
 
  But that seems not to be true. GPIO21 does nothing and RegSpy (from
  DScaler, modified to include 0x42c register) says that the register is
  0x80729555. That matches the value present in saa7134-tvaudio.c (except
  the first 0x80).
 
  With this value, the radio stations are off by about 4.2-4.3 MHz, e.g.:
  station at 97.90 MHz is tuned as 102.20 MHz
  station at 101.80 MHz is tuned as 106.0 MHz
 
  I also tried 0xDEEAAB. With this, the offset is different, about 0.4 MHz:
  station at 101.80 MHz is tuned as 102.2 MHz

 The offset seems bogus, maybe affected by my TV antenna (cable).

 For debugging, tried another card with similar chips: Pinnacle PCTV
 40i/50i/110i. It has SAA7131E chip too, but different tuner - TDA8275A. And
 the radio problem is the same as found first on the A706 - the tuned
 station sound starts but then turns into noise. So it seems that the
 problem is not in tda18271 but in tda8290 or saa7134.

 With tda8290.debug=1, I see this:
 tda829x 2-004b: tda8290 not locked, no signal?
 tda829x 2-004b: tda8290 not locked, no signal?
 tda829x 2-004b: tda8290 not locked, no signal?
 tda829x 2-004b: adjust gain, step 1. Agc: 193, ADC stat: 255, lock: 0
 tda829x 2-004b: adjust gain, step 2. Agc: 255, lock: 0
 tda829x 2-004b: adjust gain, step 3. Agc: 173

 During that, the sound is good. Then it turns into noise.
 When I increased the number of lock detections in tda8290_set_params() from
 3 to (e.g.) 10, it works longer. And when I'm quick enough to stop the
 console output using scroll lock, the radio remains working.

Pinnacle radio problems turned out to be a different bug - the driver turns 
off tuners when the radio device is closed - and I was testing using 
v4l2-ctl. Fixing that allows Pinnacle to work fine.

But it's not enough for A706 to work. When I disable gain adjust in tda8290 
(by putting a return before), strong stations work somehow (with noise).

  And what's worst, connecting analog TV antenna (cable TV) affects the
  radio tuner! E.g. the radio is tuned to 106.0 MHz (real 101.80 MHz) with
  nice clean sound. Connecting TV antenna adds strong noise to the sound,
  tuning does not help. This problem is not present in Windows.

 I've found a tiny chip marked S79 near the analog tuner. It's Skyworks
 AS179-92LF antenna switch that switches either the TV or FM antenna to the
 TDA18271 FM_IN pin! That's why TV antenna affected the radio. The switch is
 probably controlled by some other GPIO pin (haven't tested this yet).
 What's the best way to expose this switch to userspace?

This switch is controlled by GPIO12 (use TV antenna for radio) and GPIO13 (use 
FM antenna for radio). However, both these pins are tri-stated in Windows - 
voltage is about 2.2V then, enabling both antennas.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-15 Thread Ondrej Zary
On Tuesday 15 January 2013 22:57:06 Ondrej Zary wrote:
 On Monday 14 January 2013 22:29:58 Ondrej Zary wrote:
  On Saturday 12 January 2013 21:24:50 Ondrej Zary wrote:
   Partially working: FM radio
   Radio seems to be a long-standing problem with saa7134 cards using
   silicon tuners (according to various mailing lists).
  
   On this card, GPIO11 controls 74HC4052 MUX. It switches two things:
   something at TDA18271 V_IFAGC pin and something that goes to SAA7131E.
   GPIO11 is enabled for radio and disabled for TV in Windows. I did the
   same thing in this patch.
  
   Windows INF file says:
   ; Setting FM radio of the Silicon tuner via SIF (GPIO 21 in use/
   5.5MHz) HKR, Audio, FM Radio IF, 0x00010001, 0xDEEAAB
  
   But that seems not to be true. GPIO21 does nothing and RegSpy (from
   DScaler, modified to include 0x42c register) says that the register is
   0x80729555. That matches the value present in saa7134-tvaudio.c (except
   the first 0x80).
  
   With this value, the radio stations are off by about 4.2-4.3 MHz, e.g.:
   station at 97.90 MHz is tuned as 102.20 MHz
   station at 101.80 MHz is tuned as 106.0 MHz
  
   I also tried 0xDEEAAB. With this, the offset is different, about 0.4
   MHz: station at 101.80 MHz is tuned as 102.2 MHz
 
  The offset seems bogus, maybe affected by my TV antenna (cable).
 
  For debugging, tried another card with similar chips: Pinnacle PCTV
  40i/50i/110i. It has SAA7131E chip too, but different tuner - TDA8275A.
  And the radio problem is the same as found first on the A706 - the tuned
  station sound starts but then turns into noise. So it seems that the
  problem is not in tda18271 but in tda8290 or saa7134.
 
  With tda8290.debug=1, I see this:
  tda829x 2-004b: tda8290 not locked, no signal?
  tda829x 2-004b: tda8290 not locked, no signal?
  tda829x 2-004b: tda8290 not locked, no signal?
  tda829x 2-004b: adjust gain, step 1. Agc: 193, ADC stat: 255, lock: 0
  tda829x 2-004b: adjust gain, step 2. Agc: 255, lock: 0
  tda829x 2-004b: adjust gain, step 3. Agc: 173
 
  During that, the sound is good. Then it turns into noise.
  When I increased the number of lock detections in tda8290_set_params()
  from 3 to (e.g.) 10, it works longer. And when I'm quick enough to stop
  the console output using scroll lock, the radio remains working.

 Pinnacle radio problems turned out to be a different bug - the driver turns
 off tuners when the radio device is closed - and I was testing using
 v4l2-ctl. Fixing that allows Pinnacle to work fine.

 But it's not enough for A706 to work. When I disable gain adjust in tda8290
 (by putting a return before), strong stations work somehow (with noise).

Changing IF frequency from 1.25MHz (1250) to 5.5MHz (5500) in tda18271-maps.c 
allows the radio to work without disabling gain adjust. Seems that IF 
mismatch between tda18271 and saa7134 is causing problems. However, only 
strong stations work.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-14 Thread Ondrej Zary
On Saturday 12 January 2013 21:24:50 Ondrej Zary wrote:
 Partially working: FM radio
 Radio seems to be a long-standing problem with saa7134 cards using silicon
 tuners (according to various mailing lists).

 On this card, GPIO11 controls 74HC4052 MUX. It switches two things:
 something at TDA18271 V_IFAGC pin and something that goes to SAA7131E.
 GPIO11 is enabled for radio and disabled for TV in Windows. I did the same
 thing in this patch.

 Windows INF file says:
 ; Setting FM radio of the Silicon tuner via SIF (GPIO 21 in use/ 5.5MHz)
 HKR, Audio, FM Radio IF, 0x00010001, 0xDEEAAB

 But that seems not to be true. GPIO21 does nothing and RegSpy (from
 DScaler, modified to include 0x42c register) says that the register is
 0x80729555. That matches the value present in saa7134-tvaudio.c (except the
 first 0x80).

 With this value, the radio stations are off by about 4.2-4.3 MHz, e.g.:
 station at 97.90 MHz is tuned as 102.20 MHz
 station at 101.80 MHz is tuned as 106.0 MHz

 I also tried 0xDEEAAB. With this, the offset is different, about 0.4 MHz:
 station at 101.80 MHz is tuned as 102.2 MHz

The offset seems bogus, maybe affected by my TV antenna (cable).

For debugging, tried another card with similar chips: Pinnacle PCTV 
40i/50i/110i. It has SAA7131E chip too, but different tuner - TDA8275A. And 
the radio problem is the same as found first on the A706 - the tuned station 
sound starts but then turns into noise. So it seems that the problem is not 
in tda18271 but in tda8290 or saa7134.

With tda8290.debug=1, I see this:
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: adjust gain, step 1. Agc: 193, ADC stat: 255, lock: 0
tda829x 2-004b: adjust gain, step 2. Agc: 255, lock: 0
tda829x 2-004b: adjust gain, step 3. Agc: 173

During that, the sound is good. Then it turns into noise.
When I increased the number of lock detections in tda8290_set_params() from 3 
to (e.g.) 10, it works longer. And when I'm quick enough to stop the console 
output using scroll lock, the radio remains working.

 And what's worst, connecting analog TV antenna (cable TV) affects the radio
 tuner! E.g. the radio is tuned to 106.0 MHz (real 101.80 MHz) with nice
 clean sound. Connecting TV antenna adds strong noise to the sound, tuning
 does not help. This problem is not present in Windows.

I've found a tiny chip marked S79 near the analog tuner. It's Skyworks 
AS179-92LF antenna switch that switches either the TV or FM antenna to the 
TDA18271 FM_IN pin! That's why TV antenna affected the radio. The switch is 
probably controlled by some other GPIO pin (haven't tested this yet). What's 
the best way to expose this switch to userspace?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-12 Thread Ondrej Zary
/saa7134/saa7134-input.c
index e761262..6f43126 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -997,6 +997,9 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
info.addr = 0x40;
break;
+   case SAA7134_BOARD_AVERMEDIA_A706:
+   info.addr = 0x41;
+   break;
case SAA7134_BOARD_FLYDVB_TRIO:
dev-init_data.name = FlyDVB Trio;
dev-init_data.get_key = get_key_flydvb_trio;
diff --git a/drivers/media/pci/saa7134/saa7134.h 
b/drivers/media/pci/saa7134/saa7134.h
index c24b651..6cef84d 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -332,6 +332,7 @@ struct saa7134_card_ir {
 #define SAA7134_BOARD_SENSORAY811_911   188
 #define SAA7134_BOARD_KWORLD_PC150U 189
 #define SAA7134_BOARD_ASUSTeK_PS3_100  190
+#define SAA7134_BOARD_AVERMEDIA_A706   191
 
 #define SAA7134_MAXBOARDS 32
 #define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c48521..bf5c7df 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -54,6 +54,7 @@ struct tda8290_priv {
 #define TDA18271 16
 
struct tda827x_config cfg;
+   bool no_i2c_gate;
 };
 
 /*-*/
@@ -66,6 +67,9 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char disable[2] = { 0x21, 0x00 };
unsigned char *msg;
 
+   if (priv-no_i2c_gate)
+   return 0;
+
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -88,6 +92,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char buf[3] = { 0x45, 0x01, 0x00 };
unsigned char *msg;
 
+   if (priv-no_i2c_gate)
+   return 0;
+
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -740,8 +747,12 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend 
*fe,
priv-i2c_props.addr = i2c_addr;
priv-i2c_props.adap = i2c_adap;
priv-i2c_props.name = tda829x;
-   if (cfg)
-   priv-cfg.config = cfg-lna_cfg;
+   if (cfg) {
+   if (cfg-lna_cfg  TDA829X_NO_I2C_GATE)
+   priv-no_i2c_gate = true;
+   priv-cfg.config = cfg-lna_cfg  TDA829X_CFG_MASK;
+   printk(cfg.config=%d\n, priv-cfg.config);
+   }
 
if (tda8290_probe(priv-i2c_props) == 0) {
priv-ver = TDA8290;
diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
index 7e288b2..e300f4c 100644
--- a/drivers/media/tuners/tda8290.h
+++ b/drivers/media/tuners/tda8290.h
@@ -20,6 +20,9 @@
 #include linux/i2c.h
 #include dvb_frontend.h
 
+#define TDA829X_NO_I2C_GATE(1  7)
+#define TDA829X_CFG_MASK   (~TDA829X_NO_I2C_GATE)
+
 struct tda829x_config {
unsigned int lna_cfg;
 


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BAD PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706

2013-01-10 Thread Ondrej Zary
 SAA7134_BOARD_FLYDVB_TRIO:
dev-init_data.name = FlyDVB Trio;
dev-init_data.get_key = get_key_flydvb_trio;
diff --git a/drivers/media/pci/saa7134/saa7134.h 
b/drivers/media/pci/saa7134/saa7134.h
index c24b651..6cef84d 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -332,6 +332,7 @@ struct saa7134_card_ir {
 #define SAA7134_BOARD_SENSORAY811_911   188
 #define SAA7134_BOARD_KWORLD_PC150U 189
 #define SAA7134_BOARD_ASUSTeK_PS3_100  190
+#define SAA7134_BOARD_AVERMEDIA_A706   191
 
 #define SAA7134_MAXBOARDS 32
 #define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c48521..7234428 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -65,7 +65,7 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char  enable[2] = { 0x21, 0xC0 };
unsigned char disable[2] = { 0x21, 0x00 };
unsigned char *msg;
-
+return 0;
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -87,7 +87,7 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int 
close)
unsigned char disable[2] = { 0x46, 0x00 };
unsigned char buf[3] = { 0x45, 0x01, 0x00 };
unsigned char *msg;
-
+return 0;
if (close) {
msg = enable;
tuner_i2c_xfer_send(priv-i2c_props, msg, 2);
@@ -731,7 +731,7 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
 {
struct tda8290_priv *priv = NULL;
char *name;
-
+   printk(%s, fe=%p, i2c_adap=%p, i2c_addr=0x%02x, cfg=%p\n, 
__FUNCTION__, fe, i2c_adap, i2c_addr, cfg);
priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
if (priv == NULL)
return NULL;


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: AverMedia Satelllite Hybrid+FM A706

2012-12-21 Thread Ondrej Zary
Update 2:
all I2C breakage is caused by i2c gates in CE6313 and TDA8290 so I just
commented-out the calls in tuner drivers for now.
Tuner detection in tda8290 breaks because it finds CE5039 at 0x60. Disabling
CE5039 using GPIO in board_init1() and enabling it in dvb_init() allows all
chips to initialize properly:

[  130.658813] saa7130/34: v4l2 driver version 0, 2, 17 loaded
[  130.662715] saa7133[0]: found at :02:01.0, rev: 209, irq: 9, latency: 
32, mmio: 0xf400
[  130.665879] saa7133[0]: subsystem: 1461:2055, board: AverMedia AverTV 
Satellite Hybrid+FM A706 [card=191,autodetected]
[  130.669347] saa7133[0]: board init: gpio is 3500
[  130.822347] saa7133[0]: i2c eeprom 00: 61 14 55 20 00 00 00 00 00 00 00 00 
00 00 00 00
[  130.825689] saa7133[0]: i2c eeprom 10: ff ff ff ff ff 20 ff ff ff ff ff ff 
ff ff ff ff
[  130.829008] saa7133[0]: i2c eeprom 20: 02 40 01 02 02 01 01 04 06 ff 00 57 
ff ff ff ff
[  130.832317] saa7133[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.835627] saa7133[0]: i2c eeprom 40: 60 a0 00 c6 96 ff 05 30 8b 05 ff 40 
ff ff ff ff
[  130.838932] saa7133[0]: i2c eeprom 50: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.84] saa7133[0]: i2c eeprom 60: ff 89 00 c0 ff 1c 08 19 97 89 ff ff 
80 15 0a ff
[  130.845525] saa7133[0]: i2c eeprom 70: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.848833] saa7133[0]: i2c eeprom 80: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.852109] saa7133[0]: i2c eeprom 90: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.855351] saa7133[0]: i2c eeprom a0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.858565] saa7133[0]: i2c eeprom b0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.861736] saa7133[0]: i2c eeprom c0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.864894] saa7133[0]: i2c eeprom d0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.868021] saa7133[0]: i2c eeprom e0: 00 01 81 b0 65 07 ff ff ff ff ff ff 
ff ff ff ff
[  130.871133] saa7133[0]: i2c eeprom f0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[  130.930349] tuner 2-004b: Tuner -1 found with type(s) Radio TV.
[  130.974345] tda829x 2-004b: setting tuner address to 63
[  131.019535] tda18271 2-0063: creating new instance
[  131.030345] TDA18271HD/C2 detected @ 2-0063
[  131.454335] tda18271: performing RF tracking filter calibration
[  135.778283] tda18271: RF tracking filter calibration complete
[  135.786296] tda829x 2-004b: type set to tda8290+18271
[  138.635047] saa7133[0]: registered device video0 [v4l2]
[  138.639407] saa7133[0]: registered device vbi0
[  138.643130] saa7133[0]: registered device radio0
[  138.676190] dvb_init() allocating 1 frontend
[  139.730238] DVB: registering new adapter (saa7133[0])
[  139.733196] saa7134 :02:01.0: DVB: registering adapter 0 frontend 0 
(Zarlink ZL10313 DVB-S)...
[  140.321583] saa7134 ALSA driver for DMA sound loaded
[  140.325361] saa7133[0]/alsa: saa7133[0] at 0xf400 irq 9 registered as 
card -1

The card comes to life slowly: FM radio works for a couple of seconds!
With arecord | aplay, noise is played. When a radio station is tuned
(v4l2ctl -d /dev/radio0 -f something), I can hear it clearly for a 2-3 seconds,
then it fades to noise.

These errors appear in log:
[  521.281639] tda18271c2_rf_tracking_filters_correction: [2-0063|M] error -22 
on line 277
[  521.289675] tda18271_calc_ir_measure: [2-0063|M] error -34 on line 686
[  521.289682] tda18271_calc_bp_filter: [2-0063|M] error -34 on line 618
[  521.289686] tda18271_calc_rf_band: [2-0063|M] error -34 on line 652
[  521.289690] tda18271_calc_gain_taper: [2-0063|M] error -34 on line 669


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: AverMedia Satelllite Hybrid+FM A706

2012-12-20 Thread Ondrej Zary
Update:
GPIO 9 is CE6313 SLEEP signal
GPIO 23 is CE5039 SLEEP signal
GPIO 25 is CE6313 RESET# signal - this one needs to be set high for CE6313 to 
appear on I2C bus

But there is a problem with CE5039 (zl10039) - the I2C bus breaks during its 
initialization (SDA stuck low):

Here it works (communication with CE6313):
[  921.556682] start xfer
[  921.556684] send address
[  921.556687] saa7133[0]: i2c data = 0x1c
[  921.556690] saa7133[0]: i2c stat = BUSY
[  921.556725] saa7133[0]: i2c stat = BUSY
[  921.556759] saa7133[0]: i2c stat = BUSY
[  921.556794] saa7133[0]: i2c stat = BUSY
[  921.556828] saa7133[0]: i2c stat = DONE_WRITE
[  921.556831] saa7133[0]: i2c stat = DONE_WRITE
[  921.556833] write bytes
[  921.556836] saa7133[0]: i2c data = 0x14
[  921.556838] saa7133[0]: i2c stat = BUSY
[  921.556873] saa7133[0]: i2c stat = BUSY
[  921.556907] saa7133[0]: i2c stat = BUSY
[  921.556942] saa7133[0]: i2c stat = DONE_WRITE
[  921.556945] saa7133[0]: i2c stat = DONE_WRITE
[  921.556948] saa7133[0]: i2c data = 0x40
[  921.556950] saa7133[0]: i2c stat = BUSY
[  921.556985] saa7133[0]: i2c stat = BUSY
[  921.557019] saa7133[0]: i2c stat = BUSY
[  921.557054] saa7133[0]: i2c stat = DONE_WRITE
[  921.557057] saa7133[0]: i2c stat = DONE_WRITE
[  921.557058] xfer done
[  921.557060] saa7133[0]: i2c attr = STOP
[  921.557064] saa7133[0]: i2c stat = BUSY
[  921.557098] saa7133[0]: i2c stat = DONE_STOP
[  921.557101] saa7133[0]: i2c stat = DONE_STOP

Here starts CE5039 communication:
[  921.564672] zl10039_read
[  921.564677] saa7133[0]: i2c stat = DONE_STOP
[  921.564679] start xfer
[  921.564681] send address
[  921.564684] saa7133[0]: i2c data = 0xc0
[  921.564686] saa7133[0]: i2c stat = BUSY
[  921.564721] saa7133[0]: i2c stat = BUSY
[  921.564755] saa7133[0]: i2c stat = BUSY
[  921.564790] saa7133[0]: i2c stat = BUSY

And here it breaks:
[  921.564824] saa7133[0]: i2c stat = ARB_LOST
[  921.564827] saa7133[0]: i2c stat = ARB_LOST
[  921.564829] zl10039_read: i2c read error
[  921.564833] saa7133[0]: i2c stat = ARB_LOST
[  921.564834] saa7133[0]: i2c reset
[  921.564837] saa7133[0]: i2c stat = ARB_LOST
[  921.564839] saa7133[0]: i2c stat = ARB_LOST
[  921.564843] saa7133[0]: i2c stat = ARB_LOST
[  921.564877] saa7133[0]: i2c stat = IDLE
[  921.564879] saa7133[0]: i2c attr = NOP

And everything is broken now (until reloading saa7134 module):
[  921.564882] start xfer
[  921.564883] send address
[  921.564886] saa7133[0]: i2c data = 0x1c
[  921.564889] saa7133[0]: i2c stat = BUSY
[  921.564923] saa7133[0]: i2c stat = BUSY
[  921.564958] saa7133[0]: i2c stat = BUSY
[  921.564992] saa7133[0]: i2c stat = BUSY
[  921.565026] saa7133[0]: i2c stat = BUSY
[  921.565061] saa7133[0]: i2c stat = BUSY
[  921.565095] saa7133[0]: i2c stat = BUSY
[  921.565130] saa7133[0]: i2c stat = BUSY
[  921.565164] saa7133[0]: i2c stat = BUSY
[  921.565199] saa7133[0]: i2c stat = BUSY
[  921.565233] saa7133[0]: i2c stat = BUSY
[  921.565268] saa7133[0]: i2c stat = BUSY
[  921.565302] saa7133[0]: i2c stat = BUSY
[  921.565336] saa7133[0]: i2c stat = BUSY
[  921.565371] saa7133[0]: i2c stat = BUSY
[  921.565405] saa7133[0]: i2c stat = BUSY
[  921.565440] mt312_read: ret == -5
[  921.565450] saa7133[0]/dvb: dvb_init: No zl10039 found!



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


AverMedia Satelllite Hybrid+FM A706

2012-12-18 Thread Ondrej Zary
[3.843747] saa7133[0]: subsystem: 1461:2055, board: AverMedia AverTV 
Satellite Hybrid+FM A706 [card=191,autodetected]
[3.843830] saa7133[0]: board init: gpio is 1835ff
[4.085202] saa7133[0]: i2c eeprom 00: 61 14 55 20 00 00 00 00 00 00 00 00 
00 00 00 00
[4.085210] saa7133[0]: i2c eeprom 10: ff ff ff ff ff 20 ff ff ff ff ff ff 
ff ff ff ff
[4.085217] saa7133[0]: i2c eeprom 20: 02 40 01 02 02 01 01 04 06 ff 00 57 
ff ff ff ff
[4.085225] saa7133[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085232] saa7133[0]: i2c eeprom 40: 60 a0 00 c6 96 ff 05 30 8b 05 ff 40 
ff ff ff ff
[4.085240] saa7133[0]: i2c eeprom 50: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085247] saa7133[0]: i2c eeprom 60: ff 89 00 c0 ff 1c 08 19 97 89 ff ff 
80 15 0a ff
[4.085255] saa7133[0]: i2c eeprom 70: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085262] saa7133[0]: i2c eeprom 80: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085270] saa7133[0]: i2c eeprom 90: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085277] saa7133[0]: i2c eeprom a0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085285] saa7133[0]: i2c eeprom b0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085292] saa7133[0]: i2c eeprom c0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085300] saa7133[0]: i2c eeprom d0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.085307] saa7133[0]: i2c eeprom e0: 00 01 81 b0 65 07 ff ff ff ff ff ff 
ff ff ff ff
[4.085315] saa7133[0]: i2c eeprom f0: ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff
[4.108510] tuner 2-0063: Tuner -1 found with type(s) Radio TV.
[4.247906] tda8290: no gate control were provided!
[4.247995] tuner 2-0063: Tuner has no way to set tv freq
[4.248057] tuner 2-0063: Tuner has no way to set tv freq
[4.248454] saa7133[0]: registered device video0 [v4l2]
[4.248547] saa7133[0]: registered device vbi0
[4.248626] saa7133[0]: registered device radio0
[4.305662] tuner 2-0063: Tuner has no way to set tv freq
[4.306555] tuner 2-0063: tuner has no way to set radio frequency
[4.307711] tuner 2-0063: Tuner has no way to set tv freq
[4.443378] dvb_init() allocating 1 frontend
[4.462345] mt312_read: ret == -5
[4.462352] saa7133[0]/dvb: frontend initialization failed
[4.638148] saa7134 ALSA driver for DMA sound loaded
[4.638658] saa7133[0]/alsa: saa7133[0] at 0xf400 irq 9 registered as 
card -1
[   12.585084] tuner 2-0063: tuner has no way to set radio frequency
[   12.593909] tuner 2-0063: Tuner has no way to set tv freq
[   12.599760] tuner 2-0063: Tuner has no way to set tv freq


The card should be capable of DVB-S, analog TV and FM radio. No DVB-T.

Main chip:   SAA7131E
EEPROM:  S24CS02A
DVB-S demod: CE6313 (=ZL10303 = MT312)
DVB-S tuner: CE5039 (=ZL10039)
TV/FM tuner: TDA18271HD

I physically verified that all these chips are connected to a single I2C bus
(CE5039 and TDA18271HD through 100-ohm resistors).
There is also some MCU present (EM78P153) but it's not connected to I2C so it
probably does not matter.

i2cdetect output:
 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:  -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- 41 -- -- -- -- -- -- -- -- -- 4b -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- UU -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

0x41: wtf is this?
0x4b: TDA8295 (integrated in SAA7131E)
0x50: S24CS02A
0x60: CE5039
0x63: TDA18271HD
But where is CE6313? It should be at 0x0e according to datasheet and pins
35..38 (35 = GND, 36, 37, 38 = VCC).

The tda8290 driver seems to require some i2c gate control but I thinka that
this card has none as all devices are directly on the I2C bus.

Any ideas?

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] radio: Add Sanyo LM7000 tuner driver

2012-06-13 Thread Ondrej Zary
Add very simple driver for Sanyo LM7000 AM/FM tuner chip. Only FM is supported
as there is no known HW with AM implemented.

This will be used by radio-aimslab and radio-sf16fmi.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h
new file mode 100644
index 000..139cd6b
--- /dev/null
+++ b/drivers/media/radio/lm7000.h
@@ -0,0 +1,43 @@
+#ifndef __LM7000_H
+#define __LM7000_H
+
+/* Sanyo LM7000 tuner chip control
+ *
+ * Copyright 2012 Ondrej Zary li...@rainbow-software.org
+ * based on radio-aimslab.c by M. Kirkwood
+ * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec
+ */
+
+#define LM7000_DATA(1  0)
+#define LM7000_CLK (1  1)
+#define LM7000_CE  (1  2)
+
+#define LM7000_FM_100  (0  20)
+#define LM7000_FM_50   (1  20)
+#define LM7000_FM_25   (2  20)
+#define LM7000_BIT_FM  (1  23)
+
+static inline void lm7000_set_freq(u32 freq, void *handle,
+   void (*set_pins)(void *handle, u8 pins))
+{
+   int i;
+   u8 data;
+   u32 val;
+
+   freq += 171200; /* Add 10.7 MHz IF */
+   freq /= 400;/* Convert to 25 kHz units */
+   val = freq | LM7000_FM_25 | LM7000_BIT_FM;
+   /* write the 24-bit register, starting with LSB */
+   for (i = 0; i  24; i++) {
+   data = val  (1  i) ? LM7000_DATA : 0;
+   set_pins(handle, data | LM7000_CE);
+   udelay(2);
+   set_pins(handle, data | LM7000_CE | LM7000_CLK);
+   udelay(2);
+   set_pins(handle, data | LM7000_CE);
+   udelay(2);
+   }
+   set_pins(handle, 0);
+}
+
+#endif /* __LM7000_H */



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] radio-aimslab: Use LM7000 driver

2012-06-13 Thread Ondrej Zary
Convert radio-aimslab to use generic LM7000 driver.
Tested with Reveal RA300.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -37,6 +37,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include radio-isa.h
+#include lm7000.h
 
 MODULE_AUTHOR(M. Kirkwood);
 MODULE_DESCRIPTION(A driver for the RadioTrack/RadioReveal radio card.);
@@ -72,55 +73,38 @@ static struct radio_isa_card *rtrack_alloc(void)
return rt ? rt-isa : NULL;
 }
 
-/* The 128+64 on these outb's is to keep the volume stable while tuning.
- * Without them, the volume _will_ creep up with each frequency change
- * and bit 4 (+16) is to keep the signal strength meter enabled.
- */
+#define AIMS_BIT_TUN_CE(1  0)
+#define AIMS_BIT_TUN_CLK   (1  1)
+#define AIMS_BIT_TUN_DATA  (1  2)
+#define AIMS_BIT_VOL_CE(1  3)
+#define AIMS_BIT_TUN_STRQ  (1  4)
+/* bit 5 is not connected */
+#define AIMS_BIT_VOL_UP(1  6)/* active low */
+#define AIMS_BIT_VOL_DN(1  7)/* active low */
 
-static void send_0_byte(struct radio_isa_card *isa, int on)
+void rtrack_set_pins(void *handle, u8 pins)
 {
-   outb_p(128+64+16+on+1, isa-io);/* wr-enable + data low */
-   outb_p(128+64+16+on+2+1, isa-io);  /* clock */
-   msleep(1);
-}
+   struct radio_isa_card *isa = handle;
+   struct rtrack *rt = container_of(isa, struct rtrack, isa);
+   u8 bits = AIMS_BIT_VOL_DN | AIMS_BIT_VOL_UP | AIMS_BIT_TUN_STRQ;
 
-static void send_1_byte(struct radio_isa_card *isa, int on)
-{
-   outb_p(128+64+16+on+4+1, isa-io);  /* wr-enable+data high */
-   outb_p(128+64+16+on+4+2+1, isa-io);/* clock */
-   msleep(1);
+   if (!v4l2_ctrl_g_ctrl(rt-isa.mute))
+   bits |= AIMS_BIT_VOL_CE;
+
+   if (pins  LM7000_DATA)
+   bits |= AIMS_BIT_TUN_DATA;
+   if (pins  LM7000_CLK)
+   bits |= AIMS_BIT_TUN_CLK;
+   if (pins  LM7000_CE)
+   bits |= AIMS_BIT_TUN_CE;
+
+   outb_p(bits, rt-isa.io);
 }
 
 static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq)
 {
-   int on = v4l2_ctrl_g_ctrl(isa-mute) ? 0 : 8;
-   int i;
-
-   freq += 171200; /* Add 10.7 MHz IF  */
-   freq /= 800;/* Convert to 50 kHz units  */
-
-   send_0_byte(isa, on);   /*  0: LSB of frequency */
-
-   for (i = 0; i  13; i++)/*   : frequency bits (1-13)*/
-   if (freq  (1  i))
-   send_1_byte(isa, on);
-   else
-   send_0_byte(isa, on);
-
-   send_0_byte(isa, on);   /* 14: test bit - always 0*/
-   send_0_byte(isa, on);   /* 15: test bit - always 0*/
-
-   send_0_byte(isa, on);   /* 16: band data 0 - always 0 */
-   send_0_byte(isa, on);   /* 17: band data 1 - always 0 */
-   send_0_byte(isa, on);   /* 18: band data 2 - always 0 */
-   send_0_byte(isa, on);   /* 19: time base - always 0   */
-
-   send_0_byte(isa, on);   /* 20: spacing (0 = 25 kHz)   */
-   send_1_byte(isa, on);   /* 21: spacing (1 = 25 kHz)   */
-   send_0_byte(isa, on);   /* 22: spacing (0 = 25 kHz)   */
-   send_1_byte(isa, on);   /* 23: AM/FM (FM = 1, always) */
+   lm7000_set_freq(freq, isa, rtrack_set_pins);
 
-   outb(0xd0 + on, isa-io);   /* volume steady + sigstr */
return 0;
 }
 


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] radio-sf16fmi: Use LM7000 driver

2012-06-13 Thread Ondrej Zary
Convert radio-sf16fmi to use generic LM7000 driver.
Tested with SF16-FMI, SF16-FMP and SF16-FMD.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -27,6 +27,7 @@
 #include linux/io.h  /* outb, outb_p */
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
+#include lm7000.h
 
 MODULE_AUTHOR(Petr Vandrovec, vandr...@vc.cvut.cz and M. Kirkwood);
 MODULE_DESCRIPTION(A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio.);
@@ -54,31 +55,33 @@ static struct fmi fmi_card;
 static struct pnp_dev *dev;
 bool pnp_attached;
 
-/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
-/* It is only useful to give freq in interval of 800 (=0.05Mhz),
- * other bits will be truncated, e.g 92.7400016 - 92.7, but
- * 92.7400017 - 92.75
- */
-#define RSF16_ENCODE(x)((x) / 800 + 214)
 #define RSF16_MINFREQ (87 * 16000)
 #define RSF16_MAXFREQ (108 * 16000)
 
-static void outbits(int bits, unsigned int data, int io)
+#define FMI_BIT_TUN_CE (1  0)
+#define FMI_BIT_TUN_CLK(1  1)
+#define FMI_BIT_TUN_DATA   (1  2)
+#define FMI_BIT_VOL_SW (1  3)
+#define FMI_BIT_TUN_STRQ   (1  4)
+
+void fmi_set_pins(void *handle, u8 pins)
 {
-   while (bits--) {
-   if (data  1) {
-   outb(5, io);
-   udelay(6);
-   outb(7, io);
-   udelay(6);
-   } else {
-   outb(1, io);
-   udelay(6);
-   outb(3, io);
-   udelay(6);
-   }
-   data = 1;
-   }
+   struct fmi *fmi = handle;
+   u8 bits = FMI_BIT_TUN_STRQ;
+
+   if (!fmi-mute)
+   bits |= FMI_BIT_VOL_SW;
+
+   if (pins  LM7000_DATA)
+   bits |= FMI_BIT_TUN_DATA;
+   if (pins  LM7000_CLK)
+   bits |= FMI_BIT_TUN_CLK;
+   if (pins  LM7000_CE)
+   bits |= FMI_BIT_TUN_CE;
+
+   mutex_lock(fmi-lock);
+   outb_p(bits, fmi-io);
+   mutex_unlock(fmi-lock);
 }
 
 static inline void fmi_mute(struct fmi *fmi)
@@ -95,20 +98,6 @@ static inline void fmi_unmute(struct fmi *fmi)
mutex_unlock(fmi-lock);
 }
 
-static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq)
-{
-   mutex_lock(fmi-lock);
-   fmi-curfreq = freq;
-
-   outbits(16, RSF16_ENCODE(freq), fmi-io);
-   outbits(8, 0xC0, fmi-io);
-   msleep(143);/* was schedule_timeout(HZ/7) */
-   mutex_unlock(fmi-lock);
-   if (!fmi-mute)
-   fmi_unmute(fmi);
-   return 0;
-}
-
 static inline int fmi_getsigstr(struct fmi *fmi)
 {
int val;
@@ -173,7 +162,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
return -EINVAL;
/* rounding in steps of 800 to match the freq
   that will be used */
-   fmi_setfreq(fmi, (f-frequency / 800) * 800);
+   lm7000_set_freq((f-frequency / 800) * 800, fmi, fmi_set_pins);
return 0;
 }
 
 

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] radio: Add Sanyo LM7000 tuner driver

2012-06-12 Thread Ondrej Zary
Add very simple driver for Sanyo LM7000 AM/FM tuner chip. Only FM is supported
as there is no known HW with AM implemented.

This will be used by radio-aimslab and radio-sf16fmi.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index c257da1..5bcce12 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -191,6 +191,9 @@ config RADIO_CADET
  To compile this driver as a module, choose M here: the
  module will be called radio-cadet.
 
+config RADIO_LM7000
+   tristate
+
 config RADIO_RTRACK
tristate AIMSlab RadioTrack (aka RadioReveal) support
depends on ISA  VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index ca8c7d1..7f6aa63 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -28,5 +28,6 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
 obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
 obj-$(CONFIG_RADIO_WL128X) += wl128x/
+obj-$(CONFIG_RADIO_LM7000) += lm7000.o
 
 ccflags-y += -Isound
diff --git a/drivers/media/radio/lm7000.c b/drivers/media/radio/lm7000.c
new file mode 100644
index 000..681f3af
--- /dev/null
+++ b/drivers/media/radio/lm7000.c
@@ -0,0 +1,52 @@
+/* Sanyo LM7000 tuner chip driver
+ *
+ * Copyright 2012 Ondrej Zary li...@rainbow-software.org
+ * based on radio-aimslab.c by M. Kirkwood
+ * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec
+ */
+
+#include linux/delay.h
+#include linux/module.h
+#include lm7000.h
+
+MODULE_AUTHOR(Ondrej Zary li...@rainbow-software.org);
+MODULE_DESCRIPTION(Routines for Sanyo LM7000 AM/FM radio tuner chip);
+MODULE_LICENSE(GPL);
+
+/* write the 24-bit register, starting with LSB */
+static void lm7000_write(struct lm7000 *lm, u32 val)
+{
+   int i;
+   u8 data;
+
+   for (i = 0; i  24; i++) {
+   data = val  (1  i) ? LM7000_DATA : 0;
+   lm-set_pins(lm, data | LM7000_CE);
+   udelay(2);
+   lm-set_pins(lm, data | LM7000_CE | LM7000_CLK);
+   udelay(2);
+   lm-set_pins(lm, data | LM7000_CE);
+   udelay(2);
+   }
+   lm-set_pins(lm, 0);
+}
+
+void lm7000_set_freq(struct lm7000 *lm, u32 freq)
+{
+   freq += 171200; /* Add 10.7 MHz IF */
+   freq /= 400;/* Convert to 25 kHz units */
+   lm7000_write(lm, freq | LM7000_FM_25 | LM7000_BIT_FM);
+}
+EXPORT_SYMBOL(lm7000_set_freq);
+
+static int __init lm7000_module_init(void)
+{
+   return 0;
+}
+
+static void __exit lm7000_module_exit(void)
+{
+}
+
+module_init(lm7000_module_init)
+module_exit(lm7000_module_exit)
diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h
new file mode 100644
index 000..a5bc7d6
--- /dev/null
+++ b/drivers/media/radio/lm7000.h
@@ -0,0 +1,32 @@
+#ifndef __LM7000_H
+#define __LM7000_H
+
+#define LM7000_DATA(1  0)
+#define LM7000_CLK (1  1)
+#define LM7000_CE  (1  2)
+
+#define LM7000_FREQ_MASK 0x3fff
+#define LM7000_BIT_T0  (1  14)
+#define LM7000_BIT_T1  (1  15)
+#define LM7000_BIT_B0  (1  16)
+#define LM7000_BIT_B1  (1  17)
+#define LM7000_BIT_B2  (1  18)
+#define LM7000_BIT_TB  (1  19)
+#define LM7000_FM_100  (0  20)
+#define LM7000_FM_50   (1  20)
+#define LM7000_FM_25   (2  20)
+#define LM7000_AM_5(3  20)
+#define LM7000_AM_10   (4  20)
+#define LM7000_AM_9(5  20)
+#define LM7000_AM_1(6  20)
+#define LM7000_AM_5_   (7  20)
+#define LM7000_BIT_FM  (1  23)
+
+
+struct lm7000 {
+   void (*set_pins)(struct lm7000 *lm, u8 pins);
+};
+
+void lm7000_set_freq(struct lm7000 *lm, u32 freq);
+
+#endif /* __LM7000_H */

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] radio-aimslab: Use LM7000 driver

2012-06-12 Thread Ondrej Zary
Convert radio-aimslab to use generic LM7000 driver.
Tested with Reveal RA300.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 5bcce12..abdf43c 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -193,11 +193,14 @@ config RADIO_CADET
 
 config RADIO_LM7000
tristate
+   depends on RADIO_RTRACK
+   default RADIO_RTRACK
 
 config RADIO_RTRACK
tristate AIMSlab RadioTrack (aka RadioReveal) support
depends on ISA  VIDEO_V4L2
select RADIO_ISA
+   select RADIO_LM7000
---help---
  Choose Y here if you have one of these FM radio cards, and then fill
  in the port address below.
diff --git a/drivers/media/radio/radio-aimslab.c 
b/drivers/media/radio/radio-aimslab.c
index 98e0c8c..48b72d8 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -37,6 +37,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include radio-isa.h
+#include lm7000.h
 
 MODULE_AUTHOR(M. Kirkwood);
 MODULE_DESCRIPTION(A driver for the RadioTrack/RadioReveal radio card.);
@@ -61,66 +62,53 @@ MODULE_PARM_DESC(radio_nr, Radio device numbers);
 struct rtrack {
struct radio_isa_card isa;
int curvol;
+   struct lm7000 lm;
 };
 
-static struct radio_isa_card *rtrack_alloc(void)
+#define AIMS_BIT_TUN_CE(1  0)
+#define AIMS_BIT_TUN_CLK   (1  1)
+#define AIMS_BIT_TUN_DATA  (1  2)
+#define AIMS_BIT_VOL_CE(1  3)
+#define AIMS_BIT_TUN_STRQ  (1  4)
+/* bit 5 is not connected */
+#define AIMS_BIT_VOL_UP(1  6)/* active low */
+#define AIMS_BIT_VOL_DN(1  7)/* active low */
+
+void rtrack_set_pins(struct lm7000 *lm, u8 pins)
 {
-   struct rtrack *rt = kzalloc(sizeof(struct rtrack), GFP_KERNEL);
+   struct rtrack *rt = container_of(lm, struct rtrack, lm);
+   u8 bits = AIMS_BIT_VOL_DN | AIMS_BIT_VOL_UP | AIMS_BIT_TUN_STRQ;
 
-   if (rt)
-   rt-curvol = 0xff;
-   return rt ? rt-isa : NULL;
-}
+   if (!v4l2_ctrl_g_ctrl(rt-isa.mute))
+   bits |= AIMS_BIT_VOL_CE;
 
-/* The 128+64 on these outb's is to keep the volume stable while tuning.
- * Without them, the volume _will_ creep up with each frequency change
- * and bit 4 (+16) is to keep the signal strength meter enabled.
- */
+   if (pins  LM7000_DATA)
+   bits |= AIMS_BIT_TUN_DATA;
+   if (pins  LM7000_CLK)
+   bits |= AIMS_BIT_TUN_CLK;
+   if (pins  LM7000_CE)
+   bits |= AIMS_BIT_TUN_CE;
 
-static void send_0_byte(struct radio_isa_card *isa, int on)
-{
-   outb_p(128+64+16+on+1, isa-io);/* wr-enable + data low */
-   outb_p(128+64+16+on+2+1, isa-io);  /* clock */
-   msleep(1);
+   outb_p(bits, rt-isa.io);
 }
 
-static void send_1_byte(struct radio_isa_card *isa, int on)
+static struct radio_isa_card *rtrack_alloc(void)
 {
-   outb_p(128+64+16+on+4+1, isa-io);  /* wr-enable+data high */
-   outb_p(128+64+16+on+4+2+1, isa-io);/* clock */
-   msleep(1);
+   struct rtrack *rt = kzalloc(sizeof(struct rtrack), GFP_KERNEL);
+
+   if (rt) {
+   rt-curvol = 0xff;
+   rt-lm.set_pins = rtrack_set_pins;
+   }
+   return rt ? rt-isa : NULL;
 }
 
 static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq)
 {
-   int on = v4l2_ctrl_g_ctrl(isa-mute) ? 0 : 8;
-   int i;
-
-   freq += 171200; /* Add 10.7 MHz IF  */
-   freq /= 800;/* Convert to 50 kHz units  */
-
-   send_0_byte(isa, on);   /*  0: LSB of frequency */
-
-   for (i = 0; i  13; i++)/*   : frequency bits (1-13)*/
-   if (freq  (1  i))
-   send_1_byte(isa, on);
-   else
-   send_0_byte(isa, on);
-
-   send_0_byte(isa, on);   /* 14: test bit - always 0*/
-   send_0_byte(isa, on);   /* 15: test bit - always 0*/
-
-   send_0_byte(isa, on);   /* 16: band data 0 - always 0 */
-   send_0_byte(isa, on);   /* 17: band data 1 - always 0 */
-   send_0_byte(isa, on);   /* 18: band data 2 - always 0 */
-   send_0_byte(isa, on);   /* 19: time base - always 0   */
+   struct rtrack *rt = container_of(isa, struct rtrack, isa);
 
-   send_0_byte(isa, on);   /* 20: spacing (0 = 25 kHz)   */
-   send_1_byte(isa, on);   /* 21: spacing (1 = 25 kHz)   */
-   send_0_byte(isa, on);   /* 22: spacing (0 = 25 kHz)   */
-   send_1_byte(isa, on);   /* 23: AM/FM (FM = 1, always) */
+   lm7000_set_freq(rt-lm, freq);
 
-   outb(0xd0 + on, isa-io);   /* volume steady + sigstr */
return 0;
 }
 

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line

[PATCH 3/3] radio-sf16fmi: Use LM7000 driver

2012-06-12 Thread Ondrej Zary
Convert radio-sf16fmi to use generic LM7000 driver.
Tested with SF16-FMI, SF16-FMP and SF16-FMD.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index abdf43c..f4c3924 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -193,8 +193,8 @@ config RADIO_CADET
 
 config RADIO_LM7000
tristate
-   depends on RADIO_RTRACK
-   default RADIO_RTRACK
+   depends on RADIO_RTRACK || RADIO_SF16FMI
+   default RADIO_RTRACK || RADIO_SF16FMI
 
 config RADIO_RTRACK
tristate AIMSlab RadioTrack (aka RadioReveal) support
@@ -328,6 +328,7 @@ config RADIO_MIROPCM20
 config RADIO_SF16FMI
tristate SF16-FMI/SF16-FMP/SF16-FMD Radio
depends on ISA  VIDEO_V4L2
+   select RADIO_LM7000
---help---
  Choose Y here if you have one of these FM radio cards.
 
diff --git a/drivers/media/radio/radio-sf16fmi.c 
b/drivers/media/radio/radio-sf16fmi.c
index a81d723..3cbee77 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -27,6 +27,8 @@
 #include linux/io.h  /* outb, outb_p */
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
+#include lm7000.h
 
 MODULE_AUTHOR(Petr Vandrovec, vandr...@vc.cvut.cz and M. Kirkwood);
 MODULE_DESCRIPTION(A driver for the SF16-FMI, SF16-FMP and SF16-FMD 
radio.);
@@ -48,37 +50,40 @@ struct fmi
bool mute;
unsigned long curfreq; /* freq in kHz */
struct mutex lock;
+   struct lm7000 lm;
 };
 
 static struct fmi fmi_card;
 static struct pnp_dev *dev;
 bool pnp_attached;
 
-/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
-/* It is only useful to give freq in interval of 800 (=0.05Mhz),
- * other bits will be truncated, e.g 92.7400016 - 92.7, but
- * 92.7400017 - 92.75
- */
-#define RSF16_ENCODE(x)((x) / 800 + 214)
 #define RSF16_MINFREQ (87 * 16000)
 #define RSF16_MAXFREQ (108 * 16000)
 
-static void outbits(int bits, unsigned int data, int io)
+#define FMI_BIT_TUN_CE (1  0)
+#define FMI_BIT_TUN_CLK(1  1)
+#define FMI_BIT_TUN_DATA   (1  2)
+#define FMI_BIT_VOL_SW (1  3)
+#define FMI_BIT_TUN_STRQ   (1  4)
+
+void fmi_set_pins(struct lm7000 *lm, u8 pins)
 {
-   while (bits--) {
-   if (data  1) {
-   outb(5, io);
-   udelay(6);
-   outb(7, io);
-   udelay(6);
-   } else {
-   outb(1, io);
-   udelay(6);
-   outb(3, io);
-   udelay(6);
-   }
-   data = 1;
-   }
+   struct fmi *fmi = container_of(lm, struct fmi, lm);
+   u8 bits = FMI_BIT_TUN_STRQ;
+
+   if (!fmi-mute)
+   bits |= FMI_BIT_VOL_SW;
+
+   if (pins  LM7000_DATA)
+   bits |= FMI_BIT_TUN_DATA;
+   if (pins  LM7000_CLK)
+   bits |= FMI_BIT_TUN_CLK;
+   if (pins  LM7000_CE)
+   bits |= FMI_BIT_TUN_CE;
+
+   mutex_lock(fmi-lock);
+   outb_p(bits, fmi-io);
+   mutex_unlock(fmi-lock);
 }
 
 static inline void fmi_mute(struct fmi *fmi)
@@ -95,20 +100,6 @@ static inline void fmi_unmute(struct fmi *fmi)
mutex_unlock(fmi-lock);
 }
 
-static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq)
-{
-   mutex_lock(fmi-lock);
-   fmi-curfreq = freq;
-
-   outbits(16, RSF16_ENCODE(freq), fmi-io);
-   outbits(8, 0xC0, fmi-io);
-   msleep(143);/* was schedule_timeout(HZ/7) */
-   mutex_unlock(fmi-lock);
-   if (!fmi-mute)
-   fmi_unmute(fmi);
-   return 0;
-}
-
 static inline int fmi_getsigstr(struct fmi *fmi)
 {
int val;
@@ -173,7 +164,7 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
return -EINVAL;
/* rounding in steps of 800 to match the freq
   that will be used */
-   fmi_setfreq(fmi, (f-frequency / 800) * 800);
+   lm7000_set_freq(fmi-lm, (f-frequency / 800) * 800);
return 0;
 }
 
@@ -364,6 +355,7 @@ static int __init fmi_init(void)
 
strlcpy(v4l2_dev-name, sf16fmi, sizeof(v4l2_dev-name));
fmi-io = io;
+   fmi-lm.set_pins = fmi_set_pins;
 
res = v4l2_device_register(NULL, v4l2_dev);
if (res  0) {

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] radio: Add Sanyo LM7000 tuner driver

2012-06-12 Thread Ondrej Zary
On Tuesday 12 June 2012 22:17:43 Hans Verkuil wrote:
 Hi Ondrej!

 On Tue June 12 2012 20:37:54 Ondrej Zary wrote:
  Add very simple driver for Sanyo LM7000 AM/FM tuner chip. Only FM is
  supported as there is no known HW with AM implemented.

 It feels to me that it is overkill to turn this into a full blown module.
 Can't this be done as a single lm7000.h header that contains a single
 static inline function like this:

 static inline void lm7000_set_freq(u32 freq, void *handle,
   void (*set_pins)(void *handle, 
 u8 pins))
 {
   ...
 }

 It does the job just as well.

Thanks for idea, it will simplify this a lot. Will resend updated patches.

 Otherwise it looks fine.

 Regards,

   Hans

  This will be used by radio-aimslab and radio-sf16fmi.
 
  Signed-off-by: Ondrej Zary li...@rainbow-software.org
 
  diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
  index c257da1..5bcce12 100644
  --- a/drivers/media/radio/Kconfig
  +++ b/drivers/media/radio/Kconfig
  @@ -191,6 +191,9 @@ config RADIO_CADET
To compile this driver as a module, choose M here: the
module will be called radio-cadet.
 
  +config RADIO_LM7000
  +   tristate
  +
   config RADIO_RTRACK
  tristate AIMSlab RadioTrack (aka RadioReveal) support
  depends on ISA  VIDEO_V4L2
  diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
  index ca8c7d1..7f6aa63 100644
  --- a/drivers/media/radio/Makefile
  +++ b/drivers/media/radio/Makefile
  @@ -28,5 +28,6 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
   obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
   obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
   obj-$(CONFIG_RADIO_WL128X) += wl128x/
  +obj-$(CONFIG_RADIO_LM7000) += lm7000.o
 
   ccflags-y += -Isound
  diff --git a/drivers/media/radio/lm7000.c b/drivers/media/radio/lm7000.c
  new file mode 100644
  index 000..681f3af
  --- /dev/null
  +++ b/drivers/media/radio/lm7000.c
  @@ -0,0 +1,52 @@
  +/* Sanyo LM7000 tuner chip driver
  + *
  + * Copyright 2012 Ondrej Zary li...@rainbow-software.org
  + * based on radio-aimslab.c by M. Kirkwood
  + * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec
  + */
  +
  +#include linux/delay.h
  +#include linux/module.h
  +#include lm7000.h
  +
  +MODULE_AUTHOR(Ondrej Zary li...@rainbow-software.org);
  +MODULE_DESCRIPTION(Routines for Sanyo LM7000 AM/FM radio tuner chip);
  +MODULE_LICENSE(GPL);
  +
  +/* write the 24-bit register, starting with LSB */
  +static void lm7000_write(struct lm7000 *lm, u32 val)
  +{
  +   int i;
  +   u8 data;
  +
  +   for (i = 0; i  24; i++) {
  +   data = val  (1  i) ? LM7000_DATA : 0;
  +   lm-set_pins(lm, data | LM7000_CE);
  +   udelay(2);
  +   lm-set_pins(lm, data | LM7000_CE | LM7000_CLK);
  +   udelay(2);
  +   lm-set_pins(lm, data | LM7000_CE);
  +   udelay(2);
  +   }
  +   lm-set_pins(lm, 0);
  +}
  +
  +void lm7000_set_freq(struct lm7000 *lm, u32 freq)
  +{
  +   freq += 171200; /* Add 10.7 MHz IF */
  +   freq /= 400;/* Convert to 25 kHz units */
  +   lm7000_write(lm, freq | LM7000_FM_25 | LM7000_BIT_FM);
  +}
  +EXPORT_SYMBOL(lm7000_set_freq);
  +
  +static int __init lm7000_module_init(void)
  +{
  +   return 0;
  +}
  +
  +static void __exit lm7000_module_exit(void)
  +{
  +}
  +
  +module_init(lm7000_module_init)
  +module_exit(lm7000_module_exit)
  diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h
  new file mode 100644
  index 000..a5bc7d6
  --- /dev/null
  +++ b/drivers/media/radio/lm7000.h
  @@ -0,0 +1,32 @@
  +#ifndef __LM7000_H
  +#define __LM7000_H
  +
  +#define LM7000_DATA(1  0)
  +#define LM7000_CLK (1  1)
  +#define LM7000_CE  (1  2)
  +
  +#define LM7000_FREQ_MASK 0x3fff
  +#define LM7000_BIT_T0  (1  14)
  +#define LM7000_BIT_T1  (1  15)
  +#define LM7000_BIT_B0  (1  16)
  +#define LM7000_BIT_B1  (1  17)
  +#define LM7000_BIT_B2  (1  18)
  +#define LM7000_BIT_TB  (1  19)
  +#define LM7000_FM_100  (0  20)
  +#define LM7000_FM_50   (1  20)
  +#define LM7000_FM_25   (2  20)
  +#define LM7000_AM_5(3  20)
  +#define LM7000_AM_10   (4  20)
  +#define LM7000_AM_9(5  20)
  +#define LM7000_AM_1(6  20)
  +#define LM7000_AM_5_   (7  20)
  +#define LM7000_BIT_FM  (1  23)
  +
  +
  +struct lm7000 {
  +   void (*set_pins)(struct lm7000 *lm, u8 pins);
  +};
  +
  +void lm7000_set_freq(struct lm7000 *lm, u32 freq);
  +
  +#endif /* __LM7000_H */



-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/6] snd_tea575x: Various patches

2012-05-22 Thread Ondrej Zary
On Sunday 20 May 2012 03:25:25 Hans de Goede wrote:
 Hi All,

 This patch series contains various patches for the tea575x driver to
 prepare for adding support for the Griffin radioSHARK device. The 6th patch
 adds support for tuning AM, which depends on the discussions surrounding
 the v4l2 API and radio devices with multiple tuners. I plan to add patches
 1-5 to my next pull request to Mauro, I will leave patch 6 out until the
 API discussion is done.

I tested the patches with FM-only card (SF16-FMD2) and haven't found any 
problems.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] radio-sf16fmi: add support for SF16-FMD

2012-05-19 Thread Ondrej Zary
Add support for SF16-FMD card to radio-sf16fmi driver.
Only new PnP ID is added and texts changed.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -320,7 +320,7 @@ config RADIO_MIROPCM20
  module will be called radio-miropcm20.
 
 config RADIO_SF16FMI
-   tristate SF16-FMI/SF16-FMP Radio
+   tristate SF16-FMI/SF16-FMP/SF16-FMD Radio
depends on ISA  VIDEO_V4L2
---help---
  Choose Y here if you have one of these FM radio cards.
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -1,4 +1,4 @@
-/* SF16-FMI and SF16-FMP radio driver for Linux radio support
+/* SF16-FMI, SF16-FMP and SF16-FMD radio driver for Linux radio support
  * heavily based on rtrack driver...
  * (c) 1997 M. Kirkwood
  * (c) 1998 Petr Vandrovec, vandr...@vc.cvut.cz
@@ -11,7 +11,7 @@
  *
  *  Frequency control is done digitally -- ie out(port,encodefreq(95.8));
  *  No volume control - only mute/unmute - you have to use line volume
- *  control on SB-part of SF16-FMI/SF16-FMP
+ *  control on SB-part of SF16-FMI/SF16-FMP/SF16-FMD
  *
  * Converted to V4L2 API by Mauro Carvalho Chehab mche...@infradead.org
  */
@@ -29,7 +29,7 @@
 #include media/v4l2-ioctl.h
 
 MODULE_AUTHOR(Petr Vandrovec, vandr...@vc.cvut.cz and M. Kirkwood);
-MODULE_DESCRIPTION(A driver for the SF16-FMI and SF16-FMP radio.);
+MODULE_DESCRIPTION(A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio.);
 MODULE_LICENSE(GPL);
 MODULE_VERSION(0.0.3);
 
@@ -37,7 +37,7 @@ static int io = -1;
 static int radio_nr = -1;
 
 module_param(io, int, 0);
-MODULE_PARM_DESC(io, I/O address of the SF16-FMI or SF16-FMP card (0x284 or 
0x384));
+MODULE_PARM_DESC(io, I/O address of the SF16-FMI/SF16-FMP/SF16-FMD card 
(0x284 or 0x384));
 module_param(radio_nr, int, 0);
 
 struct fmi
@@ -130,7 +130,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
struct v4l2_capability *v)
 {
strlcpy(v-driver, radio-sf16fmi, sizeof(v-driver));
-   strlcpy(v-card, SF16-FMx radio, sizeof(v-card));
+   strlcpy(v-card, SF16-FMI/FMP/FMD radio, sizeof(v-card));
strlcpy(v-bus_info, ISA, sizeof(v-bus_info));
v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
return 0;
@@ -277,8 +277,12 @@ static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
 
 /* ladis: this is my card. does any other types exist? */
 static struct isapnp_device_id id_table[] __devinitdata = {
+   /* SF16-FMI */
{   ISAPNP_ANY_ID, ISAPNP_ANY_ID,
ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad10), 0},
+   /* SF16-FMD */
+   {   ISAPNP_ANY_ID, ISAPNP_ANY_ID,
+   ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad12), 0},
{   ISAPNP_CARD_END, },
 };
 

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: V4L2 API and radio devices with multiple tuners

2012-05-19 Thread Ondrej Zary
On Saturday 19 May 2012 20:20:57 Hans de Goede wrote:
 Hi Hans et all,

 Currently the V4L2 API does not allow for radio devices with more then 1
 tuner, which is a bit of a historical oversight, since many radio devices
 have 2 tuners/demodulators 1 for FM and one for AM. Trying to model this as
 1 tuner really does not work well, as they have 2 completely separate
 frequency bands they handle, as well as different properties (the FM part
 usually is stereo capable, the AM part is not).

 It is important to realize here that usually the AM/FM tuners are part
 of 1 chip, and often have only 1 frequency register which is used in
 both AM/FM modes. IOW it more or less is one tuner, but with 2 modes,
 and from a V4L2 API pov these modes are best modeled as 2 tuners.
 This is at least true for the radio-cadet card and the tea575x,
 which are the only 2 AM capable radio devices we currently know about.

When working on tea575x driver, I thought that it would be nice to implement 
AM. But found that none of my cards with TEA575x has implemented the AM part. 
The components required to receive AM radio (according to the chip datasheet) 
are missing.

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [resend] radio-sf16fmr2: add PnP support for SF16-FMD2

2012-05-17 Thread Ondrej Zary
Add PnP support to radio-sf16fmr2 driver to support SF16-FMD2 card (SB16 +
TEA5757). The driver can now handle two cards (FMR2 is hardwired to 0x384,
FMD2 can be put at 0x384 or 0x284 by PnP).
Tested with both SF16-FMR2 and SF16-FMD2 (the can work at the same time by
using kernel parameter pnp_reserve_io=0x384,2 so the FMD2 is put at 0x284).

Signed-off-by: Ondrej Zary li...@rainbow-software.org

--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -329,7 +329,7 @@ config RADIO_SF16FMI
  module will be called radio-sf16fmi.
 
 config RADIO_SF16FMR2
-   tristate SF16FMR2 Radio
+   tristate SF16-FMR2/SF16-FMD2 Radio
depends on ISA  VIDEO_V4L2  SND
---help---
  Choose Y here if you have one of these FM radio cards.
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -1,4 +1,4 @@
-/* SF16-FMR2 radio driver for Linux
+/* SF16-FMR2 and SF16-FMD2 radio driver for Linux
  * Copyright (c) 2011 Ondrej Zary
  *
  * Original driver was (c) 2000-2002 Ziglio Frediano, fredd...@angelfire.com
@@ -13,15 +13,19 @@
 #include linux/ioport.h  /* request_region   */
 #include linux/io.h  /* outb, outb_p */
 #include linux/isa.h
+#include linux/pnp.h
 #include sound/tea575x-tuner.h
 
 MODULE_AUTHOR(Ondrej Zary);
-MODULE_DESCRIPTION(MediaForte SF16-FMR2 FM radio card driver);
+MODULE_DESCRIPTION(MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver);
 MODULE_LICENSE(GPL);
 
-static int radio_nr = -1;
-module_param(radio_nr, int, 0444);
-MODULE_PARM_DESC(radio_nr, Radio device number);
+/* these cards can only use two different ports (0x384 and 0x284) */
+#define FMR2_MAX 2
+
+static int radio_nr[FMR2_MAX] = { [0 ... (FMR2_MAX - 1)] = -1 };
+module_param_array(radio_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_nr, Radio device numbers);
 
 struct fmr2 {
int io;
@@ -29,9 +33,15 @@ struct fmr2 {
struct snd_tea575x tea;
struct v4l2_ctrl *volume;
struct v4l2_ctrl *balance;
+   bool is_fmd2;
 };
 
-/* the port is hardwired so no need to support multiple cards */
+static int num_fmr2_cards;
+static struct fmr2 *fmr2_cards[FMR2_MAX];
+static bool isa_registered;
+static bool pnp_registered;
+
+/* the port is hardwired on SF16-FMR2 */
 #define FMR2_PORT  0x384
 
 /* TEA575x tuner pins */
@@ -174,7 +184,8 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
 {
struct fmr2 *fmr2 = tea-private_data;
 
-   if (inb(fmr2-io)  FMR2_HASVOL) {
+   /* FMR2 can have volume control, FMD2 can't (uses SB16 mixer) */
+   if (!fmr2-is_fmd2  inb(fmr2-io)  FMR2_HASVOL) {
fmr2-volume = v4l2_ctrl_new_std(tea-ctrl_handler, 
fmr2_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 0, 68, 2, 56);
fmr2-balance = v4l2_ctrl_new_std(tea-ctrl_handler, 
fmr2_ctrl_ops, V4L2_CID_AUDIO_BALANCE, -68, 68, 2, 0);
if (tea-ctrl_handler.error) {
@@ -186,22 +197,28 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
return 0;
 }
 
-static int __devinit fmr2_probe(struct device *pdev, unsigned int dev)
+static struct pnp_device_id fmr2_pnp_ids[] __devinitdata = {
+   { .id = MFRad13 }, /* tuner subdevice of SF16-FMD2 */
+   { .id =  }
+};
+MODULE_DEVICE_TABLE(pnp, fmr2_pnp_ids);
+
+static int __devinit fmr2_probe(struct fmr2 *fmr2, struct device *pdev, int io)
 {
-   struct fmr2 *fmr2;
-   int err;
+   int err, i;
+   char *card_name = fmr2-is_fmd2 ? SF16-FMD2 : SF16-FMR2;
 
-   fmr2 = kzalloc(sizeof(*fmr2), GFP_KERNEL);
-   if (fmr2 == NULL)
-   return -ENOMEM;
+   /* avoid errors if a card was already registered at given port */
+   for (i = 0; i  num_fmr2_cards; i++)
+   if (io == fmr2_cards[i]-io)
+   return -EBUSY;
 
-   strlcpy(fmr2-v4l2_dev.name, dev_name(pdev),
-   sizeof(fmr2-v4l2_dev.name));
-   fmr2-io = FMR2_PORT;
+   strlcpy(fmr2-v4l2_dev.name, radio-sf16fmr2,
+   sizeof(fmr2-v4l2_dev.name)),
+   fmr2-io = io;
 
if (!request_region(fmr2-io, 2, fmr2-v4l2_dev.name)) {
printk(KERN_ERR radio-sf16fmr2: I/O port 0x%x already in 
use\n, fmr2-io);
-   kfree(fmr2);
return -EBUSY;
}
 
@@ -210,56 +227,121 @@ static int __devinit fmr2_probe(struct device *pdev, 
unsigned int dev)
if (err  0) {
v4l2_err(fmr2-v4l2_dev, Could not register v4l2_device\n);
release_region(fmr2-io, 2);
-   kfree(fmr2);
return err;
}
fmr2-tea.v4l2_dev = fmr2-v4l2_dev;
fmr2-tea.private_data = fmr2;
-   fmr2-tea.radio_nr = radio_nr;
+   fmr2-tea.radio_nr = radio_nr[num_fmr2_cards];
fmr2-tea.ops = fmr2_tea_ops;
fmr2-tea.ext_init = fmr2_tea_ext_init;
-   strlcpy(fmr2-tea.card, SF16-FMR2, sizeof(fmr2-tea.card));
-   snprintf(fmr2-tea.bus_info

[PATCH] radio-sf16fmr2: add PnP support for SF16-FMD2

2012-05-13 Thread Ondrej Zary
Add PnP support to radio-sf16fmr2 driver to support SF16-FMD2 card (SB16 +
TEA5757). The driver can now handle two cards (FMR2 is hardwired to 0x384,
FMD2 can be put at 0x384 or 0x284 by PnP).
Tested with both SF16-FMR2 and SF16-FMD2 (the can work at the same time by
using kernel parameter pnp_reserve_io=0x384,2 so the FMD2 is put at 0x284).

Signed-off-by: Ondrej Zary li...@rainbow-software.org

--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -329,7 +329,7 @@ config RADIO_SF16FMI
  module will be called radio-sf16fmi.
 
 config RADIO_SF16FMR2
-   tristate SF16FMR2 Radio
+   tristate SF16-FMR2/SF16-FMD2 Radio
depends on ISA  VIDEO_V4L2  SND
---help---
  Choose Y here if you have one of these FM radio cards.
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -1,4 +1,4 @@
-/* SF16-FMR2 radio driver for Linux
+/* SF16-FMR2 and SF16-FMD2 radio driver for Linux
  * Copyright (c) 2011 Ondrej Zary
  *
  * Original driver was (c) 2000-2002 Ziglio Frediano, fredd...@angelfire.com
@@ -13,15 +13,19 @@
 #include linux/ioport.h  /* request_region   */
 #include linux/io.h  /* outb, outb_p */
 #include linux/isa.h
+#include linux/pnp.h
 #include sound/tea575x-tuner.h
 
 MODULE_AUTHOR(Ondrej Zary);
-MODULE_DESCRIPTION(MediaForte SF16-FMR2 FM radio card driver);
+MODULE_DESCRIPTION(MediaForte SF16-FMR2 and SF16-FMD2 FM radio card driver);
 MODULE_LICENSE(GPL);
 
-static int radio_nr = -1;
-module_param(radio_nr, int, 0444);
-MODULE_PARM_DESC(radio_nr, Radio device number);
+/* these cards can only use two different ports (0x384 and 0x284) */
+#define FMR2_MAX 2
+
+static int radio_nr[FMR2_MAX] = { [0 ... (FMR2_MAX - 1)] = -1 };
+module_param_array(radio_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_nr, Radio device numbers);
 
 struct fmr2 {
int io;
@@ -29,9 +33,15 @@ struct fmr2 {
struct snd_tea575x tea;
struct v4l2_ctrl *volume;
struct v4l2_ctrl *balance;
+   bool is_fmd2;
 };
 
-/* the port is hardwired so no need to support multiple cards */
+static int num_fmr2_cards;
+static struct fmr2 *fmr2_cards[FMR2_MAX];
+static bool isa_registered;
+static bool pnp_registered;
+
+/* the port is hardwired on SF16-FMR2 */
 #define FMR2_PORT  0x384
 
 /* TEA575x tuner pins */
@@ -174,7 +184,8 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
 {
struct fmr2 *fmr2 = tea-private_data;
 
-   if (inb(fmr2-io)  FMR2_HASVOL) {
+   /* FMR2 can have volume control, FMD2 can't (uses SB16 mixer) */
+   if (!fmr2-is_fmd2  inb(fmr2-io)  FMR2_HASVOL) {
fmr2-volume = v4l2_ctrl_new_std(tea-ctrl_handler, 
fmr2_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 0, 68, 2, 56);
fmr2-balance = v4l2_ctrl_new_std(tea-ctrl_handler, 
fmr2_ctrl_ops, V4L2_CID_AUDIO_BALANCE, -68, 68, 2, 0);
if (tea-ctrl_handler.error) {
@@ -186,22 +197,28 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
return 0;
 }
 
-static int __devinit fmr2_probe(struct device *pdev, unsigned int dev)
+static struct pnp_device_id fmr2_pnp_ids[] __devinitdata = {
+   { .id = MFRad13 }, /* tuner subdevice of SF16-FMD2 */
+   { .id =  }
+};
+MODULE_DEVICE_TABLE(pnp, fmr2_pnp_ids);
+
+static int __devinit fmr2_probe(struct fmr2 *fmr2, struct device *pdev, int io)
 {
-   struct fmr2 *fmr2;
-   int err;
+   int err, i;
+   char *card_name = fmr2-is_fmd2 ? SF16-FMD2 : SF16-FMR2;
 
-   fmr2 = kzalloc(sizeof(*fmr2), GFP_KERNEL);
-   if (fmr2 == NULL)
-   return -ENOMEM;
+   /* avoid errors if a card was already registered at given port */
+   for (i = 0; i  num_fmr2_cards; i++)
+   if (io == fmr2_cards[i]-io)
+   return -EBUSY;
 
-   strlcpy(fmr2-v4l2_dev.name, dev_name(pdev),
-   sizeof(fmr2-v4l2_dev.name));
-   fmr2-io = FMR2_PORT;
+   strlcpy(fmr2-v4l2_dev.name, radio-sf16fmr2,
+   sizeof(fmr2-v4l2_dev.name)),
+   fmr2-io = io;
 
if (!request_region(fmr2-io, 2, fmr2-v4l2_dev.name)) {
printk(KERN_ERR radio-sf16fmr2: I/O port 0x%x already in 
use\n, fmr2-io);
-   kfree(fmr2);
return -EBUSY;
}
 
@@ -210,56 +227,121 @@ static int __devinit fmr2_probe(struct device *pdev, 
unsigned int dev)
if (err  0) {
v4l2_err(fmr2-v4l2_dev, Could not register v4l2_device\n);
release_region(fmr2-io, 2);
-   kfree(fmr2);
return err;
}
fmr2-tea.v4l2_dev = fmr2-v4l2_dev;
fmr2-tea.private_data = fmr2;
-   fmr2-tea.radio_nr = radio_nr;
+   fmr2-tea.radio_nr = radio_nr[num_fmr2_cards];
fmr2-tea.ops = fmr2_tea_ops;
fmr2-tea.ext_init = fmr2_tea_ext_init;
-   strlcpy(fmr2-tea.card, SF16-FMR2, sizeof(fmr2-tea.card));
-   snprintf(fmr2-tea.bus_info

Re: Dazzle DVC80 under FC16

2012-05-09 Thread Ondrej Zary
On Wednesday 09 May 2012, Bruno Martins wrote:
 Hello guys,

 Has anyone ever got this to working under any Linux distro, including
 Fedora?

 I have just plugged it in and I get this on dmesg:

 [ 1365.932522] usb 2-1.1: new full-speed USB device number 26 using ehci_hcd
 [ 1366.073145] usb 2-1.1: New USB device found, idVendor=07d0, idProduct=0004
 [ 1366.073153] usb 2-1.1: New USB device strings: Mfr=0, Product=0, 
 SerialNumber=0
 [ 1366.091741] usbvision_probe: Dazzle Fusion Model DVC-80 Rev 1 (PAL) found
 [ 1366.092072] USBVision[0]: registered USBVision Video device video1 [v4l2]
 [ 1366.092091] usbvision_probe: Dazzle Fusion Model DVC-80 Rev 1 (PAL) found
 [ 1366.092149] USBVision[1]: registered USBVision Video device video2 [v4l2]
 [ 1366.092182] usbcore: registered new interface driver usbvision
 [ 1366.092184] USBVision USB Video Device Driver for Linux : 0.9.11
 [ 1366.189268] saa7115 15-0025: saa7113 found (1f7113d0e10) @ 0x4a 
 (usbvision-2-1.1)
 [ 1366.319647] usb 2-1.1: selecting invalid altsetting 1
 [ 1366.319658] usb 2-1.1: cannot change alternate number to 1 (error=-22)

 Device is recognized since it appears in lsusb:

 [skorzen@g62 ~]$ lsusb | grep DVC
 Bus 002 Device 026: ID 07d0:0004 Dazzle DVC-800 (PAL) Grabber

 However, I cannot make it work (my goal is to capture video from a
 camcorder).
 I've tried using cheese for this, but it just crashes and ABRT
 launches for me to fill a bug.

 Any ideas?

Please include the output of lsusb -v for this device (run the command as 
root).


-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Dazzle DVC80 under FC16

2012-05-09 Thread Ondrej Zary
On Wednesday 09 May 2012 18:54:58 Ezequiel Garcia wrote:
 Hi,

 Also please output lsmod with your device plugged and the list of your
 installed modules (do you know how to do this?)

 I may be wrong, but this device should be supported by usbvision module.

The log show that usbvision module is loaded but fails to set altsetting to 1. 
Probably because the device has two interfaces (note that the driver is also 
initialized twice).

-- 
Ondrej Zary
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Dazzle DVC80 under FC16

2012-05-09 Thread Ondrej Zary
On Wednesday 09 May 2012 18:20:18 Bruno Martins wrote:
 On 05/09/2012 04:32 PM, Ondrej Zary wrote:
  On Wednesday 09 May 2012, Bruno Martins wrote:
  Hello guys,
 
  Has anyone ever got this to working under any Linux distro, including
  Fedora?
 
  I have just plugged it in and I get this on dmesg:
 
  [ 1365.932522] usb 2-1.1: new full-speed USB device number 26 using
  ehci_hcd [ 1366.073145] usb 2-1.1: New USB device found, idVendor=07d0,
  idProduct=0004 [ 1366.073153] usb 2-1.1: New USB device strings: Mfr=0,
  Product=0, SerialNumber=0 [ 1366.091741] usbvision_probe: Dazzle Fusion
  Model DVC-80 Rev 1 (PAL) found [ 1366.092072] USBVision[0]: registered
  USBVision Video device video1 [v4l2] [ 1366.092091] usbvision_probe:
  Dazzle Fusion Model DVC-80 Rev 1 (PAL) found [ 1366.092149]
  USBVision[1]: registered USBVision Video device video2 [v4l2] [
  1366.092182] usbcore: registered new interface driver usbvision [
  1366.092184] USBVision USB Video Device Driver for Linux : 0.9.11 [
  1366.189268] saa7115 15-0025: saa7113 found (1f7113d0e10) @ 0x4a
  (usbvision-2-1.1) [ 1366.319647] usb 2-1.1: selecting invalid altsetting
  1
  [ 1366.319658] usb 2-1.1: cannot change alternate number to 1
  (error=-22)
 
  Device is recognized since it appears in lsusb:
 
  [skorzen@g62 ~]$ lsusb | grep DVC
  Bus 002 Device 026: ID 07d0:0004 Dazzle DVC-800 (PAL) Grabber
 
  However, I cannot make it work (my goal is to capture video from a
  camcorder).
  I've tried using cheese for this, but it just crashes and ABRT
  launches for me to fill a bug.
 
  Any ideas?
 
  Please include the output of lsusb -v for this device (run the command
  as root).

 Here it is, mate. Thanks for your cooperation.

 Bus 002 Device 005: ID 07d0:0004 Dazzle DVC-800 (PAL) Grabber
 Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   1.00
   bDeviceClass0 (Defined at Interface level)
   bDeviceSubClass 0
   bDeviceProtocol 0
   bMaxPacketSize0 8
   idVendor   0x07d0 Dazzle
   idProduct  0x0004 DVC-800 (PAL) Grabber
   bcdDevice1.00
   iManufacturer   0
   iProduct0
   iSerial 0
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength  468
 bNumInterfaces  2
 bConfigurationValue 2
 iConfiguration  0
 bmAttributes 0x80
   (Bus Powered)
 MaxPower  500mA
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   0
   bNumEndpoints   3
   bInterfaceClass 0 (Defined at Interface level)
   bInterfaceSubClass  0
   bInterfaceProtocol  0
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x01  EP 1 OUT
 bmAttributes0
   Transfer TypeControl
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0008  1x 8 bytes
 bInterval   1
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x82  EP 2 IN
 bmAttributes1
   Transfer TypeIsochronous
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x  1x 0 bytes
 bInterval   1
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x83  EP 3 IN
 bmAttributes1
   Transfer TypeIsochronous
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x  1x 0 bytes
 bInterval   1
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   1
   bNumEndpoints   3
   bInterfaceClass 0 (Defined at Interface level)
   bInterfaceSubClass  0
   bInterfaceProtocol  0
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x01  EP 1 OUT
 bmAttributes0
   Transfer TypeControl
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0008  1x 8 bytes
 bInterval   1
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x82  EP 2 IN
 bmAttributes

[PATCH v2 1/2] [resend] radio-isa: PnP support for the new ISA radio framework

2012-03-22 Thread Ondrej Zary
Add PnP support to the new ISA radio framework.

Signed-off-by: Ondrej Zary li...@rainbow-software.org

diff --git a/drivers/media/radio/radio-isa.c b/drivers/media/radio/radio-isa.c
index 02bcead..ed9039f 100644
--- a/drivers/media/radio/radio-isa.c
+++ b/drivers/media/radio/radio-isa.c
@@ -26,6 +26,7 @@
 #include linux/delay.h
 #include linux/videodev2.h
 #include linux/io.h
+#include linux/slab.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-fh.h
@@ -198,56 +199,31 @@ static bool radio_isa_valid_io(const struct 
radio_isa_driver *drv, int io)
return false;
 }
 
-int radio_isa_probe(struct device *pdev, unsigned int dev)
+struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv,
+   struct device *pdev)
 {
-   struct radio_isa_driver *drv = pdev-platform_data;
-   const struct radio_isa_ops *ops = drv-ops;
struct v4l2_device *v4l2_dev;
-   struct radio_isa_card *isa;
-   int res;
+   struct radio_isa_card *isa = drv-ops-alloc();
+   if (!isa)
+   return NULL;
 
-   isa = drv-ops-alloc();
-   if (isa == NULL)
-   return -ENOMEM;
dev_set_drvdata(pdev, isa);
isa-drv = drv;
-   isa-io = drv-io_params[dev];
v4l2_dev = isa-v4l2_dev;
strlcpy(v4l2_dev-name, dev_name(pdev), sizeof(v4l2_dev-name));
 
-   if (drv-probe  ops-probe) {
-   int i;
-
-   for (i = 0; i  drv-num_of_io_ports; ++i) {
-   int io = drv-io_ports[i];
-
-   if (request_region(io, drv-region_size, 
v4l2_dev-name)) {
-   bool found = ops-probe(isa, io);
-
-   release_region(io, drv-region_size);
-   if (found) {
-   isa-io = io;
-   break;
-   }
-   }
-   }
-   }
-
-   if (!radio_isa_valid_io(drv, isa-io)) {
-   int i;
+   return isa;
+}
 
-   if (isa-io  0)
-   return -ENODEV;
-   v4l2_err(v4l2_dev, you must set an I/O address with io=0x%03x,
-   drv-io_ports[0]);
-   for (i = 1; i  drv-num_of_io_ports; i++)
-   printk(KERN_CONT /0x%03x, drv-io_ports[i]);
-   printk(KERN_CONT .\n);
-   kfree(isa);
-   return -EINVAL;
-   }
+int radio_isa_common_probe(struct radio_isa_card *isa, struct device *pdev,
+   int radio_nr, unsigned region_size)
+{
+   const struct radio_isa_driver *drv = isa-drv;
+   const struct radio_isa_ops *ops = drv-ops;
+   struct v4l2_device *v4l2_dev = isa-v4l2_dev;
+   int res;
 
-   if (!request_region(isa-io, drv-region_size, v4l2_dev-name)) {
+   if (!request_region(isa-io, region_size, v4l2_dev-name)) {
v4l2_err(v4l2_dev, port 0x%x already in use\n, isa-io);
kfree(isa);
return -EBUSY;
@@ -300,8 +276,8 @@ int radio_isa_probe(struct device *pdev, unsigned int dev)
v4l2_err(v4l2_dev, Could not setup card\n);
goto err_node_reg;
}
-   res = video_register_device(isa-vdev, VFL_TYPE_RADIO,
-   drv-radio_nr_params[dev]);
+   res = video_register_device(isa-vdev, VFL_TYPE_RADIO, radio_nr);
+
if (res  0) {
v4l2_err(v4l2_dev, Could not register device node\n);
goto err_node_reg;
@@ -316,24 +292,110 @@ err_node_reg:
 err_hdl:
v4l2_device_unregister(isa-v4l2_dev);
 err_dev_reg:
-   release_region(isa-io, drv-region_size);
+   release_region(isa-io, region_size);
kfree(isa);
return res;
 }
-EXPORT_SYMBOL_GPL(radio_isa_probe);
 
-int radio_isa_remove(struct device *pdev, unsigned int dev)
+int radio_isa_common_remove(struct radio_isa_card *isa, unsigned region_size)
 {
-   struct radio_isa_card *isa = dev_get_drvdata(pdev);
const struct radio_isa_ops *ops = isa-drv-ops;
 
ops-s_mute_volume(isa, true, isa-volume ? isa-volume-cur.val : 0);
video_unregister_device(isa-vdev);
v4l2_ctrl_handler_free(isa-hdl);
v4l2_device_unregister(isa-v4l2_dev);
-   release_region(isa-io, isa-drv-region_size);
+   release_region(isa-io, region_size);
v4l2_info(isa-v4l2_dev, Removed radio card %s\n, isa-drv-card);
kfree(isa);
return 0;
 }
+
+int radio_isa_probe(struct device *pdev, unsigned int dev)
+{
+   struct radio_isa_driver *drv = pdev-platform_data;
+   const struct radio_isa_ops *ops = drv-ops;
+   struct v4l2_device *v4l2_dev;
+   struct radio_isa_card *isa;
+
+   isa = radio_isa_alloc(drv, pdev);
+   if (!isa)
+   return -ENOMEM;
+   isa-io = drv-io_params[dev

  1   2   >