[linuxtv-commits] [hg:v4l-dvb] merge? http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-empress

2008-08-29 Thread Patch from Mauro Carvalho Chehab
The patch number 8798 was added via Mauro Carvalho Chehab [EMAIL PROTECTED]
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
[EMAIL PROTECTED]

--

From: Mauro Carvalho Chehab  [EMAIL PROTECTED]
merge? http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-empress


Priority: normal

Signed-off-by: Mauro Carvalho Chehab [EMAIL PROTECTED]


---

 linux/drivers/media/video/saa7134/saa6752hs.c   |   17 ++-
 linux/drivers/media/video/saa7134/saa7134-core.c|4 
 linux/drivers/media/video/saa7134/saa7134-empress.c |   15 ++-
 linux/drivers/media/video/saa7134/saa7134-ts.c  |   58 +---
 linux/drivers/media/video/saa7134/saa7134.h |8 +
 5 files changed, 77 insertions(+), 25 deletions(-)

diff -r 002496a68970 -r 86f8ab9468e6 
linux/drivers/media/video/saa7134/saa6752hs.c
--- a/linux/drivers/media/video/saa7134/saa6752hs.c Mon Aug 25 15:45:09 
2008 -0600
+++ b/linux/drivers/media/video/saa7134/saa6752hs.c Fri Aug 29 18:35:43 
2008 -0300
@@ -654,7 +654,7 @@ static int saa6752hs_qmenu(struct saa675
return v4l2_ctrl_query_menu(qmenu, qctrl, NULL);
 }
 
-static int saa6752hs_init(struct i2c_client* client)
+static int saa6752hs_init(struct i2c_client *client, u32 leading_null_bytes)
 {
unsigned char buf[9], buf2[4];
struct saa6752hs_state *h;
@@ -705,6 +705,12 @@ static int saa6752hs_init(struct i2c_cli
buf[0] = 0xB0;
buf[1] = 0x05;
i2c_master_send(client,buf,2);
+
+   /* Set leading null byte for TS */
+   buf[0] = 0xF6;
+   buf[1] = (leading_null_bytes  8)  0xff;
+   buf[2] = leading_null_bytes  0xff;
+   i2c_master_send(client, buf, 3);
 
/* compute PAT */
memcpy(localPAT, PAT, sizeof(PAT));
@@ -813,14 +819,13 @@ saa6752hs_command(struct i2c_client *cli
int i;
 
switch (cmd) {
+   case VIDIOC_INT_INIT:
+   /* apply settings and start encoder */
+   saa6752hs_init(client, *(u32 *)arg);
+   break;
case VIDIOC_S_EXT_CTRLS:
if (ctrls-ctrl_class != V4L2_CTRL_CLASS_MPEG)
return -EINVAL;
-   if (ctrls-count == 0) {
-   /* apply settings and start encoder */
-   saa6752hs_init(client);
-   break;
-   }
/* fall through */
case VIDIOC_TRY_EXT_CTRLS:
case VIDIOC_G_EXT_CTRLS:
diff -r 002496a68970 -r 86f8ab9468e6 
linux/drivers/media/video/saa7134/saa7134-core.c
--- a/linux/drivers/media/video/saa7134/saa7134-core.c  Mon Aug 25 15:45:09 
2008 -0600
+++ b/linux/drivers/media/video/saa7134/saa7134-core.c  Fri Aug 29 18:35:43 
2008 -0300
@@ -465,9 +465,7 @@ int saa7134_set_dmabits(struct saa7134_d
/* TS capture -- dma 5 */
if (dev-ts_q.curr) {
ctrl |= SAA7134_MAIN_CTRL_TE5;
-   irq  |= SAA7134_IRQ1_INTE_RA2_3 |
-   SAA7134_IRQ1_INTE_RA2_2 |
-   SAA7134_IRQ1_INTE_RA2_1 |
+   irq  |= SAA7134_IRQ1_INTE_RA2_1 |
SAA7134_IRQ1_INTE_RA2_0;
}
 
diff -r 002496a68970 -r 86f8ab9468e6 
linux/drivers/media/video/saa7134/saa7134-empress.c
--- a/linux/drivers/media/video/saa7134/saa7134-empress.c   Mon Aug 25 
15:45:09 2008 -0600
+++ b/linux/drivers/media/video/saa7134/saa7134-empress.c   Fri Aug 29 
18:35:43 2008 -0300
@@ -64,10 +64,19 @@ static void ts_reset_encoder(struct saa7
 
 static int ts_init_encoder(struct saa7134_dev* dev)
 {
-   struct v4l2_ext_controls ctrls = { V4L2_CTRL_CLASS_MPEG, 0 };
-
+   u32 leading_null_bytes = 0;
+
+   /* If more cards start to need this, then this
+  should probably be added to the card definitions. */
+   switch (dev-board) {
+   case SAA7134_BOARD_BEHOLD_M6:
+   case SAA7134_BOARD_BEHOLD_M63:
+   case SAA7134_BOARD_BEHOLD_M6_EXTRA:
+   leading_null_bytes = 1;
+   break;
+   }
ts_reset_encoder(dev);
-   saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, ctrls);
+   saa7134_i2c_call_clients(dev, VIDIOC_INT_INIT, leading_null_bytes);
dev-empress_started = 1;
return 0;
 }
diff -r 002496a68970 -r 86f8ab9468e6 
linux/drivers/media/video/saa7134/saa7134-ts.c
--- a/linux/drivers/media/video/saa7134/saa7134-ts.cMon Aug 25 15:45:09 
2008 -0600
+++ b/linux/drivers/media/video/saa7134/saa7134-ts.cFri Aug 29 18:35:43 
2008 -0300
@@ -66,11 +66,29 @@ static int buffer_activate(struct saa713
saa7134_set_dmabits(dev);
 
mod_timer(dev-ts_q.timeout, jiffies+BUFFER_TIMEOUT);
+
+   if (dev-ts_state == SAA7134_TS_BUFF_DONE) {
+   /* Clear TS cache */

[linuxtv-commits] [hg:v4l-dvb] merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-empress

2008-07-27 Thread Patch from Mauro Carvalho Chehab
The patch number 8508 was added via Mauro Carvalho Chehab [EMAIL PROTECTED]
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
[EMAIL PROTECTED]

--

From: Mauro Carvalho Chehab  [EMAIL PROTECTED]
merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-empress


Signed-off-by: Mauro Carvalho Chehab [EMAIL PROTECTED]


---

 linux/drivers/media/video/saa7134/saa7134-empress.c |   32 +---
 linux/drivers/media/video/saa7134/saa7134-video.c   |   46 
 linux/drivers/media/video/saa7134/saa7134.h |6 -
 v4l2-apps/util/v4l2-ctl.cpp |8 +-
 4 files changed, 62 insertions(+), 30 deletions(-)

diff -r a3d6b67b2484 -r c279c49e81e7 
linux/drivers/media/video/saa7134/saa7134-empress.c
--- a/linux/drivers/media/video/saa7134/saa7134-empress.c   Sun Jul 27 
11:30:21 2008 +0200
+++ b/linux/drivers/media/video/saa7134/saa7134-empress.c   Sun Jul 27 
08:21:28 2008 -0300
@@ -89,14 +89,14 @@ static int ts_open(struct inode *inode, 
err = -EBUSY;
if (!mutex_trylock(dev-empress_tsq.vb_lock))
goto done;
-   if (dev-empress_users)
+   if (atomic_read(dev-empress_users))
goto done_up;
 
/* Unmute audio */
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
saa_readb(SAA7134_AUDIO_MUTE_CTRL)  ~(1  6));
 
-   dev-empress_users++;
+   atomic_inc(dev-empress_users);
file-private_data = dev;
err = 0;
 
@@ -110,8 +110,6 @@ static int ts_release(struct inode *inod
 {
struct saa7134_dev *dev = file-private_data;
 
-   mutex_lock(dev-empress_tsq.vb_lock);
-
videobuf_stop(dev-empress_tsq);
videobuf_mmap_free(dev-empress_tsq);
 
@@ -122,9 +120,7 @@ static int ts_release(struct inode *inod
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1  6));
 
-   dev-empress_users--;
-
-   mutex_unlock(dev-empress_tsq.vb_lock);
+   atomic_dec(dev-empress_users);
 
return 0;
 }
@@ -331,6 +327,22 @@ static int empress_g_ext_ctrls(struct fi
if (ctrls-ctrl_class != V4L2_CTRL_CLASS_MPEG)
return -EINVAL;
return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls);
+}
+
+static int empress_g_ctrl(struct file *file, void *priv,
+   struct v4l2_control *c)
+{
+   struct saa7134_dev *dev = file-private_data;
+
+   return saa7134_g_ctrl_internal(dev, NULL, c);
+}
+
+static int empress_s_ctrl(struct file *file, void *priv,
+   struct v4l2_control *c)
+{
+   struct saa7134_dev *dev = file-private_data;
+
+   return saa7134_s_ctrl_internal(dev, NULL, c);
 }
 
 static int empress_queryctrl(struct file *file, void *priv,
@@ -419,8 +431,8 @@ static const struct v4l2_ioctl_ops ts_io
 
.vidioc_queryctrl   = empress_queryctrl,
.vidioc_querymenu   = empress_querymenu,
-   .vidioc_g_ctrl  = saa7134_g_ctrl,
-   .vidioc_s_ctrl  = saa7134_s_ctrl,
+   .vidioc_g_ctrl  = empress_g_ctrl,
+   .vidioc_s_ctrl  = empress_s_ctrl,
 };
 
 /* --- */
@@ -455,7 +467,7 @@ static void empress_signal_update(struct
ts_reset_encoder(dev);
} else {
dprintk(video signal acquired\n);
-   if (dev-empress_users)
+   if (atomic_read(dev-empress_users))
ts_init_encoder(dev);
}
 }
diff -r a3d6b67b2484 -r c279c49e81e7 
linux/drivers/media/video/saa7134/saa7134-video.c
--- a/linux/drivers/media/video/saa7134/saa7134-video.c Sun Jul 27 11:30:21 
2008 +0200
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c Sun Jul 27 08:21:28 
2008 -0300
@@ -1112,10 +1112,8 @@ static struct videobuf_queue_ops video_q
 
 /* -- */
 
-int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
-{
-   struct saa7134_fh *fh = priv;
-   struct saa7134_dev *dev = fh-dev;
+int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, 
struct v4l2_control *c)
+{
const struct v4l2_queryctrl* ctrl;
 
ctrl = ctrl_by_id(c-id);
@@ -1160,20 +1158,31 @@ int saa7134_g_ctrl(struct file *file, vo
}
return 0;
 }
-EXPORT_SYMBOL_GPL(saa7134_g_ctrl);
-
-int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
+EXPORT_SYMBOL_GPL(saa7134_g_ctrl_internal);
+
+static int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control 
*c)
+{
+   struct saa7134_fh *fh = priv;
+
+