aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-driver.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-12-07 21:30:17 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:29 -0500
commit6ecd86dcc838fa446ec86334a9fe0c1e415e3514 (patch)
treedf04619a856f7adaa5cfed62df396a2aa2375c67 /drivers/media/video/cx18/cx18-driver.c
parent66c2a6b0bc0b394d215768610d96f44cf97052ac (diff)
V4L/DVB (9802): cx18: Add module parameters for finer control over buffer allocations
cx18: Add module parameters for finer control over buffer allocations. User now has the option of setting smaller buffers to get lower latency transfers from the encoder. User can also now set the number of buffers used for a stream explicitly. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-driver.c')
-rw-r--r--drivers/media/video/cx18/cx18-driver.c154
1 files changed, 140 insertions, 14 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index a893caff0aa9..255d5477567d 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -83,12 +83,28 @@ static char secam[] = "--";
83static char ntsc[] = "-"; 83static char ntsc[] = "-";
84 84
85/* Buffers */ 85/* Buffers */
86static int enc_mpg_buffers = CX18_DEFAULT_ENC_MPG_BUFFERS;
87static int enc_ts_buffers = CX18_DEFAULT_ENC_TS_BUFFERS; 86static int enc_ts_buffers = CX18_DEFAULT_ENC_TS_BUFFERS;
87static int enc_mpg_buffers = CX18_DEFAULT_ENC_MPG_BUFFERS;
88static int enc_idx_buffers = CX18_DEFAULT_ENC_IDX_BUFFERS;
88static int enc_yuv_buffers = CX18_DEFAULT_ENC_YUV_BUFFERS; 89static int enc_yuv_buffers = CX18_DEFAULT_ENC_YUV_BUFFERS;
89static int enc_vbi_buffers = CX18_DEFAULT_ENC_VBI_BUFFERS; 90static int enc_vbi_buffers = CX18_DEFAULT_ENC_VBI_BUFFERS;
90static int enc_pcm_buffers = CX18_DEFAULT_ENC_PCM_BUFFERS; 91static int enc_pcm_buffers = CX18_DEFAULT_ENC_PCM_BUFFERS;
91 92
93static int enc_ts_bufsize = CX18_DEFAULT_ENC_TS_BUFSIZE;
94static int enc_mpg_bufsize = CX18_DEFAULT_ENC_MPG_BUFSIZE;
95static int enc_idx_bufsize = CX18_DEFAULT_ENC_IDX_BUFSIZE;
96static int enc_yuv_bufsize = CX18_DEFAULT_ENC_YUV_BUFSIZE;
97/* VBI bufsize based on standards supported by card tuner for now */
98static int enc_pcm_bufsize = CX18_DEFAULT_ENC_PCM_BUFSIZE;
99
100static int enc_ts_bufs = -1;
101static int enc_mpg_bufs = -1;
102static int enc_idx_bufs = -1;
103static int enc_yuv_bufs = -1;
104static int enc_vbi_bufs = -1;
105static int enc_pcm_bufs = -1;
106
107
92static int cx18_pci_latency = 1; 108static int cx18_pci_latency = 1;
93 109
94static int mmio_ndelay; 110static int mmio_ndelay;
@@ -108,12 +124,27 @@ module_param(retry_mmio, int, 0644);
108module_param(cx18_pci_latency, int, 0644); 124module_param(cx18_pci_latency, int, 0644);
109module_param(cx18_first_minor, int, 0644); 125module_param(cx18_first_minor, int, 0644);
110 126
111module_param(enc_mpg_buffers, int, 0644);
112module_param(enc_ts_buffers, int, 0644); 127module_param(enc_ts_buffers, int, 0644);
128module_param(enc_mpg_buffers, int, 0644);
129module_param(enc_idx_buffers, int, 0644);
113module_param(enc_yuv_buffers, int, 0644); 130module_param(enc_yuv_buffers, int, 0644);
114module_param(enc_vbi_buffers, int, 0644); 131module_param(enc_vbi_buffers, int, 0644);
115module_param(enc_pcm_buffers, int, 0644); 132module_param(enc_pcm_buffers, int, 0644);
116 133
134module_param(enc_ts_bufsize, int, 0644);
135module_param(enc_mpg_bufsize, int, 0644);
136module_param(enc_idx_bufsize, int, 0644);
137module_param(enc_yuv_bufsize, int, 0644);
138/* VBI bufsize based on standards supported by card tuner for now */
139module_param(enc_pcm_bufsize, int, 0644);
140
141module_param(enc_ts_bufs, int, 0644);
142module_param(enc_mpg_bufs, int, 0644);
143module_param(enc_idx_bufs, int, 0644);
144module_param(enc_yuv_bufs, int, 0644);
145module_param(enc_vbi_bufs, int, 0644);
146module_param(enc_pcm_bufs, int, 0644);
147
117MODULE_PARM_DESC(tuner, "Tuner type selection,\n" 148MODULE_PARM_DESC(tuner, "Tuner type selection,\n"
118 "\t\t\tsee tuner.h for values"); 149 "\t\t\tsee tuner.h for values");
119MODULE_PARM_DESC(radio, 150MODULE_PARM_DESC(radio,
@@ -154,21 +185,57 @@ MODULE_PARM_DESC(retry_mmio,
154MODULE_PARM_DESC(mmio_ndelay, 185MODULE_PARM_DESC(mmio_ndelay,
155 "(Deprecated) MMIO accesses are now never purposely delayed\n" 186 "(Deprecated) MMIO accesses are now never purposely delayed\n"
156 "\t\t\tEffectively: 0 ns"); 187 "\t\t\tEffectively: 0 ns");
157MODULE_PARM_DESC(enc_mpg_buffers,
158 "Encoder MPG Buffers (in MB)\n"
159 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_MPG_BUFFERS));
160MODULE_PARM_DESC(enc_ts_buffers, 188MODULE_PARM_DESC(enc_ts_buffers,
161 "Encoder TS Buffers (in MB)\n" 189 "Encoder TS buffer memory (MB). (enc_ts_bufs can override)\n"
162 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_TS_BUFFERS)); 190 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_TS_BUFFERS));
191MODULE_PARM_DESC(enc_ts_bufsize,
192 "Size of an encoder TS buffer (kB)\n"
193 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_TS_BUFSIZE));
194MODULE_PARM_DESC(enc_ts_bufs,
195 "Number of encoder TS buffers\n"
196 "\t\t\tDefault is computed from other enc_ts_* parameters");
197MODULE_PARM_DESC(enc_mpg_buffers,
198 "Encoder MPG buffer memory (MB). (enc_mpg_bufs can override)\n"
199 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_MPG_BUFFERS));
200MODULE_PARM_DESC(enc_mpg_bufsize,
201 "Size of an encoder MPG buffer (kB)\n"
202 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_MPG_BUFSIZE));
203MODULE_PARM_DESC(enc_mpg_bufs,
204 "Number of encoder MPG buffers\n"
205 "\t\t\tDefault is computed from other enc_mpg_* parameters");
206MODULE_PARM_DESC(enc_idx_buffers,
207 "Encoder IDX buffer memory (MB). (enc_idx_bufs can override)\n"
208 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_IDX_BUFFERS));
209MODULE_PARM_DESC(enc_idx_bufsize,
210 "Size of an encoder IDX buffer (kB)\n"
211 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_IDX_BUFSIZE));
212MODULE_PARM_DESC(enc_idx_bufs,
213 "Number of encoder IDX buffers\n"
214 "\t\t\tDefault is computed from other enc_idx_* parameters");
163MODULE_PARM_DESC(enc_yuv_buffers, 215MODULE_PARM_DESC(enc_yuv_buffers,
164 "Encoder YUV Buffers (in MB)\n" 216 "Encoder YUV buffer memory (MB). (enc_yuv_bufs can override)\n"
165 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_YUV_BUFFERS)); 217 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_YUV_BUFFERS));
218MODULE_PARM_DESC(enc_yuv_bufsize,
219 "Size of an encoder YUV buffer (kB)\n"
220 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_YUV_BUFSIZE));
221MODULE_PARM_DESC(enc_yuv_bufs,
222 "Number of encoder YUV buffers\n"
223 "\t\t\tDefault is computed from other enc_yuv_* parameters");
166MODULE_PARM_DESC(enc_vbi_buffers, 224MODULE_PARM_DESC(enc_vbi_buffers,
167 "Encoder VBI Buffers (in MB)\n" 225 "Encoder VBI buffer memory (MB). (enc_vbi_bufs can override)\n"
168 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_VBI_BUFFERS)); 226 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_VBI_BUFFERS));
227MODULE_PARM_DESC(enc_vbi_bufs,
228 "Number of encoder VBI buffers\n"
229 "\t\t\tDefault is computed from enc_vbi_buffers & tuner std");
169MODULE_PARM_DESC(enc_pcm_buffers, 230MODULE_PARM_DESC(enc_pcm_buffers,
170 "Encoder PCM buffers (in MB)\n" 231 "Encoder PCM buffer memory (MB). (enc_pcm_bufs can override)\n"
171 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_PCM_BUFFERS)); 232 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_PCM_BUFFERS));
233MODULE_PARM_DESC(enc_pcm_bufsize,
234 "Size of an encoder PCM buffer (kB)\n"
235 "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_PCM_BUFSIZE));
236MODULE_PARM_DESC(enc_pcm_bufs,
237 "Number of encoder PCM buffers\n"
238 "\t\t\tDefault is computed from other enc_pcm_* parameters");
172 239
173MODULE_PARM_DESC(cx18_first_minor, "Set kernel number assigned to first card"); 240MODULE_PARM_DESC(cx18_first_minor, "Set kernel number assigned to first card");
174 241
@@ -361,11 +428,65 @@ static void cx18_process_options(struct cx18 *cx)
361{ 428{
362 int i, j; 429 int i, j;
363 430
364 cx->options.megabytes[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers;
365 cx->options.megabytes[CX18_ENC_STREAM_TYPE_TS] = enc_ts_buffers; 431 cx->options.megabytes[CX18_ENC_STREAM_TYPE_TS] = enc_ts_buffers;
432 cx->options.megabytes[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers;
433 cx->options.megabytes[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_buffers;
366 cx->options.megabytes[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers; 434 cx->options.megabytes[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers;
367 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers; 435 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers;
368 cx->options.megabytes[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; 436 cx->options.megabytes[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers;
437 cx->options.megabytes[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control only */
438
439 cx->stream_buffers[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufs;
440 cx->stream_buffers[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufs;
441 cx->stream_buffers[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufs;
442 cx->stream_buffers[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufs;
443 cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_bufs;
444 cx->stream_buffers[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufs;
445 cx->stream_buffers[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control, no data */
446
447 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufsize;
448 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize;
449 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize;
450 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize;
451 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = 0; /* computed later */
452 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize;
453 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */
454
455 /* Except for VBI ensure stream_buffers & stream_buf_size are valid */
456 for (i = 0; i < CX18_MAX_STREAMS; i++) {
457 /* User said to use 0 buffers */
458 if (cx->stream_buffers[i] == 0) {
459 cx->options.megabytes[i] = 0;
460 cx->stream_buf_size[i] = 0;
461 continue;
462 }
463 /* User said to use 0 MB total */
464 if (cx->options.megabytes[i] <= 0) {
465 cx->options.megabytes[i] = 0;
466 cx->stream_buffers[i] = 0;
467 cx->stream_buf_size[i] = 0;
468 continue;
469 }
470 /* VBI is computed later or user said buffer has size 0 */
471 if (cx->stream_buf_size[i] <= 0) {
472 if (i != CX18_ENC_STREAM_TYPE_VBI) {
473 cx->options.megabytes[i] = 0;
474 cx->stream_buffers[i] = 0;
475 cx->stream_buf_size[i] = 0;
476 }
477 continue;
478 }
479 if (cx->stream_buffers[i] < 0) {
480 cx->stream_buffers[i] = cx->options.megabytes[i] * 1024
481 / cx->stream_buf_size[i];
482 } else {
483 /* N.B. This might round down to 0 */
484 cx->options.megabytes[i] =
485 cx->stream_buffers[i] * cx->stream_buf_size[i] / 1024;
486 }
487 cx->stream_buf_size[i] *= 1024; /* convert from kB to bytes */
488 }
489
369 cx->options.cardtype = cardtype[cx->num]; 490 cx->options.cardtype = cardtype[cx->num];
370 cx->options.tuner = tuner[cx->num]; 491 cx->options.tuner = tuner[cx->num];
371 cx->options.radio = radio[cx->num]; 492 cx->options.radio = radio[cx->num];
@@ -768,13 +889,18 @@ static int __devinit cx18_probe(struct pci_dev *dev,
768 } 889 }
769 cx->params.video_gop_size = cx->is_60hz ? 15 : 12; 890 cx->params.video_gop_size = cx->is_60hz ? 15 : 12;
770 891
771 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = 0x08000;
772 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = 0x08000;
773 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = 0x01200;
774 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = 0x20000;
775 vbi_buf_size = cx->vbi.raw_size * (cx->is_60hz ? 24 : 36) / 2; 892 vbi_buf_size = cx->vbi.raw_size * (cx->is_60hz ? 24 : 36) / 2;
776 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_buf_size; 893 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_buf_size;
777 894
895 if (cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] < 0)
896 cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] =
897 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] * 1024 * 1024
898 / vbi_buf_size;
899 else
900 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] =
901 cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] * vbi_buf_size
902 / (1024 * 1024);
903
778 if (cx->options.radio > 0) 904 if (cx->options.radio > 0)
779 cx->v4l2_cap |= V4L2_CAP_RADIO; 905 cx->v4l2_cap |= V4L2_CAP_RADIO;
780 906