V4L/DVB: tm6000: Add a callback code for buffer fill
authorMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 3 Jun 2010 20:16:28 +0000 (17:16 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 2 Aug 2010 17:05:53 +0000 (14:05 -0300)
Implements a callback to be used by tm6000-alsa, in order to allow filling
audio data packets.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/tm6000/tm6000-alsa.c
drivers/staging/tm6000/tm6000-core.c
drivers/staging/tm6000/tm6000-video.c
drivers/staging/tm6000/tm6000.h

index de5e78d4b54a163a3452bc5bbee4b2b4b6ce547c..b14c5b780c962299338e4a9d55efd71a15fcc4c2 100644 (file)
@@ -200,6 +200,21 @@ static int snd_tm6000_close(struct snd_pcm_substream *substream)
        return 0;
 }
 
+static int tm6000_fillbuf(struct tm6000_core *core, char *buf, int size)
+{
+       int i;
+
+       /* Need to add a real code to copy audio buffer */
+       printk("Audio (%i bytes): ", size);
+       for (i = 0; i < size - 3; i +=4)
+               printk("(0x%04x, 0x%04x), ",
+                       *(u16 *)(buf + i), *(u16 *)(buf + i + 2));
+
+       printk("\n");
+
+       return 0;
+}
+
 /*
  * hw_params callback
  */
@@ -396,6 +411,7 @@ struct tm6000_ops audio_ops = {
        .name   = "TM6000 Audio Extension",
        .init   = tm6000_audio_init,
        .fini   = tm6000_audio_fini,
+       .fillbuf = tm6000_fillbuf,
 };
 
 static int __init tm6000_alsa_register(void)
index 3d66f9bbfc598fb2670c94f03ae3d0d28c6a9033..6ddb7465a40c2a1793b41b048cc7c99dfe4dd07d 100644 (file)
@@ -653,6 +653,23 @@ void tm6000_add_into_devlist(struct tm6000_core *dev)
 static LIST_HEAD(tm6000_extension_devlist);
 static DEFINE_MUTEX(tm6000_extension_devlist_lock);
 
+int tm6000_call_fillbuf(struct tm6000_core *dev, enum tm6000_ops_type type,
+                       char *buf, int size)
+{
+       struct tm6000_ops *ops = NULL;
+
+       /* FIXME: tm6000_extension_devlist_lock should be a spinlock */
+
+       if (!list_empty(&tm6000_extension_devlist)) {
+               list_for_each_entry(ops, &tm6000_extension_devlist, next) {
+                       if (ops->fillbuf && ops->type == type)
+                               ops->fillbuf(dev, buf, size);
+               }
+       }
+
+       return 0;
+}
+
 int tm6000_register_extension(struct tm6000_ops *ops)
 {
        struct tm6000_core *dev = NULL;
index 1e348ac7c63f4c5424357280af7a519fbdfbccc8..c0d6f6a25c1724a00a15080507b8a463972c5b31 100644 (file)
@@ -301,7 +301,7 @@ static int copy_streams(u8 *data, unsigned long len,
                                        memcpy (&voutp[pos], ptr, cpysize);
                                break;
                        case TM6000_URB_MSG_AUDIO:
-                               /* Need some code to copy audio buffer */
+                               tm6000_call_fillbuf(dev, TM6000_AUDIO, ptr, cpysize);
                                break;
                        case TM6000_URB_MSG_VBI:
                                /* Need some code to copy vbi buffer */
index 8fccf3e4d8f614c9b98e7c5604a5731acee164aa..db9995914caa4087f6081fa01de73990acb16d53 100644 (file)
@@ -229,6 +229,7 @@ struct tm6000_ops {
        enum tm6000_ops_type    type;
        int (*init)(struct tm6000_core *);
        int (*fini)(struct tm6000_core *);
+       int (*fillbuf)(struct tm6000_core *, char *buf, int size);
 };
 
 struct tm6000_fh {
@@ -278,6 +279,9 @@ int tm6000_register_extension(struct tm6000_ops *ops);
 void tm6000_unregister_extension(struct tm6000_ops *ops);
 void tm6000_init_extension(struct tm6000_core *dev);
 void tm6000_close_extension(struct tm6000_core *dev);
+int tm6000_call_fillbuf(struct tm6000_core *dev, enum tm6000_ops_type type,
+                       char *buf, int size);
+
 
 /* In tm6000-stds.c */
 void tm6000_get_std_res(struct tm6000_core *dev);