V4L/DVB (6054): ivtv: specify some stream sizes in kB instead of MB
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 19 Aug 2007 08:32:33 +0000 (05:32 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 01:05:41 +0000 (22:05 -0300)
Some streams (PCM, VBI decoding) do not need that much memory, so specify
the allocated memory in kB instead of MB to limit memory usage. E.g. 1 MB
is overkill for the VBI decoding stream, 64 kB is enough.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/ivtv/ivtv-driver.c
drivers/media/video/ivtv/ivtv-driver.h
drivers/media/video/ivtv/ivtv-streams.c

index 8086c62e7545652dc5cb36946508ac9b7067baf5..3591518ed35894b9d7abb697eab4a5153d8a2389 100644 (file)
@@ -208,7 +208,7 @@ MODULE_PARM_DESC(enc_vbi_buffers,
                 "Encoder VBI Buffers (in MB)\n"
                 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_ENC_VBI_BUFFERS));
 MODULE_PARM_DESC(enc_pcm_buffers,
-                "Encoder PCM buffers (in MB)\n"
+                "Encoder PCM buffers (in kB)\n"
                 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_ENC_PCM_BUFFERS));
 MODULE_PARM_DESC(dec_mpg_buffers,
                 "Decoder MPG buffers (in MB)\n"
@@ -217,7 +217,7 @@ MODULE_PARM_DESC(dec_yuv_buffers,
                 "Decoder YUV buffers (in MB)\n"
                 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_DEC_YUV_BUFFERS));
 MODULE_PARM_DESC(dec_vbi_buffers,
-                "Decoder VBI buffers (in MB)\n"
+                "Decoder VBI buffers (in kB)\n"
                 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_DEC_VBI_BUFFERS));
 MODULE_PARM_DESC(newi2c,
                 "Use new I2C implementation\n"
@@ -547,13 +547,13 @@ static void ivtv_process_options(struct ivtv *itv)
        const char *chipname;
        int i, j;
 
-       itv->options.megabytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers;
-       itv->options.megabytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers;
-       itv->options.megabytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers;
-       itv->options.megabytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers;
-       itv->options.megabytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers;
-       itv->options.megabytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers;
-       itv->options.megabytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers;
+       itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers * 1024;
+       itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers * 1024;
+       itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers * 1024;
+       itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers;
+       itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024;
+       itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024;
+       itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers;
        itv->options.cardtype = cardtype[itv->num];
        itv->options.tuner = tuner[itv->num];
        itv->options.radio = radio[itv->num];
index e80f9f65a9051824783adaa94de8d44504735fa8..783fb4449b0ecf1a118b413c86cd2f82079e3dec 100644 (file)
@@ -186,10 +186,12 @@ extern const u32 yuv_offset[4];
 #define IVTV_DEFAULT_ENC_MPG_BUFFERS 4
 #define IVTV_DEFAULT_ENC_YUV_BUFFERS 2
 #define IVTV_DEFAULT_ENC_VBI_BUFFERS 1
-#define IVTV_DEFAULT_ENC_PCM_BUFFERS 1
+/* Exception: size in kB for this stream (MB is overkill) */
+#define IVTV_DEFAULT_ENC_PCM_BUFFERS 320
 #define IVTV_DEFAULT_DEC_MPG_BUFFERS 1
 #define IVTV_DEFAULT_DEC_YUV_BUFFERS 1
-#define IVTV_DEFAULT_DEC_VBI_BUFFERS 1
+/* Exception: size in kB for this stream (MB is way overkill) */
+#define IVTV_DEFAULT_DEC_VBI_BUFFERS 64
 
 /* ======================================================================== */
 /* ========================== END USER SETTABLE DMA VARIABLES ============= */
@@ -321,7 +323,7 @@ extern int ivtv_debug;
 
 
 struct ivtv_options {
-       int megabytes[IVTV_MAX_STREAMS]; /* Size in megabytes of each stream */
+       int kilobytes[IVTV_MAX_STREAMS]; /* Size in kilobytes of each stream */
        int cardtype;           /* force card type on load */
        int tuner;              /* set tuner on load */
        int radio;              /* enable/disable radio */
index 2e632014c90de511685fc0daf26a2805328f5704..fab5c51b15198586eedcb3b01fa54ad8e54c330c 100644 (file)
@@ -150,7 +150,7 @@ static void ivtv_stream_init(struct ivtv *itv, int type)
                s->dma = ivtv_stream_info[type].dma;
        s->buf_size = itv->stream_buf_size[type];
        if (s->buf_size)
-               s->buffers = itv->options.megabytes[type] * 1024 * 1024 / s->buf_size;
+               s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size;
        spin_lock_init(&s->qlock);
        init_waitqueue_head(&s->waitq);
        s->id = -1;
@@ -192,7 +192,7 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
        /* User explicitly selected 0 buffers for these streams, so don't
           create them. */
        if (minor >= 0 && ivtv_stream_info[type].dma != PCI_DMA_NONE &&
-           itv->options.megabytes[type] == 0) {
+           itv->options.kilobytes[type] == 0) {
                IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
                return 0;
        }
@@ -238,18 +238,18 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
 
        switch (vfl_type) {
        case VFL_TYPE_GRABBER:
-               IVTV_INFO("Registered device video%d for %s (%d MB)\n",
-                       s->v4l2dev->minor, s->name, itv->options.megabytes[type]);
+               IVTV_INFO("Registered device video%d for %s (%d kB)\n",
+                       s->v4l2dev->minor, s->name, itv->options.kilobytes[type]);
                break;
        case VFL_TYPE_RADIO:
                IVTV_INFO("Registered device radio%d for %s\n",
                        s->v4l2dev->minor - MINOR_VFL_TYPE_RADIO_MIN, s->name);
                break;
        case VFL_TYPE_VBI:
-               if (itv->options.megabytes[type])
-                       IVTV_INFO("Registered device vbi%d for %s (%d MB)\n",
+               if (itv->options.kilobytes[type])
+                       IVTV_INFO("Registered device vbi%d for %s (%d kB)\n",
                                s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN,
-                               s->name, itv->options.megabytes[type]);
+                               s->name, itv->options.kilobytes[type]);
                else
                        IVTV_INFO("Registered device vbi%d for %s\n",
                                s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN, s->name);