The patch number 13902 was added via Andy Walls <awa...@radix.net>
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:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

From: Andy Walls  <awa...@radix.net>
cx18: Update MPEG Index stream buffers module option processing


Update the module options related to INDEX stream buffer allocation.  A single
CX2341[5678] index entry is only 24 bytes.  Large buffers for the IDX stream
will prevent the CX23418 from transferring index data over at all.  Buffers
of around 1.5 kB or 64 index entries seem to be just fine.  We'll default to
63 buffers/MDLs as that is the firmware limit per stream and IDX stream buffers
are not high rate.  There is no reason on earth to allocate the previous 1 MB
default of buffer space for the IDX stream.

This is in anticipation of implementing the G_ENC_INDEX ioctl() in the cx18
driver.

Priority: normal

Signed-off-by: Andy Walls <awa...@radix.net>


---

 linux/drivers/media/video/cx18/cx18-driver.c |   33 ++++++++++++++-----
 linux/drivers/media/video/cx18/cx18-driver.h |   14 +++++++-
 2 files changed, 38 insertions(+), 9 deletions(-)

diff -r 59e746a1c5d1 -r eb875b71908a 
linux/drivers/media/video/cx18/cx18-driver.c
--- a/linux/drivers/media/video/cx18/cx18-driver.c      Wed Dec 30 09:10:33 
2009 -0200
+++ b/linux/drivers/media/video/cx18/cx18-driver.c      Wed Dec 30 20:54:53 
2009 -0500
@@ -91,7 +91,7 @@
 
 static int enc_ts_bufs = -1;
 static int enc_mpg_bufs = -1;
-static int enc_idx_bufs = -1;
+static int enc_idx_bufs = CX18_MAX_FW_MDLS_PER_STREAM;
 static int enc_yuv_bufs = -1;
 static int enc_vbi_bufs = -1;
 static int enc_pcm_bufs = -1;
@@ -196,14 +196,17 @@
                 "Number of encoder MPG buffers\n"
                 "\t\t\tDefault is computed from other enc_mpg_* parameters");
 MODULE_PARM_DESC(enc_idx_buffers,
-                "Encoder IDX buffer memory (MB). (enc_idx_bufs can override)\n"
-                "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_IDX_BUFFERS));
+                "(Deprecated) Encoder IDX buffer memory (MB)\n"
+                "\t\t\tIgnored, except 0 disables IDX buffer allocations\n"
+                "\t\t\tDefault: 1 [Enabled]");
 MODULE_PARM_DESC(enc_idx_bufsize,
                 "Size of an encoder IDX buffer (kB)\n"
-                "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_IDX_BUFSIZE));
+                "\t\t\tAllowed values are multiples of 1.5 kB rounded up\n"
+                "\t\t\t(multiples of size required for 64 index entries)\n"
+                "\t\t\tDefault: 2");
 MODULE_PARM_DESC(enc_idx_bufs,
                 "Number of encoder IDX buffers\n"
-                "\t\t\tDefault is computed from other enc_idx_* parameters");
+                "\t\t\tDefault: " __stringify(CX18_MAX_FW_MDLS_PER_STREAM));
 MODULE_PARM_DESC(enc_yuv_buffers,
                 "Encoder YUV buffer memory (MB). (enc_yuv_bufs can override)\n"
                 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_YUV_BUFFERS));
@@ -501,7 +504,12 @@
                /*
                 * YUV is a special case where the stream_buf_size needs to be
                 * an integral multiple of 33.75 kB (storage for 32 screens
-                * lines to maintain alignment in case of lost buffers
+                * lines to maintain alignment in case of lost buffers).
+                *
+                * IDX is a special case where the stream_buf_size should be
+                * an integral multiple of 1.5 kB (storage for 64 index entries
+                * to maintain alignment in case of lost buffers).
+                *
                 */
                if (i == CX18_ENC_STREAM_TYPE_YUV) {
                        cx->stream_buf_size[i] *= 1024;
@@ -511,15 +519,24 @@
                        if (cx->stream_buf_size[i] < CX18_UNIT_ENC_YUV_BUFSIZE)
                                cx->stream_buf_size[i] =
                                                CX18_UNIT_ENC_YUV_BUFSIZE;
+               } else if (i == CX18_ENC_STREAM_TYPE_IDX) {
+                       cx->stream_buf_size[i] *= 1024;
+                       cx->stream_buf_size[i] -=
+                          (cx->stream_buf_size[i] % CX18_UNIT_ENC_IDX_BUFSIZE);
+
+                       if (cx->stream_buf_size[i] < CX18_UNIT_ENC_IDX_BUFSIZE)
+                               cx->stream_buf_size[i] =
+                                               CX18_UNIT_ENC_IDX_BUFSIZE;
                }
                /*
-                * YUV is a special case where the stream_buf_size is
+                * YUV and IDX are special cases where the stream_buf_size is
                 * now in bytes.
                 * VBI is a special case where the stream_buf_size is fixed
                 * and already in bytes
                 */
                if (i == CX18_ENC_STREAM_TYPE_VBI ||
-                   i == CX18_ENC_STREAM_TYPE_YUV) {
+                   i == CX18_ENC_STREAM_TYPE_YUV ||
+                   i == CX18_ENC_STREAM_TYPE_IDX) {
                        if (cx->stream_buffers[i] < 0) {
                                cx->stream_buffers[i] =
                                        cx->options.megabytes[i] * 1024 * 1024
diff -r 59e746a1c5d1 -r eb875b71908a 
linux/drivers/media/video/cx18/cx18-driver.h
--- a/linux/drivers/media/video/cx18/cx18-driver.h      Wed Dec 30 09:10:33 
2009 -0200
+++ b/linux/drivers/media/video/cx18/cx18-driver.h      Wed Dec 30 20:54:53 
2009 -0500
@@ -128,10 +128,22 @@
 #define CX18_625_LINE_ENC_YUV_BUFSIZE  (CX18_UNIT_ENC_YUV_BUFSIZE * 576/32)
 #define CX18_525_LINE_ENC_YUV_BUFSIZE  (CX18_UNIT_ENC_YUV_BUFSIZE * 480/32)
 
+/* IDX buffer size should be a multiple of the index entry size from the chip 
*/
+struct cx18_enc_idx_entry {
+       __le32 length;
+       __le32 offset_low;
+       __le32 offset_high;
+       __le32 flags;
+       __le32 pts_low;
+       __le32 pts_high;
+} __attribute__ ((packed));
+#define CX18_UNIT_ENC_IDX_BUFSIZE \
+       (sizeof(struct cx18_enc_idx_entry) * V4L2_ENC_IDX_ENTRIES)
+
 /* DMA buffer, default size in kB allocated */
 #define CX18_DEFAULT_ENC_TS_BUFSIZE   32
 #define CX18_DEFAULT_ENC_MPG_BUFSIZE  32
-#define CX18_DEFAULT_ENC_IDX_BUFSIZE  32
+#define CX18_DEFAULT_ENC_IDX_BUFSIZE  (CX18_UNIT_ENC_IDX_BUFSIZE * 1 / 1024 + 
1)
 #define CX18_DEFAULT_ENC_YUV_BUFSIZE  (CX18_UNIT_ENC_YUV_BUFSIZE * 3 / 1024 + 
1)
 #define CX18_DEFAULT_ENC_PCM_BUFSIZE   4
 


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/eb875b71908a414dc20dc1252602286a2af68db5

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to