aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r--drivers/media/video/cx88/Kconfig3
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c5
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c875
-rw-r--r--drivers/media/video/cx88/cx88-cards.c150
-rw-r--r--drivers/media/video/cx88/cx88-core.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c252
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c8
-rw-r--r--drivers/media/video/cx88/cx88-input.c34
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c50
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c16
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c4
-rw-r--r--drivers/media/video/cx88/cx88.h25
12 files changed, 528 insertions, 902 deletions
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 630273992a41..91e1c481a164 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -11,6 +11,7 @@ config VIDEO_CX88
11 select VIDEO_BUF 11 select VIDEO_BUF
12 select VIDEO_TUNER 12 select VIDEO_TUNER
13 select VIDEO_TVEEPROM 13 select VIDEO_TVEEPROM
14 select VIDEO_CX2341X
14 select VIDEO_IR 15 select VIDEO_IR
15 ---help--- 16 ---help---
16 This is a video4linux driver for Conexant 2388x based 17 This is a video4linux driver for Conexant 2388x based
@@ -61,6 +62,7 @@ config VIDEO_CX88_DVB_ALL_FRONTENDS
61 select DVB_LGDT330X 62 select DVB_LGDT330X
62 select DVB_NXT200X 63 select DVB_NXT200X
63 select DVB_CX24123 64 select DVB_CX24123
65 select DVB_ISL6421
64 ---help--- 66 ---help---
65 This builds cx88-dvb with all currently supported frontend 67 This builds cx88-dvb with all currently supported frontend
66 demodulators. If you wish to tweak your configuration, and 68 demodulators. If you wish to tweak your configuration, and
@@ -139,6 +141,7 @@ config VIDEO_CX88_DVB_CX24123
139 default y 141 default y
140 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 142 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
141 select DVB_CX24123 143 select DVB_CX24123
144 select DVB_ISL6421
142 ---help--- 145 ---help---
143 This adds DVB-S support for cards based on the 146 This adds DVB-S support for cards based on the
144 Connexant 2388x chip and the CX24123 demodulator. 147 Connexant 2388x chip and the CX24123 demodulator.
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 320b3d9384ba..2194cbeca33b 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -4,7 +4,7 @@
4 * PCI function #1 of the cx2388x. 4 * PCI function #1 of the cx2388x.
5 * 5 *
6 * (c) 2005,2006 Ricardo Cerqueira <v4l@cerqueira.org> 6 * (c) 2005,2006 Ricardo Cerqueira <v4l@cerqueira.org>
7 * (c) 2005 Mauro Carvalho Chehab <mchehab@brturbo.com.br> 7 * (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
8 * Based on a dummy cx88 module by Gerd Knorr <kraxel@bytesex.org> 8 * Based on a dummy cx88 module by Gerd Knorr <kraxel@bytesex.org>
9 * Based on dummy.c by Jaroslav Kysela <perex@suse.cz> 9 * Based on dummy.c by Jaroslav Kysela <perex@suse.cz>
10 * 10 *
@@ -111,7 +111,7 @@ MODULE_PARM_DESC(index, "Index value for cx88x capture interface(s).");
111 111
112MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards"); 112MODULE_DESCRIPTION("ALSA driver module for cx2388x based TV cards");
113MODULE_AUTHOR("Ricardo Cerqueira"); 113MODULE_AUTHOR("Ricardo Cerqueira");
114MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@brturbo.com.br>"); 114MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
115MODULE_LICENSE("GPL"); 115MODULE_LICENSE("GPL");
116MODULE_SUPPORTED_DEVICE("{{Conexant,23881}," 116MODULE_SUPPORTED_DEVICE("{{Conexant,23881},"
117 "{{Conexant,23882}," 117 "{{Conexant,23882},"
@@ -696,7 +696,6 @@ static int __devinit snd_cx88_create(struct snd_card *card,
696 chip->irq = -1; 696 chip->irq = -1;
697 spin_lock_init(&chip->reg_lock); 697 spin_lock_init(&chip->reg_lock);
698 698
699 cx88_reset(core);
700 chip->core = core; 699 chip->core = core;
701 700
702 /* get irq */ 701 /* get irq */
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index e100d8ef369a..67fd3302e8f2 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -30,9 +30,10 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/firmware.h> 32#include <linux/firmware.h>
33#include <media/v4l2-common.h>
34#include <media/cx2341x.h>
33 35
34#include "cx88.h" 36#include "cx88.h"
35#include <media/v4l2-common.h>
36 37
37MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards"); 38MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");
38MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 39MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
@@ -53,7 +54,6 @@ static LIST_HEAD(cx8802_devlist);
53 54
54/* ------------------------------------------------------------------ */ 55/* ------------------------------------------------------------------ */
55 56
56#define BLACKBIRD_FIRM_ENC_FILENAME "blackbird-fw-enc.bin"
57#define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024 57#define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
58 58
59/* defines below are from ivtv-driver.h */ 59/* defines below are from ivtv-driver.h */
@@ -63,8 +63,6 @@ static LIST_HEAD(cx8802_devlist);
63/* Firmware API commands */ 63/* Firmware API commands */
64#define IVTV_API_STD_TIMEOUT 500 64#define IVTV_API_STD_TIMEOUT 500
65 65
66#define BLACKBIRD_API_PING 0x80
67#define BLACKBIRD_API_BEGIN_CAPTURE 0x81
68enum blackbird_capture_type { 66enum blackbird_capture_type {
69 BLACKBIRD_MPEG_CAPTURE, 67 BLACKBIRD_MPEG_CAPTURE,
70 BLACKBIRD_RAW_CAPTURE, 68 BLACKBIRD_RAW_CAPTURE,
@@ -78,205 +76,29 @@ enum blackbird_capture_bits {
78 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08, 76 BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
79 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10 77 BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
80}; 78};
81#define BLACKBIRD_API_END_CAPTURE 0x82
82enum blackbird_capture_end { 79enum blackbird_capture_end {
83 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */ 80 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
84 BLACKBIRD_END_NOW, /* stop immediately, no irq */ 81 BLACKBIRD_END_NOW, /* stop immediately, no irq */
85}; 82};
86#define BLACKBIRD_API_SET_AUDIO_ID 0x89
87#define BLACKBIRD_API_SET_VIDEO_ID 0x8B
88#define BLACKBIRD_API_SET_PCR_ID 0x8D
89#define BLACKBIRD_API_SET_FRAMERATE 0x8F
90enum blackbird_framerate { 83enum blackbird_framerate {
91 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */ 84 BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
92 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */ 85 BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
93}; 86};
94#define BLACKBIRD_API_SET_RESOLUTION 0x91
95#define BLACKBIRD_API_SET_VIDEO_BITRATE 0x95
96enum blackbird_video_bitrate_type {
97 BLACKBIRD_VIDEO_VBR,
98 BLACKBIRD_VIDEO_CBR
99};
100#define BLACKBIRD_PEAK_RATE_DIVISOR 400
101enum blackbird_mux_rate {
102 BLACKBIRD_MUX_RATE_DEFAULT,
103 /* dvd mux rate: multiply by 400 to get the actual rate */
104 BLACKBIRD_MUX_RATE_DVD = 25200
105};
106#define BLACKBIRD_API_SET_GOP_STRUCTURE 0x97
107#define BLACKBIRD_API_SET_ASPECT_RATIO 0x99
108enum blackbird_aspect_ratio {
109 BLACKBIRD_ASPECT_RATIO_FORBIDDEN,
110 BLACKBIRD_ASPECT_RATIO_1_1_SQUARE,
111 BLACKBIRD_ASPECT_RATIO_4_3,
112 BLACKBIRD_ASPECT_RATIO_16_9,
113 BLACKBIRD_ASPECT_RATIO_221_100,
114 BLACKBIRD_ASPECT_RATIO_RESERVED
115};
116#define BLACKBIRD_API_SET_DNR_MODE 0x9B
117enum blackbird_dnr_bits {
118 BLACKBIRD_DNR_BITS_MANUAL,
119 BLACKBIRD_DNR_BITS_AUTO_SPATIAL,
120 BLACKBIRD_DNR_BITS_AUTO_TEMPORAL,
121 BLACKBIRD_DNR_BITS_AUTO
122};
123enum blackbird_median_filter {
124 BLACKBIRD_MEDIAN_FILTER_DISABLED,
125 BLACKBIRD_MEDIAN_FILTER_HORIZONTAL,
126 BLACKBIRD_MEDIAN_FILTER_VERTICAL,
127 BLACKBIRD_MEDIAN_FILTER_HV,
128 BLACKBIRD_MEDIAN_FILTER_DIAGONAL
129};
130#define BLACKBIRD_API_SET_MANUAL_DNR 0x9D
131#define BLACKBIRD_API_SET_DNR_MEDIAN 0x9F
132#define BLACKBIRD_API_SET_SPATIAL_FILTER 0xA1
133enum blackbird_spatial_filter_luma {
134 BLACKBIRD_SPATIAL_FILTER_LUMA_DISABLED,
135 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ,
136 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_VERT,
137 BLACKBIRD_SPATIAL_FILTER_LUMA_2D_HV, /* separable, default */
138 BLACKBIRD_SPATIAL_FILTER_LUMA_2D_SYMM /* symmetric non-separable */
139};
140enum blackbird_spatial_filter_chroma {
141 BLACKBIRD_SPATIAL_FILTER_CHROMA_DISABLED,
142 BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ /* default */
143};
144#define BLACKBIRD_API_SET_3_2_PULLDOWN 0xB1
145enum blackbird_pulldown {
146 BLACKBIRD_3_2_PULLDOWN_DISABLED,
147 BLACKBIRD_3_2_PULLDOWN_ENABLED
148};
149#define BLACKBIRD_API_SET_VBI_LINE_NO 0xB7
150enum blackbird_vbi_line_bits {
151 BLACKBIRD_VBI_LINE_BITS_TOP_FIELD,
152 BLACKBIRD_VBI_LINE_BITS_BOT_FIELD = (1 << 31),
153 BLACKBIRD_VBI_LINE_BITS_ALL_LINES = 0xFFFFFFFF
154};
155enum blackbird_vbi_line {
156 BLACKBIRD_VBI_LINE_DISABLED,
157 BLACKBIRD_VBI_LINE_ENABLED
158};
159enum blackbird_vbi_slicing {
160 BLACKBIRD_VBI_SLICING_NONE,
161 BLACKBIRD_VBI_SLICING_CLOSED_CAPTION
162};
163#define BLACKBIRD_API_SET_STREAM_TYPE 0xB9
164enum blackbird_stream_type {
165 BLACKBIRD_STREAM_PROGRAM,
166 BLACKBIRD_STREAM_TRANSPORT,
167 BLACKBIRD_STREAM_MPEG1,
168 BLACKBIRD_STREAM_PES_AV,
169 BLACKBIRD_STREAM_UNKNOWN4,
170 BLACKBIRD_STREAM_PES_VIDEO,
171 BLACKBIRD_STREAM_UNKNOWN6,
172 BLACKBIRD_STREAM_PES_AUDIO,
173 BLACKBIRD_STREAM_UNKNOWN8,
174 BLACKBIRD_STREAM_UNKNOWN9, /* audio/pcm ? */
175 BLACKBIRD_STREAM_DVD,
176 BLACKBIRD_STREAM_VCD,
177 BLACKBIRD_STREAM_UNKNOWN12 /* svcd/xvcd ? */
178};
179#define BLACKBIRD_API_SET_OUTPUT_PORT 0xBB
180enum blackbird_stream_port { 87enum blackbird_stream_port {
181 BLACKBIRD_OUTPUT_PORT_MEMORY, 88 BLACKBIRD_OUTPUT_PORT_MEMORY,
182 BLACKBIRD_OUTPUT_PORT_STREAMING, 89 BLACKBIRD_OUTPUT_PORT_STREAMING,
183 BLACKBIRD_OUTPUT_PORT_SERIAL 90 BLACKBIRD_OUTPUT_PORT_SERIAL
184}; 91};
185#define BLACKBIRD_API_SET_AUDIO_PARAMS 0xBD
186enum blackbird_audio_bits_sample_rate {
187 BLACKBIRD_AUDIO_BITS_44100HZ,
188 BLACKBIRD_AUDIO_BITS_48000HZ,
189 BLACKBIRD_AUDIO_BITS_32000HZ,
190 BLACKBIRD_AUDIO_BITS_RESERVED_HZ,
191};
192enum blackbird_audio_bits_encoding {
193 BLACKBIRD_AUDIO_BITS_LAYER_1 = 0x1 << 2,
194 BLACKBIRD_AUDIO_BITS_LAYER_2 = 0x2 << 2,
195};
196enum blackbird_audio_bits_bitrate_layer_1 {
197 BLACKBIRD_AUDIO_BITS_LAYER_1_FREE_FORMAT,
198 BLACKBIRD_AUDIO_BITS_LAYER_1_32 = 0x01 << 4,
199 BLACKBIRD_AUDIO_BITS_LAYER_1_64 = 0x02 << 4,
200 BLACKBIRD_AUDIO_BITS_LAYER_1_96 = 0x03 << 4,
201 BLACKBIRD_AUDIO_BITS_LAYER_1_128 = 0x04 << 4,
202 BLACKBIRD_AUDIO_BITS_LAYER_1_160 = 0x05 << 4,
203 BLACKBIRD_AUDIO_BITS_LAYER_1_192 = 0x06 << 4,
204 BLACKBIRD_AUDIO_BITS_LAYER_1_224 = 0x07 << 4,
205 BLACKBIRD_AUDIO_BITS_LAYER_1_256 = 0x08 << 4,
206 BLACKBIRD_AUDIO_BITS_LAYER_1_288 = 0x09 << 4,
207 BLACKBIRD_AUDIO_BITS_LAYER_1_320 = 0x0A << 4,
208 BLACKBIRD_AUDIO_BITS_LAYER_1_352 = 0x0B << 4,
209 BLACKBIRD_AUDIO_BITS_LAYER_1_384 = 0x0C << 4,
210 BLACKBIRD_AUDIO_BITS_LAYER_1_416 = 0x0D << 4,
211 BLACKBIRD_AUDIO_BITS_LAYER_1_448 = 0x0E << 4,
212};
213enum blackbird_audio_bits_bitrate_layer_2 {
214 BLACKBIRD_AUDIO_BITS_LAYER_2_FREE_FORMAT,
215 BLACKBIRD_AUDIO_BITS_LAYER_2_32 = 0x01 << 4,
216 BLACKBIRD_AUDIO_BITS_LAYER_2_48 = 0x02 << 4,
217 BLACKBIRD_AUDIO_BITS_LAYER_2_56 = 0x03 << 4,
218 BLACKBIRD_AUDIO_BITS_LAYER_2_64 = 0x04 << 4,
219 BLACKBIRD_AUDIO_BITS_LAYER_2_80 = 0x05 << 4,
220 BLACKBIRD_AUDIO_BITS_LAYER_2_96 = 0x06 << 4,
221 BLACKBIRD_AUDIO_BITS_LAYER_2_112 = 0x07 << 4,
222 BLACKBIRD_AUDIO_BITS_LAYER_2_128 = 0x08 << 4,
223 BLACKBIRD_AUDIO_BITS_LAYER_2_160 = 0x09 << 4,
224 BLACKBIRD_AUDIO_BITS_LAYER_2_192 = 0x0A << 4,
225 BLACKBIRD_AUDIO_BITS_LAYER_2_224 = 0x0B << 4,
226 BLACKBIRD_AUDIO_BITS_LAYER_2_256 = 0x0C << 4,
227 BLACKBIRD_AUDIO_BITS_LAYER_2_320 = 0x0D << 4,
228 BLACKBIRD_AUDIO_BITS_LAYER_2_384 = 0x0E << 4,
229};
230enum blackbird_audio_bits_mode {
231 BLACKBIRD_AUDIO_BITS_STEREO,
232 BLACKBIRD_AUDIO_BITS_JOINT_STEREO = 0x1 << 8,
233 BLACKBIRD_AUDIO_BITS_DUAL = 0x2 << 8,
234 BLACKBIRD_AUDIO_BITS_MONO = 0x3 << 8,
235};
236enum blackbird_audio_bits_mode_extension {
237 BLACKBIRD_AUDIO_BITS_BOUND_4,
238 BLACKBIRD_AUDIO_BITS_BOUND_8 = 0x1 << 10,
239 BLACKBIRD_AUDIO_BITS_BOUND_12 = 0x2 << 10,
240 BLACKBIRD_AUDIO_BITS_BOUND_16 = 0x3 << 10,
241};
242enum blackbird_audio_bits_emphasis {
243 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE,
244 BLACKBIRD_AUDIO_BITS_EMPHASIS_50_15 = 0x1 << 12,
245 BLACKBIRD_AUDIO_BITS_EMPHASIS_RESERVED = 0x2 << 12,
246 BLACKBIRD_AUDIO_BITS_EMPHASIS_CCITT_J17 = 0x3 << 12,
247};
248enum blackbird_audio_bits_crc {
249 BLACKBIRD_AUDIO_BITS_CRC_OFF,
250 BLACKBIRD_AUDIO_BITS_CRC_ON = 0x1 << 14,
251};
252enum blackbird_audio_bits_copyright {
253 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF,
254 BLACKBIRD_AUDIO_BITS_COPYRIGHT_ON = 0x1 << 15,
255};
256enum blackbird_audio_bits_original {
257 BLACKBIRD_AUDIO_BITS_COPY,
258 BLACKBIRD_AUDIO_BITS_ORIGINAL = 0x1 << 16,
259};
260#define BLACKBIRD_API_HALT 0xC3
261#define BLACKBIRD_API_GET_VERSION 0xC4
262#define BLACKBIRD_API_SET_GOP_CLOSURE 0xC5
263enum blackbird_gop_closure {
264 BLACKBIRD_GOP_CLOSURE_OFF,
265 BLACKBIRD_GOP_CLOSURE_ON,
266};
267#define BLACKBIRD_API_DATA_XFER_STATUS 0xC6
268enum blackbird_data_xfer_status { 92enum blackbird_data_xfer_status {
269 BLACKBIRD_MORE_BUFFERS_FOLLOW, 93 BLACKBIRD_MORE_BUFFERS_FOLLOW,
270 BLACKBIRD_LAST_BUFFER, 94 BLACKBIRD_LAST_BUFFER,
271}; 95};
272#define BLACKBIRD_API_PROGRAM_INDEX_INFO 0xC7
273enum blackbird_picture_mask { 96enum blackbird_picture_mask {
274 BLACKBIRD_PICTURE_MASK_NONE, 97 BLACKBIRD_PICTURE_MASK_NONE,
275 BLACKBIRD_PICTURE_MASK_I_FRAMES, 98 BLACKBIRD_PICTURE_MASK_I_FRAMES,
276 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3, 99 BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,
277 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7, 100 BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,
278}; 101};
279#define BLACKBIRD_API_SET_VBI_PARAMS 0xC8
280enum blackbird_vbi_mode_bits { 102enum blackbird_vbi_mode_bits {
281 BLACKBIRD_VBI_BITS_SLICED, 103 BLACKBIRD_VBI_BITS_SLICED,
282 BLACKBIRD_VBI_BITS_RAW, 104 BLACKBIRD_VBI_BITS_RAW,
@@ -288,33 +110,23 @@ enum blackbird_vbi_insertion_bits {
288 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, 110 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
289 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, 111 BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
290}; 112};
291#define BLACKBIRD_API_SET_DMA_BLOCK_SIZE 0xC9
292enum blackbird_dma_unit { 113enum blackbird_dma_unit {
293 BLACKBIRD_DMA_BYTES, 114 BLACKBIRD_DMA_BYTES,
294 BLACKBIRD_DMA_FRAMES, 115 BLACKBIRD_DMA_FRAMES,
295}; 116};
296#define BLACKBIRD_API_DMA_TRANSFER_INFO 0xCA
297#define BLACKBIRD_API_DMA_TRANSFER_STAT 0xCB
298enum blackbird_dma_transfer_status_bits { 117enum blackbird_dma_transfer_status_bits {
299 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01, 118 BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,
300 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04, 119 BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,
301 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10, 120 BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
302}; 121};
303#define BLACKBIRD_API_SET_DMA2HOST_ADDR 0xCC
304#define BLACKBIRD_API_INIT_VIDEO_INPUT 0xCD
305#define BLACKBIRD_API_SET_FRAMESKIP 0xD0
306#define BLACKBIRD_API_PAUSE 0xD2
307enum blackbird_pause { 122enum blackbird_pause {
308 BLACKBIRD_PAUSE_ENCODING, 123 BLACKBIRD_PAUSE_ENCODING,
309 BLACKBIRD_RESUME_ENCODING, 124 BLACKBIRD_RESUME_ENCODING,
310}; 125};
311#define BLACKBIRD_API_REFRESH_INPUT 0xD3
312#define BLACKBIRD_API_SET_COPYRIGHT 0xD4
313enum blackbird_copyright { 126enum blackbird_copyright {
314 BLACKBIRD_COPYRIGHT_OFF, 127 BLACKBIRD_COPYRIGHT_OFF,
315 BLACKBIRD_COPYRIGHT_ON, 128 BLACKBIRD_COPYRIGHT_ON,
316}; 129};
317#define BLACKBIRD_API_SET_NOTIFICATION 0xD5
318enum blackbird_notification_type { 130enum blackbird_notification_type {
319 BLACKBIRD_NOTIFICATION_REFRESH, 131 BLACKBIRD_NOTIFICATION_REFRESH,
320}; 132};
@@ -325,7 +137,6 @@ enum blackbird_notification_status {
325enum blackbird_notification_mailbox { 137enum blackbird_notification_mailbox {
326 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1, 138 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
327}; 139};
328#define BLACKBIRD_API_SET_CAPTURE_LINES 0xD6
329enum blackbird_field1_lines { 140enum blackbird_field1_lines {
330 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */ 141 BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */
331 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */ 142 BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */
@@ -336,12 +147,10 @@ enum blackbird_field2_lines {
336 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */ 147 BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */
337 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */ 148 BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */
338}; 149};
339#define BLACKBIRD_API_SET_CUSTOM_DATA 0xD7
340enum blackbird_custom_data_type { 150enum blackbird_custom_data_type {
341 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 151 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
342 BLACKBIRD_CUSTOM_PRIVATE_PACKET, 152 BLACKBIRD_CUSTOM_PRIVATE_PACKET,
343}; 153};
344#define BLACKBIRD_API_MUTE_VIDEO 0xD9
345enum blackbird_mute { 154enum blackbird_mute {
346 BLACKBIRD_UNMUTE, 155 BLACKBIRD_UNMUTE,
347 BLACKBIRD_MUTE, 156 BLACKBIRD_MUTE,
@@ -356,7 +165,6 @@ enum blackbird_mute_video_shift {
356 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16, 165 BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,
357 BLACKBIRD_MUTE_VIDEO_Y_SHIFT = 24, 166 BLACKBIRD_MUTE_VIDEO_Y_SHIFT = 24,
358}; 167};
359#define BLACKBIRD_API_MUTE_AUDIO 0xDA
360 168
361/* Registers */ 169/* Registers */
362#define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/) 170#define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/)
@@ -498,15 +306,12 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value)
498 306
499/* ------------------------------------------------------------------ */ 307/* ------------------------------------------------------------------ */
500 308
501/* We don't need to call the API often, so using just one mailbox will probably suffice */ 309static int blackbird_mbox_func(void *priv, int command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA])
502static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
503 u32 inputcnt, u32 outputcnt, ...)
504{ 310{
311 struct cx8802_dev *dev = priv;
505 unsigned long timeout; 312 unsigned long timeout;
506 u32 value, flag, retval; 313 u32 value, flag, retval;
507 int i; 314 int i;
508 va_list args;
509 va_start(args, outputcnt);
510 315
511 dprintk(1,"%s: 0x%X\n", __FUNCTION__, command); 316 dprintk(1,"%s: 0x%X\n", __FUNCTION__, command);
512 317
@@ -530,12 +335,11 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
530 /* write command + args + fill remaining with zeros */ 335 /* write command + args + fill remaining with zeros */
531 memory_write(dev->core, dev->mailbox + 1, command); /* command code */ 336 memory_write(dev->core, dev->mailbox + 1, command); /* command code */
532 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */ 337 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */
533 for (i = 0; i < inputcnt ; i++) { 338 for (i = 0; i < in; i++) {
534 value = va_arg(args, int); 339 memory_write(dev->core, dev->mailbox + 4 + i, data[i]);
535 memory_write(dev->core, dev->mailbox + 4 + i, value); 340 dprintk(1, "API Input %d = %d\n", i, data[i]);
536 dprintk(1, "API Input %d = %d\n", i, value);
537 } 341 }
538 for (; i < 16 ; i++) 342 for (; i < CX2341X_MBOX_MAX_DATA; i++)
539 memory_write(dev->core, dev->mailbox + 4 + i, 0); 343 memory_write(dev->core, dev->mailbox + 4 + i, 0);
540 344
541 flag |= 3; /* tell 'em we're done writing */ 345 flag |= 3; /* tell 'em we're done writing */
@@ -555,12 +359,10 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
555 } 359 }
556 360
557 /* read output values */ 361 /* read output values */
558 for (i = 0; i < outputcnt ; i++) { 362 for (i = 0; i < out; i++) {
559 int *vptr = va_arg(args, int *); 363 memory_read(dev->core, dev->mailbox + 4 + i, data + i);
560 memory_read(dev->core, dev->mailbox + 4 + i, vptr); 364 dprintk(1, "API Output %d = %d\n", i, data[i]);
561 dprintk(1, "API Output %d = %d\n", i, *vptr);
562 } 365 }
563 va_end(args);
564 366
565 memory_read(dev->core, dev->mailbox + 2, &retval); 367 memory_read(dev->core, dev->mailbox + 2, &retval);
566 dprintk(1, "API result = %d\n",retval); 368 dprintk(1, "API result = %d\n",retval);
@@ -569,7 +371,29 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
569 memory_write(dev->core, dev->mailbox, flag); 371 memory_write(dev->core, dev->mailbox, flag);
570 return retval; 372 return retval;
571} 373}
374/* ------------------------------------------------------------------ */
572 375
376/* We don't need to call the API often, so using just one mailbox will probably suffice */
377static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,
378 u32 inputcnt, u32 outputcnt, ...)
379{
380 u32 data[CX2341X_MBOX_MAX_DATA];
381 va_list vargs;
382 int i, err;
383
384 va_start(vargs, outputcnt);
385
386 for (i = 0; i < inputcnt; i++) {
387 data[i] = va_arg(vargs, int);
388 }
389 err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data);
390 for (i = 0; i < outputcnt; i++) {
391 int *vptr = va_arg(vargs, int *);
392 *vptr = data[i];
393 }
394 va_end(vargs);
395 return err;
396}
573 397
574static int blackbird_find_mailbox(struct cx8802_dev *dev) 398static int blackbird_find_mailbox(struct cx8802_dev *dev)
575{ 399{
@@ -614,13 +438,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
614 if (retval < 0) 438 if (retval < 0)
615 dprintk(0, "Error with register_write\n"); 439 dprintk(0, "Error with register_write\n");
616 440
617 retval = request_firmware(&firmware, BLACKBIRD_FIRM_ENC_FILENAME, 441 retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME,
618 &dev->pci->dev); 442 &dev->pci->dev);
619 443
620 444
621 if (retval != 0) { 445 if (retval != 0) {
622 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n", 446 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",
623 BLACKBIRD_FIRM_ENC_FILENAME); 447 CX2341X_FIRM_ENC_FILENAME);
624 dprintk(0, "Please fix your hotplug setup, the board will " 448 dprintk(0, "Please fix your hotplug setup, the board will "
625 "not work without firmware loaded!\n"); 449 "not work without firmware loaded!\n");
626 return -1; 450 return -1;
@@ -686,12 +510,19 @@ DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | M
686*DB: "DirectBurn" 510*DB: "DirectBurn"
687*/ 511*/
688 512
689static struct blackbird_dnr default_dnr_params = { 513static void blackbird_codec_settings(struct cx8802_dev *dev)
690 .mode = BLACKBIRD_DNR_BITS_MANUAL, 514{
691 .type = BLACKBIRD_MEDIAN_FILTER_DISABLED, 515 /* assign frame size */
692 .spatial = 0, 516 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
693 .temporal = 0 517 dev->height, dev->width);
694}; 518
519 dev->params.width = dev->width;
520 dev->params.height = dev->height;
521 dev->params.is_50hz = (dev->core->tvnorm->id & V4L2_STD_625_50) != 0;
522
523 cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params);
524}
525
695static struct v4l2_mpeg_compression default_mpeg_params = { 526static struct v4l2_mpeg_compression default_mpeg_params = {
696 .st_type = V4L2_MPEG_PS_2, 527 .st_type = V4L2_MPEG_PS_2,
697 .st_bitrate = { 528 .st_bitrate = {
@@ -712,7 +543,7 @@ static struct v4l2_mpeg_compression default_mpeg_params = {
712 .target = 224, 543 .target = 224,
713 .max = 224 544 .max = 224
714 }, 545 },
715 .au_sample_rate = 44100, 546 .au_sample_rate = 48000,
716 .au_pesid = 0, 547 .au_pesid = 0,
717 .vi_type = V4L2_MPEG_VI_2, 548 .vi_type = V4L2_MPEG_VI_2,
718 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3, 549 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
@@ -723,524 +554,13 @@ static struct v4l2_mpeg_compression default_mpeg_params = {
723 .max = 6000 554 .max = 6000
724 }, 555 },
725 .vi_frame_rate = 25, 556 .vi_frame_rate = 25,
726 .vi_frames_per_gop = 15, 557 .vi_frames_per_gop = 12,
727 .vi_bframes_count = 2, 558 .vi_bframes_count = 2,
728 .vi_pesid = 0, 559 .vi_pesid = 0,
729 .closed_gops = 0, 560 .closed_gops = 1,
730 .pulldown = 0 561 .pulldown = 0
731}; 562};
732 563
733static enum blackbird_stream_type mpeg_stream_types[] = {
734 [V4L2_MPEG_SS_1] = BLACKBIRD_STREAM_MPEG1,
735 [V4L2_MPEG_PS_2] = BLACKBIRD_STREAM_PROGRAM,
736 [V4L2_MPEG_TS_2] = BLACKBIRD_STREAM_TRANSPORT,
737 [V4L2_MPEG_PS_DVD] = BLACKBIRD_STREAM_DVD,
738};
739static enum blackbird_aspect_ratio mpeg_stream_ratios[] = {
740 [V4L2_MPEG_ASPECT_SQUARE] = BLACKBIRD_ASPECT_RATIO_1_1_SQUARE,
741 [V4L2_MPEG_ASPECT_4_3] = BLACKBIRD_ASPECT_RATIO_4_3,
742 [V4L2_MPEG_ASPECT_16_9] = BLACKBIRD_ASPECT_RATIO_16_9,
743 [V4L2_MPEG_ASPECT_1_221] = BLACKBIRD_ASPECT_RATIO_221_100,
744};
745static enum blackbird_video_bitrate_type mpeg_video_bitrates[] = {
746 [V4L2_BITRATE_NONE] = BLACKBIRD_VIDEO_CBR,
747 [V4L2_BITRATE_CBR] = BLACKBIRD_VIDEO_CBR,
748 [V4L2_BITRATE_VBR] = BLACKBIRD_VIDEO_VBR,
749};
750/* find the best layer I/II bitrate to fit a given numeric value */
751struct bitrate_bits {
752 u32 bits; /* layer bits for the best fit */
753 u32 rate; /* actual numeric value for the layer best fit */
754};
755struct bitrate_approximation {
756 u32 target; /* numeric value of the rate we want */
757 struct bitrate_bits layer[2];
758};
759static struct bitrate_approximation mpeg_audio_bitrates[] = {
760 /* target layer[0].bits layer[0].rate layer[1].bits layer[1].rate */
761 { 0, { { 0, 0, }, { 0, 0, }, }, },
762 { 32, { { BLACKBIRD_AUDIO_BITS_LAYER_1_32 , 32, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_32 , 32, }, }, },
763 { 48, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_48 , 48, }, }, },
764 { 56, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_56 , 56, }, }, },
765 { 64, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_64 , 64, }, }, },
766 { 80, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_80 , 80, }, }, },
767 { 96, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_96 , 96, }, }, },
768 { 112, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_112, 112, }, }, },
769 { 128, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_128, 128, }, }, },
770 { 160, { { BLACKBIRD_AUDIO_BITS_LAYER_1_160, 160, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_160, 160, }, }, },
771 { 192, { { BLACKBIRD_AUDIO_BITS_LAYER_1_192, 192, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_192, 192, }, }, },
772 { 224, { { BLACKBIRD_AUDIO_BITS_LAYER_1_224, 224, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_224, 224, }, }, },
773 { 256, { { BLACKBIRD_AUDIO_BITS_LAYER_1_256, 256, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_256, 256, }, }, },
774 { 288, { { BLACKBIRD_AUDIO_BITS_LAYER_1_288, 288, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, },
775 { 320, { { BLACKBIRD_AUDIO_BITS_LAYER_1_320, 320, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, },
776 { 352, { { BLACKBIRD_AUDIO_BITS_LAYER_1_352, 352, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
777 { 384, { { BLACKBIRD_AUDIO_BITS_LAYER_1_384, 384, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
778 { 416, { { BLACKBIRD_AUDIO_BITS_LAYER_1_416, 416, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
779 { 448, { { BLACKBIRD_AUDIO_BITS_LAYER_1_448, 448, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, },
780};
781static const int BITRATES_SIZE = ARRAY_SIZE(mpeg_audio_bitrates);
782
783static void blackbird_set_default_params(struct cx8802_dev *dev)
784{
785 struct v4l2_mpeg_compression *params = &dev->params;
786 u32 au_params;
787
788 /* assign stream type */
789 if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) )
790 params->st_type = V4L2_MPEG_PS_2;
791 if( params->st_type == V4L2_MPEG_SS_1 )
792 params->vi_type = V4L2_MPEG_VI_1;
793 else
794 params->vi_type = V4L2_MPEG_VI_2;
795 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]);
796
797 /* assign framerate */
798 if( params->vi_frame_rate <= 25 )
799 {
800 params->vi_frame_rate = 25;
801 blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25);
802 }
803 else
804 {
805 params->vi_frame_rate = 30;
806 blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30);
807 }
808
809 /* assign aspect ratio */
810 if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) )
811 params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3;
812 blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]);
813
814 /* assign gop properties */
815 blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1);
816
817 /* assign gop closure */
818 blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, params->closed_gops);
819
820 /* assign 3 2 pulldown */
821 blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, params->pulldown);
822
823 /* make sure the params are within bounds */
824 if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
825 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
826 if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
827 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
828 if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
829 params->au_bitrate.mode = V4L2_BITRATE_NONE;
830
831 /* assign audio properties */
832 /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */
833 au_params = BLACKBIRD_AUDIO_BITS_STEREO |
834 /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */
835 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE |
836 BLACKBIRD_AUDIO_BITS_CRC_OFF |
837 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF |
838 BLACKBIRD_AUDIO_BITS_COPY |
839 0;
840 if( params->au_sample_rate <= 32000 )
841 {
842 params->au_sample_rate = 32000;
843 au_params |= BLACKBIRD_AUDIO_BITS_32000HZ;
844 }
845 else if( params->au_sample_rate <= 44100 )
846 {
847 params->au_sample_rate = 44100;
848 au_params |= BLACKBIRD_AUDIO_BITS_44100HZ;
849 }
850 else
851 {
852 params->au_sample_rate = 48000;
853 au_params |= BLACKBIRD_AUDIO_BITS_48000HZ;
854 }
855 if( params->au_type == V4L2_MPEG_AU_2_I )
856 {
857 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1;
858 }
859 else
860 {
861 /* TODO: try to handle the other formats more gracefully */
862 params->au_type = V4L2_MPEG_AU_2_II;
863 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2;
864 }
865 if( params->au_bitrate.mode )
866 {
867 int layer;
868
869 if( params->au_bitrate.mode == V4L2_BITRATE_CBR )
870 params->au_bitrate.max = params->vi_bitrate.target;
871 else
872 params->au_bitrate.target = params->vi_bitrate.max;
873
874 layer = params->au_type;
875 if( params->au_bitrate.target == 0 )
876 {
877 /* TODO: use the minimum possible bitrate instead of 0 ? */
878 au_params |= 0;
879 }
880 else if( params->au_bitrate.target >=
881 mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate )
882 {
883 /* clamp the bitrate to the max supported by the standard */
884 params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate;
885 params->au_bitrate.max = params->au_bitrate.target;
886 au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits;
887 }
888 else
889 {
890 /* round up to the nearest supported bitrate */
891 int i;
892 for(i = 1; i < BITRATES_SIZE; i++)
893 {
894 if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate &&
895 params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate )
896 {
897 params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate;
898 params->au_bitrate.max = params->au_bitrate.target;
899 au_params |= mpeg_audio_bitrates[i].layer[layer].bits;
900 break;
901 }
902 }
903 }
904 }
905 else
906 {
907 /* TODO: ??? */
908 params->au_bitrate.target = params->au_bitrate.max = 0;
909 au_params |= 0;
910 }
911 blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, au_params );
912
913 /* assign bitrates */
914 if( params->vi_bitrate.mode )
915 {
916 /* bitrate is set, let's figure out the cbr/vbr mess */
917 if( params->vi_bitrate.max < params->vi_bitrate.target )
918 {
919 if( params->vi_bitrate.mode == V4L2_BITRATE_CBR )
920 params->vi_bitrate.max = params->vi_bitrate.target;
921 else
922 params->vi_bitrate.target = params->vi_bitrate.max;
923 }
924 }
925 else
926 {
927 if( params->st_bitrate.max < params->st_bitrate.target )
928 {
929 if( params->st_bitrate.mode == V4L2_BITRATE_VBR )
930 params->st_bitrate.target = params->st_bitrate.max;
931 else
932 params->st_bitrate.max = params->st_bitrate.target;
933 }
934 /* calculate vi_bitrate = st_bitrate - au_bitrate */
935 params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max;
936 params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target;
937 }
938 blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 4, 0,
939 mpeg_video_bitrates[params->vi_bitrate.mode],
940 params->vi_bitrate.target * 1000, /* kbps -> bps */
941 params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */
942 BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */
943
944 /* TODO: implement the stream ID stuff:
945 ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr,
946 ps_size, au_pesid, vi_pesid
947 */
948}
949#define CHECK_PARAM( name ) ( dev->params.name != params->name )
950#define IF_PARAM( name ) if( CHECK_PARAM( name ) )
951#define UPDATE_PARAM( name ) dev->params.name = params->name
952void blackbird_set_params(struct cx8802_dev *dev, struct v4l2_mpeg_compression *params)
953{
954 u32 au_params;
955
956 /* assign stream type */
957 if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) )
958 params->st_type = V4L2_MPEG_PS_2;
959 if( params->st_type == V4L2_MPEG_SS_1 )
960 params->vi_type = V4L2_MPEG_VI_1;
961 else
962 params->vi_type = V4L2_MPEG_VI_2;
963 if( CHECK_PARAM( st_type ) || CHECK_PARAM( vi_type ) )
964 {
965 UPDATE_PARAM( st_type );
966 UPDATE_PARAM( vi_type );
967 blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]);
968 }
969
970 /* assign framerate */
971 if( params->vi_frame_rate <= 25 )
972 params->vi_frame_rate = 25;
973 else
974 params->vi_frame_rate = 30;
975 IF_PARAM( vi_frame_rate )
976 {
977 UPDATE_PARAM( vi_frame_rate );
978 if( params->vi_frame_rate == 25 )
979 blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25);
980 else
981 blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30);
982 }
983
984 /* assign aspect ratio */
985 if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) )
986 params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3;
987 IF_PARAM( vi_aspect_ratio )
988 {
989 UPDATE_PARAM( vi_aspect_ratio );
990 blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]);
991 }
992
993 /* assign gop properties */
994 if( CHECK_PARAM( vi_frames_per_gop ) || CHECK_PARAM( vi_bframes_count ) )
995 {
996 UPDATE_PARAM( vi_frames_per_gop );
997 UPDATE_PARAM( vi_bframes_count );
998 blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1);
999 }
1000
1001 /* assign gop closure */
1002 IF_PARAM( closed_gops )
1003 {
1004 UPDATE_PARAM( closed_gops );
1005 blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, params->closed_gops);
1006 }
1007
1008 /* assign 3 2 pulldown */
1009 IF_PARAM( pulldown )
1010 {
1011 UPDATE_PARAM( pulldown );
1012 blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, params->pulldown);
1013 }
1014
1015 /* make sure the params are within bounds */
1016 if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
1017 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
1018 if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
1019 params->vi_bitrate.mode = V4L2_BITRATE_NONE;
1020 if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) )
1021 params->au_bitrate.mode = V4L2_BITRATE_NONE;
1022
1023 /* assign audio properties */
1024 /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */
1025 au_params = BLACKBIRD_AUDIO_BITS_STEREO |
1026 /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */
1027 BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE |
1028 BLACKBIRD_AUDIO_BITS_CRC_OFF |
1029 BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF |
1030 BLACKBIRD_AUDIO_BITS_COPY |
1031 0;
1032 if( params->au_sample_rate < 32000 )
1033 {
1034 params->au_sample_rate = 32000;
1035 au_params |= BLACKBIRD_AUDIO_BITS_32000HZ;
1036 }
1037 else if( params->au_sample_rate < 44100 )
1038 {
1039 params->au_sample_rate = 44100;
1040 au_params |= BLACKBIRD_AUDIO_BITS_44100HZ;
1041 }
1042 else
1043 {
1044 params->au_sample_rate = 48000;
1045 au_params |= BLACKBIRD_AUDIO_BITS_48000HZ;
1046 }
1047 if( params->au_type == V4L2_MPEG_AU_2_I )
1048 {
1049 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1;
1050 }
1051 else
1052 {
1053 /* TODO: try to handle the other formats more gracefully */
1054 params->au_type = V4L2_MPEG_AU_2_II;
1055 au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2;
1056 }
1057 if( params->au_bitrate.mode )
1058 {
1059 int layer;
1060
1061 if( params->au_bitrate.mode == V4L2_BITRATE_CBR )
1062 params->au_bitrate.max = params->vi_bitrate.target;
1063 else
1064 params->au_bitrate.target = params->vi_bitrate.max;
1065
1066 layer = params->au_type;
1067 if( params->au_bitrate.target == 0 )
1068 {
1069 /* TODO: use the minimum possible bitrate instead of 0 ? */
1070 au_params |= 0;
1071 }
1072 else if( params->au_bitrate.target >=
1073 mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate )
1074 {
1075 /* clamp the bitrate to the max supported by the standard */
1076 params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate;
1077 params->au_bitrate.max = params->au_bitrate.target;
1078 au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits;
1079 }
1080 else
1081 {
1082 /* round up to the nearest supported bitrate */
1083 int i;
1084 for(i = 1; i < BITRATES_SIZE; i++)
1085 {
1086 if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate &&
1087 params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate )
1088 {
1089 params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate;
1090 params->au_bitrate.max = params->au_bitrate.target;
1091 au_params |= mpeg_audio_bitrates[i].layer[layer].bits;
1092 break;
1093 }
1094 }
1095 }
1096 }
1097 else
1098 {
1099 /* TODO: ??? */
1100 params->au_bitrate.target = params->au_bitrate.max = 0;
1101 au_params |= 0;
1102 }
1103 if( CHECK_PARAM( au_type ) || CHECK_PARAM( au_sample_rate )
1104 || CHECK_PARAM( au_bitrate.mode ) || CHECK_PARAM( au_bitrate.max )
1105 || CHECK_PARAM( au_bitrate.target )
1106 )
1107 {
1108 UPDATE_PARAM( au_type );
1109 UPDATE_PARAM( au_sample_rate );
1110 UPDATE_PARAM( au_bitrate );
1111 blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, au_params );
1112 }
1113
1114 /* assign bitrates */
1115 if( params->vi_bitrate.mode )
1116 {
1117 /* bitrate is set, let's figure out the cbr/vbr mess */
1118 if( params->vi_bitrate.max < params->vi_bitrate.target )
1119 {
1120 if( params->vi_bitrate.mode == V4L2_BITRATE_CBR )
1121 params->vi_bitrate.max = params->vi_bitrate.target;
1122 else
1123 params->vi_bitrate.target = params->vi_bitrate.max;
1124 }
1125 }
1126 else
1127 {
1128 if( params->st_bitrate.max < params->st_bitrate.target )
1129 {
1130 if( params->st_bitrate.mode == V4L2_BITRATE_VBR )
1131 params->st_bitrate.target = params->st_bitrate.max;
1132 else
1133 params->st_bitrate.max = params->st_bitrate.target;
1134 }
1135 /* calculate vi_bitrate = st_bitrate - au_bitrate */
1136 params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max;
1137 params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target;
1138 }
1139 UPDATE_PARAM( st_bitrate );
1140 if( CHECK_PARAM( vi_bitrate.mode ) || CHECK_PARAM( vi_bitrate.max )
1141 || CHECK_PARAM( vi_bitrate.target )
1142 )
1143 {
1144 UPDATE_PARAM( vi_bitrate );
1145 blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 4, 0,
1146 mpeg_video_bitrates[params->vi_bitrate.mode],
1147 params->vi_bitrate.target * 1000, /* kbps -> bps */
1148 params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */
1149 BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */
1150 }
1151
1152 /* TODO: implement the stream ID stuff:
1153 ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr,
1154 ps_size, au_pesid, vi_pesid
1155 */
1156 UPDATE_PARAM( ts_pid_pmt );
1157 UPDATE_PARAM( ts_pid_audio );
1158 UPDATE_PARAM( ts_pid_video );
1159 UPDATE_PARAM( ts_pid_pcr );
1160 UPDATE_PARAM( ps_size );
1161 UPDATE_PARAM( au_pesid );
1162 UPDATE_PARAM( vi_pesid );
1163}
1164
1165static void blackbird_set_default_dnr_params(struct cx8802_dev *dev)
1166{
1167 /* assign dnr filter mode */
1168 if( dev->dnr_params.mode > BLACKBIRD_DNR_BITS_AUTO )
1169 dev->dnr_params.mode = BLACKBIRD_DNR_BITS_MANUAL;
1170 if( dev->dnr_params.type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL )
1171 dev->dnr_params.type = BLACKBIRD_MEDIAN_FILTER_DISABLED;
1172 blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MODE, 2, 0,
1173 dev->dnr_params.mode,
1174 dev->dnr_params.type
1175 );
1176
1177 /* assign dnr filter props*/
1178 if( dev->dnr_params.spatial > 15 )
1179 dev->dnr_params.spatial = 15;
1180 if( dev->dnr_params.temporal > 31 )
1181 dev->dnr_params.temporal = 31;
1182 blackbird_api_cmd(dev, BLACKBIRD_API_SET_MANUAL_DNR, 2, 0,
1183 dev->dnr_params.spatial,
1184 dev->dnr_params.temporal
1185 );
1186}
1187#define CHECK_DNR_PARAM( name ) ( dev->dnr_params.name != dnr_params->name )
1188#define UPDATE_DNR_PARAM( name ) dev->dnr_params.name = dnr_params->name
1189void blackbird_set_dnr_params(struct cx8802_dev *dev, struct blackbird_dnr* dnr_params)
1190{
1191 /* assign dnr filter mode */
1192 /* clamp values */
1193 if( dnr_params->mode > BLACKBIRD_DNR_BITS_AUTO )
1194 dnr_params->mode = BLACKBIRD_DNR_BITS_MANUAL;
1195 if( dnr_params->type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL )
1196 dnr_params->type = BLACKBIRD_MEDIAN_FILTER_DISABLED;
1197 /* check if the params actually changed */
1198 if( CHECK_DNR_PARAM( mode ) || CHECK_DNR_PARAM( type ) )
1199 {
1200 UPDATE_DNR_PARAM( mode );
1201 UPDATE_DNR_PARAM( type );
1202 blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MODE, 2, 0, dnr_params->mode, dnr_params->type);
1203 }
1204
1205 /* assign dnr filter props*/
1206 if( dnr_params->spatial > 15 )
1207 dnr_params->spatial = 15;
1208 if( dnr_params->temporal > 31 )
1209 dnr_params->temporal = 31;
1210 if( CHECK_DNR_PARAM( spatial ) || CHECK_DNR_PARAM( temporal ) )
1211 {
1212 UPDATE_DNR_PARAM( spatial );
1213 UPDATE_DNR_PARAM( temporal );
1214 blackbird_api_cmd(dev, BLACKBIRD_API_SET_MANUAL_DNR, 2, 0, dnr_params->spatial, dnr_params->temporal);
1215 }
1216}
1217
1218static void blackbird_codec_settings(struct cx8802_dev *dev)
1219{
1220
1221 /* assign output port */
1222 blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */
1223
1224 /* assign frame size */
1225 blackbird_api_cmd(dev, BLACKBIRD_API_SET_RESOLUTION, 2, 0,
1226 dev->height, dev->width);
1227
1228 /* assign coring levels (luma_h, luma_l, chroma_h, chroma_l) */
1229 blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MEDIAN, 4, 0, 0, 255, 0, 255);
1230
1231 /* assign spatial filter type: luma_t: horiz_only, chroma_t: horiz_only */
1232 blackbird_api_cmd(dev, BLACKBIRD_API_SET_SPATIAL_FILTER, 2, 0,
1233 BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ,
1234 BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ
1235 );
1236
1237 /* assign frame drop rate */
1238 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_DROP_RATE, 1, 0, 0); */
1239
1240 blackbird_set_default_params(dev);
1241 blackbird_set_default_dnr_params(dev);
1242}
1243
1244static int blackbird_initialize_codec(struct cx8802_dev *dev) 564static int blackbird_initialize_codec(struct cx8802_dev *dev)
1245{ 565{
1246 struct cx88_core *core = dev->core; 566 struct cx88_core *core = dev->core;
@@ -1248,7 +568,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
1248 int retval; 568 int retval;
1249 569
1250 dprintk(1,"Initialize codec\n"); 570 dprintk(1,"Initialize codec\n");
1251 retval = blackbird_api_cmd(dev, BLACKBIRD_API_PING, 0, 0); /* ping */ 571 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
1252 if (retval < 0) { 572 if (retval < 0) {
1253 /* ping was not successful, reset and upload firmware */ 573 /* ping was not successful, reset and upload firmware */
1254 cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */ 574 cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */
@@ -1263,13 +583,13 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
1263 if (dev->mailbox < 0) 583 if (dev->mailbox < 0)
1264 return -1; 584 return -1;
1265 585
1266 retval = blackbird_api_cmd(dev, BLACKBIRD_API_PING, 0, 0); /* ping */ 586 retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */
1267 if (retval < 0) { 587 if (retval < 0) {
1268 dprintk(0, "ERROR: Firmware ping failed!\n"); 588 dprintk(0, "ERROR: Firmware ping failed!\n");
1269 return -1; 589 return -1;
1270 } 590 }
1271 591
1272 retval = blackbird_api_cmd(dev, BLACKBIRD_API_GET_VERSION, 0, 1, &version); 592 retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version);
1273 if (retval < 0) { 593 if (retval < 0) {
1274 dprintk(0, "ERROR: Firmware get encoder version failed!\n"); 594 dprintk(0, "ERROR: Firmware get encoder version failed!\n");
1275 return -1; 595 return -1;
@@ -1289,35 +609,35 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
1289 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xef, 0xef); 609 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xef, 0xef);
1290 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xf0, 0xf0); 610 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0xf0, 0xf0);
1291 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0x180, 0x180); */ 611 blackbird_api_cmd(dev, IVTV_API_ASSIGN_NUM_VSYNC_LINES, 4, 0, 0x180, 0x180); */
1292 blackbird_api_cmd(dev, BLACKBIRD_API_SET_CAPTURE_LINES, 2, 0, 612 blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,
1293 BLACKBIRD_FIELD1_SAA7115, 613 BLACKBIRD_FIELD1_SAA7115,
1294 BLACKBIRD_FIELD1_SAA7115 614 BLACKBIRD_FIELD2_SAA7115
1295 ); 615 );
1296 616
1297 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_PLACEHOLDER, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); */ 617 /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_PLACEHOLDER, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); */
1298 blackbird_api_cmd(dev, BLACKBIRD_API_SET_CUSTOM_DATA, 12, 0, 618 blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,
1299 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 619 BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,
1300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 620 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1301 621
1302 /* initialize the video input */ 622 /* initialize the video input */
1303 blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); 623 blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0);
1304 624
1305 msleep(1); 625 msleep(1);
1306 626
1307 blackbird_api_cmd(dev, BLACKBIRD_API_MUTE_VIDEO, 1, 0, BLACKBIRD_UNMUTE); 627 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_VIDEO, 1, 0, BLACKBIRD_UNMUTE);
1308 msleep(1); 628 msleep(1);
1309 blackbird_api_cmd(dev, BLACKBIRD_API_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE); 629 blackbird_api_cmd(dev, CX2341X_ENC_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE);
1310 msleep(1); 630 msleep(1);
1311 631
1312 /* start capturing to the host interface */ 632 /* start capturing to the host interface */
1313 /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); */ 633 /* blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, 0, 0x13); */
1314 blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 634 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
1315 BLACKBIRD_MPEG_CAPTURE, 635 BLACKBIRD_MPEG_CAPTURE,
1316 BLACKBIRD_RAW_BITS_NONE 636 BLACKBIRD_RAW_BITS_NONE
1317 ); 637 );
1318 msleep(10); 638 msleep(10);
1319 639
1320 blackbird_api_cmd(dev, BLACKBIRD_API_REFRESH_INPUT, 0,0); 640 blackbird_api_cmd(dev, CX2341X_ENC_REFRESH_INPUT, 0,0);
1321 return 0; 641 return 0;
1322} 642}
1323 643
@@ -1485,14 +805,52 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
1485 { 805 {
1486 struct v4l2_mpeg_compression *f = arg; 806 struct v4l2_mpeg_compression *f = arg;
1487 807
1488 memcpy(f,&dev->params,sizeof(*f)); 808 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
809 "Replace with VIDIOC_G_EXT_CTRLS!");
810 memcpy(f,&default_mpeg_params,sizeof(*f));
1489 return 0; 811 return 0;
1490 } 812 }
1491 case VIDIOC_S_MPEGCOMP: 813 case VIDIOC_S_MPEGCOMP:
814 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
815 "Replace with VIDIOC_S_EXT_CTRLS!");
816 return 0;
817 case VIDIOC_G_EXT_CTRLS:
1492 { 818 {
1493 struct v4l2_mpeg_compression *f = arg; 819 struct v4l2_ext_controls *f = arg;
1494 820
1495 blackbird_set_params(dev, f); 821 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
822 return -EINVAL;
823 return cx2341x_ext_ctrls(&dev->params, f, cmd);
824 }
825 case VIDIOC_S_EXT_CTRLS:
826 case VIDIOC_TRY_EXT_CTRLS:
827 {
828 struct v4l2_ext_controls *f = arg;
829 struct cx2341x_mpeg_params p;
830 int err;
831
832 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
833 return -EINVAL;
834 p = dev->params;
835 err = cx2341x_ext_ctrls(&p, f, cmd);
836 if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) {
837 err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p);
838 dev->params = p;
839 }
840 return err;
841 }
842 case VIDIOC_S_FREQUENCY:
843 {
844 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
845 BLACKBIRD_END_NOW,
846 BLACKBIRD_MPEG_CAPTURE,
847 BLACKBIRD_RAW_BITS_NONE);
848
849 cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook );
850
851 blackbird_initialize_codec(dev);
852 cx88_set_scale(dev->core, dev->width, dev->height,
853 fh->mpegq.field);
1496 return 0; 854 return 0;
1497 } 855 }
1498 856
@@ -1562,13 +920,14 @@ static int mpeg_release(struct inode *inode, struct file *file)
1562{ 920{
1563 struct cx8802_fh *fh = file->private_data; 921 struct cx8802_fh *fh = file->private_data;
1564 922
1565 /* blackbird_api_cmd(fh->dev, BLACKBIRD_API_END_CAPTURE, 3, 0, BLACKBIRD_END_NOW, 0, 0x13); */ 923 /* blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, BLACKBIRD_END_NOW, 0, 0x13); */
1566 blackbird_api_cmd(fh->dev, BLACKBIRD_API_END_CAPTURE, 3, 0, 924 blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1567 BLACKBIRD_END_NOW, 925 BLACKBIRD_END_NOW,
1568 BLACKBIRD_MPEG_CAPTURE, 926 BLACKBIRD_MPEG_CAPTURE,
1569 BLACKBIRD_RAW_BITS_NONE 927 BLACKBIRD_RAW_BITS_NONE
1570 ); 928 );
1571 929
930 cx8802_cancel_buffers(fh->dev);
1572 /* stop mpeg capture */ 931 /* stop mpeg capture */
1573 if (fh->mpegq.streaming) 932 if (fh->mpegq.streaming)
1574 videobuf_streamoff(&fh->mpegq); 933 videobuf_streamoff(&fh->mpegq);
@@ -1683,19 +1042,13 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev,
1683 dev->core = core; 1042 dev->core = core;
1684 dev->width = 720; 1043 dev->width = 720;
1685 dev->height = 576; 1044 dev->height = 576;
1686 memcpy(&dev->params,&default_mpeg_params,sizeof(default_mpeg_params)); 1045 cx2341x_fill_defaults(&dev->params);
1687 memcpy(&dev->dnr_params,&default_dnr_params,sizeof(default_dnr_params)); 1046 dev->params.port = CX2341X_PORT_STREAMING;
1688
1689 if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN) {
1690
1691 if (core->tuner_formats & V4L2_STD_525_60) {
1692 dev->height = 480;
1693 dev->params.vi_frame_rate = 30;
1694 } else {
1695 dev->height = 576;
1696 dev->params.vi_frame_rate = 25;
1697 }
1698 1047
1048 if (core->tvnorm->id & V4L2_STD_525_60) {
1049 dev->height = 480;
1050 } else {
1051 dev->height = 576;
1699 } 1052 }
1700 1053
1701 err = cx8802_init_common(dev); 1054 err = cx8802_init_common(dev);
@@ -1781,8 +1134,6 @@ module_exit(blackbird_fini);
1781 1134
1782EXPORT_SYMBOL(cx88_ioctl_hook); 1135EXPORT_SYMBOL(cx88_ioctl_hook);
1783EXPORT_SYMBOL(cx88_ioctl_translator); 1136EXPORT_SYMBOL(cx88_ioctl_translator);
1784EXPORT_SYMBOL(blackbird_set_params);
1785EXPORT_SYMBOL(blackbird_set_dnr_params);
1786 1137
1787/* ----------------------------------------------------------- */ 1138/* ----------------------------------------------------------- */
1788/* 1139/*
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index f80154b87d22..67cdd8270863 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -114,7 +114,7 @@ struct cx88_board cx88_boards[] = {
114 .radio = { 114 .radio = {
115 .type = CX88_RADIO, 115 .type = CX88_RADIO,
116 .gpio0 = 0xff10, 116 .gpio0 = 0xff10,
117 }, 117 },
118 }, 118 },
119 [CX88_BOARD_ATI_WONDER_PRO] = { 119 [CX88_BOARD_ATI_WONDER_PRO] = {
120 .name = "ATI TV Wonder Pro", 120 .name = "ATI TV Wonder Pro",
@@ -267,7 +267,7 @@ struct cx88_board cx88_boards[] = {
267 .gpio1 = 0x00007004, 267 .gpio1 = 0x00007004,
268 .gpio2 = 0x0035d700, 268 .gpio2 = 0x0035d700,
269 .gpio3 = 0x02000000, 269 .gpio3 = 0x02000000,
270 }, 270 },
271 }, 271 },
272 [CX88_BOARD_LEADTEK_PVR2000] = { 272 [CX88_BOARD_LEADTEK_PVR2000] = {
273 // gpio values for PAL version from regspy by DScaler 273 // gpio values for PAL version from regspy by DScaler
@@ -413,7 +413,7 @@ struct cx88_board cx88_boards[] = {
413 .type = CX88_VMUX_COMPOSITE1, 413 .type = CX88_VMUX_COMPOSITE1,
414 .vmux = 1, 414 .vmux = 1,
415 .gpio0 = 0x000027df, 415 .gpio0 = 0x000027df,
416 },{ 416 },{
417 .type = CX88_VMUX_SVIDEO, 417 .type = CX88_VMUX_SVIDEO,
418 .vmux = 2, 418 .vmux = 2,
419 .gpio0 = 0x000027df, 419 .gpio0 = 0x000027df,
@@ -536,7 +536,7 @@ struct cx88_board cx88_boards[] = {
536 .type = CX88_VMUX_COMPOSITE1, 536 .type = CX88_VMUX_COMPOSITE1,
537 .vmux = 1, 537 .vmux = 1,
538 .gpio0 = 0x000027df, 538 .gpio0 = 0x000027df,
539 },{ 539 },{
540 .type = CX88_VMUX_SVIDEO, 540 .type = CX88_VMUX_SVIDEO,
541 .vmux = 2, 541 .vmux = 2,
542 .gpio0 = 0x000027df, 542 .gpio0 = 0x000027df,
@@ -759,7 +759,7 @@ struct cx88_board cx88_boards[] = {
759 }, 759 },
760 [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = { 760 [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = {
761 .name = "DViCO FusionHDTV 5 Gold", 761 .name = "DViCO FusionHDTV 5 Gold",
762 .tuner_type = TUNER_LG_TDVS_H062F, 762 .tuner_type = TUNER_LG_TDVS_H06XF, /* TDVS-H062F */
763 .radio_type = UNSET, 763 .radio_type = UNSET,
764 .tuner_addr = ADDR_UNSET, 764 .tuner_addr = ADDR_UNSET,
765 .radio_addr = ADDR_UNSET, 765 .radio_addr = ADDR_UNSET,
@@ -1050,11 +1050,7 @@ struct cx88_board cx88_boards[] = {
1050 .dvb = 1, 1050 .dvb = 1,
1051 }, 1051 },
1052 [CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT] = { 1052 [CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT] = {
1053 /* FIXME: Standard video using the cx88 broadcast decoder is 1053 /* FIXME: Audio not working for s-video / composite inputs. */
1054 * working, but blackbird isn't working yet, audio is only
1055 * working correctly for television mode. S-Video and Composite
1056 * are working for video-only, so I have them disabled for now.
1057 */
1058 .name = "KWorld HardwareMpegTV XPert", 1054 .name = "KWorld HardwareMpegTV XPert",
1059 .tuner_type = TUNER_PHILIPS_TDA8290, 1055 .tuner_type = TUNER_PHILIPS_TDA8290,
1060 .radio_type = UNSET, 1056 .radio_type = UNSET,
@@ -1065,12 +1061,21 @@ struct cx88_board cx88_boards[] = {
1065 .vmux = 0, 1061 .vmux = 0,
1066 .gpio0 = 0x3de2, 1062 .gpio0 = 0x3de2,
1067 .gpio2 = 0x00ff, 1063 .gpio2 = 0x00ff,
1064 },{
1065 .type = CX88_VMUX_COMPOSITE1,
1066 .vmux = 1,
1067 .gpio0 = 0x3de6,
1068 },{
1069 .type = CX88_VMUX_SVIDEO,
1070 .vmux = 2,
1071 .gpio0 = 0x3de6,
1068 }}, 1072 }},
1069 .radio = { 1073 .radio = {
1070 .type = CX88_RADIO, 1074 .type = CX88_RADIO,
1071 .gpio0 = 0x3de6, 1075 .gpio0 = 0x3de6,
1072 .gpio2 = 0x00ff, 1076 .gpio2 = 0x00ff,
1073 }, 1077 },
1078 .blackbird = 1,
1074 }, 1079 },
1075 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = { 1080 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = {
1076 .name = "DViCO FusionHDTV DVB-T Hybrid", 1081 .name = "DViCO FusionHDTV DVB-T Hybrid",
@@ -1093,7 +1098,102 @@ struct cx88_board cx88_boards[] = {
1093 }}, 1098 }},
1094 .dvb = 1, 1099 .dvb = 1,
1095 }, 1100 },
1096 1101 [CX88_BOARD_PCHDTV_HD5500] = {
1102 .name = "pcHDTV HD5500 HDTV",
1103 .tuner_type = TUNER_LG_TDVS_H06XF, /* TDVS-H064F */
1104 .radio_type = UNSET,
1105 .tuner_addr = ADDR_UNSET,
1106 .radio_addr = ADDR_UNSET,
1107 .tda9887_conf = TDA9887_PRESENT,
1108 .input = {{
1109 .type = CX88_VMUX_TELEVISION,
1110 .vmux = 0,
1111 .gpio0 = 0x87fd,
1112 },{
1113 .type = CX88_VMUX_COMPOSITE1,
1114 .vmux = 1,
1115 .gpio0 = 0x87f9,
1116 },{
1117 .type = CX88_VMUX_SVIDEO,
1118 .vmux = 2,
1119 .gpio0 = 0x87f9,
1120 }},
1121 .dvb = 1,
1122 },
1123 [CX88_BOARD_KWORLD_MCE200_DELUXE] = {
1124 /* FIXME: tested TV input only, disabled composite,
1125 svideo and radio until they can be tested also. */
1126 .name = "Kworld MCE 200 Deluxe",
1127 .tuner_type = TUNER_TENA_9533_DI,
1128 .radio_type = UNSET,
1129 .tda9887_conf = TDA9887_PRESENT,
1130 .tuner_addr = ADDR_UNSET,
1131 .radio_addr = ADDR_UNSET,
1132 .input = {{
1133 .type = CX88_VMUX_TELEVISION,
1134 .vmux = 0,
1135 .gpio0 = 0x0000BDE6
1136 }},
1137 .blackbird = 1,
1138 },
1139 [CX88_BOARD_PIXELVIEW_PLAYTV_P7000] = {
1140 /* FIXME: SVideo, Composite and FM inputs are untested */
1141 .name = "PixelView PlayTV P7000",
1142 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
1143 .radio_type = UNSET,
1144 .tuner_addr = ADDR_UNSET,
1145 .radio_addr = ADDR_UNSET,
1146 .tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE |
1147 TDA9887_PORT2_ACTIVE,
1148 .input = {{
1149 .type = CX88_VMUX_TELEVISION,
1150 .vmux = 0,
1151 .gpio0 = 0x5da6,
1152 }},
1153 .blackbird = 1,
1154 },
1155 [CX88_BOARD_NPGTECH_REALTV_TOP10FM] = {
1156 .name = "NPG Tech Real TV FM Top 10",
1157 .tuner_type = TUNER_TNF_5335MF, /* Actually a TNF9535 */
1158 .radio_type = UNSET,
1159 .tuner_addr = ADDR_UNSET,
1160 .radio_addr = ADDR_UNSET,
1161 .input = {{
1162 .type = CX88_VMUX_TELEVISION,
1163 .vmux = 0,
1164 .gpio0 = 0x0788,
1165 },{
1166 .type = CX88_VMUX_COMPOSITE1,
1167 .vmux = 1,
1168 .gpio0 = 0x078b,
1169 },{
1170 .type = CX88_VMUX_SVIDEO,
1171 .vmux = 2,
1172 .gpio0 = 0x078b,
1173 }},
1174 .radio = {
1175 .type = CX88_RADIO,
1176 .gpio0 = 0x074a,
1177 },
1178 },
1179 [CX88_BOARD_WINFAST_DTV2000H] = {
1180 /* video inputs and radio still in testing */
1181 .name = "WinFast DTV2000 H",
1182 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
1183 .radio_type = UNSET,
1184 .tuner_addr = ADDR_UNSET,
1185 .radio_addr = ADDR_UNSET,
1186 .tda9887_conf = TDA9887_PRESENT,
1187 .input = {{
1188 .type = CX88_VMUX_TELEVISION,
1189 .vmux = 0,
1190 .gpio0 = 0x00017304,
1191 .gpio1 = 0x00008203,
1192 .gpio2 = 0x00017304,
1193 .gpio3 = 0x02000000,
1194 }},
1195 .dvb = 1,
1196 },
1097}; 1197};
1098const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 1198const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
1099 1199
@@ -1311,6 +1411,34 @@ struct cx88_subid cx88_subids[] = {
1311 .subvendor = 0x18ac, 1411 .subvendor = 0x18ac,
1312 .subdevice = 0xdb44, 1412 .subdevice = 0xdb44,
1313 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID, 1413 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID,
1414 },{
1415 .subvendor = 0x7063,
1416 .subdevice = 0x5500,
1417 .card = CX88_BOARD_PCHDTV_HD5500,
1418 },{
1419 .subvendor = 0x17de,
1420 .subdevice = 0x0841,
1421 .card = CX88_BOARD_KWORLD_MCE200_DELUXE,
1422 },{
1423 .subvendor = 0x1822,
1424 .subdevice = 0x0019,
1425 .card = CX88_BOARD_DNTV_LIVE_DVB_T_PRO,
1426 },{
1427 .subvendor = 0x1554,
1428 .subdevice = 0x4813,
1429 .card = CX88_BOARD_PIXELVIEW_PLAYTV_P7000,
1430 },{
1431 .subvendor = 0x14f1,
1432 .subdevice = 0x0842,
1433 .card = CX88_BOARD_NPGTECH_REALTV_TOP10FM,
1434 },{
1435 .subvendor = 0x107d,
1436 .subdevice = 0x665e,
1437 .card = CX88_BOARD_WINFAST_DTV2000H,
1438 },{
1439 .subvendor = 0x18ac,
1440 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */
1441 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
1314 }, 1442 },
1315}; 1443};
1316const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1444const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index e1092d5d4628..c56292d8d93b 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -677,7 +677,7 @@ static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
677 677
678static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm) 678static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
679{ 679{
680 return (norm->id & V4L2_STD_625_50) ? 511 : 288; 680 return (norm->id & V4L2_STD_625_50) ? 511 : 400;
681} 681}
682 682
683int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height, 683int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height,
@@ -932,9 +932,9 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
932 htotal, cx_read(MO_HTOTAL), (u32)tmp64); 932 htotal, cx_read(MO_HTOTAL), (u32)tmp64);
933 cx_write(MO_HTOTAL, htotal); 933 cx_write(MO_HTOTAL, htotal);
934 934
935 // vbi stuff 935 // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes
936 cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm) << 11) | */ 936 // the effective vbi offset ~244 samples, the same as the Bt8x8
937 norm_vbipack(norm))); 937 cx_write(MO_VBI_PACKET, (10<<11) | norm_vbipack(norm));
938 938
939 // this is needed as well to set all tvnorm parameter 939 // this is needed as well to set all tvnorm parameter
940 cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED); 940 cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 3619a449aefd..dce1feddd55d 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -51,6 +51,7 @@
51#endif 51#endif
52#ifdef HAVE_LGDT330X 52#ifdef HAVE_LGDT330X
53# include "lgdt330x.h" 53# include "lgdt330x.h"
54# include "lg_h06xf.h"
54#endif 55#endif
55#ifdef HAVE_NXT200X 56#ifdef HAVE_NXT200X
56# include "nxt200x.h" 57# include "nxt200x.h"
@@ -58,6 +59,7 @@
58#ifdef HAVE_CX24123 59#ifdef HAVE_CX24123
59# include "cx24123.h" 60# include "cx24123.h"
60#endif 61#endif
62#include "isl6421.h"
61 63
62MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); 64MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
63MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 65MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
@@ -113,21 +115,6 @@ static struct videobuf_queue_ops dvb_qops = {
113 115
114/* ------------------------------------------------------------------ */ 116/* ------------------------------------------------------------------ */
115 117
116#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
117static int zarlink_pll_set(struct dvb_frontend *fe,
118 struct dvb_frontend_parameters *params,
119 u8 *pllbuf)
120{
121 struct cx8802_dev *dev = fe->dvb->priv;
122
123 pllbuf[0] = dev->core->pll_addr << 1;
124 dvb_pll_configure(dev->core->pll_desc, pllbuf + 1,
125 params->frequency,
126 params->u.ofdm.bandwidth);
127 return 0;
128}
129#endif
130
131#ifdef HAVE_MT352 118#ifdef HAVE_MT352
132static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 119static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
133{ 120{
@@ -196,19 +183,16 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
196static struct mt352_config dvico_fusionhdtv = { 183static struct mt352_config dvico_fusionhdtv = {
197 .demod_address = 0x0F, 184 .demod_address = 0x0F,
198 .demod_init = dvico_fusionhdtv_demod_init, 185 .demod_init = dvico_fusionhdtv_demod_init,
199 .pll_set = zarlink_pll_set,
200}; 186};
201 187
202static struct mt352_config dntv_live_dvbt_config = { 188static struct mt352_config dntv_live_dvbt_config = {
203 .demod_address = 0x0f, 189 .demod_address = 0x0f,
204 .demod_init = dntv_live_dvbt_demod_init, 190 .demod_init = dntv_live_dvbt_demod_init,
205 .pll_set = zarlink_pll_set,
206}; 191};
207 192
208static struct mt352_config dvico_fusionhdtv_dual = { 193static struct mt352_config dvico_fusionhdtv_dual = {
209 .demod_address = 0x0F, 194 .demod_address = 0x0F,
210 .demod_init = dvico_dual_demod_init, 195 .demod_init = dvico_dual_demod_init,
211 .pll_set = zarlink_pll_set,
212}; 196};
213 197
214#ifdef HAVE_VP3054_I2C 198#ifdef HAVE_VP3054_I2C
@@ -246,6 +230,8 @@ static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
246 .buf = fmd1216_init, .len = sizeof(fmd1216_init) }; 230 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
247 int err; 231 int err;
248 232
233 if (fe->ops.i2c_gate_ctrl)
234 fe->ops.i2c_gate_ctrl(fe, 1);
249 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 235 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
250 if (err < 0) 236 if (err < 0)
251 return err; 237 return err;
@@ -256,14 +242,14 @@ static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
256 return 0; 242 return 0;
257} 243}
258 244
259static int dntv_live_dvbt_pro_pll_set(struct dvb_frontend* fe, 245static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
260 struct dvb_frontend_parameters* params, 246 struct dvb_frontend_parameters* params)
261 u8* pllbuf)
262{ 247{
263 struct cx8802_dev *dev= fe->dvb->priv; 248 struct cx8802_dev *dev= fe->dvb->priv;
249 u8 buf[4];
264 struct i2c_msg msg = 250 struct i2c_msg msg =
265 { .addr = dev->core->pll_addr, .flags = 0, 251 { .addr = dev->core->pll_addr, .flags = 0,
266 .buf = pllbuf+1, .len = 4 }; 252 .buf = buf, .len = 4 };
267 int err; 253 int err;
268 254
269 /* Switch PLL to DVB mode */ 255 /* Switch PLL to DVB mode */
@@ -272,14 +258,16 @@ static int dntv_live_dvbt_pro_pll_set(struct dvb_frontend* fe,
272 return err; 258 return err;
273 259
274 /* Tune PLL */ 260 /* Tune PLL */
275 pllbuf[0] = dev->core->pll_addr << 1; 261 dvb_pll_configure(dev->core->pll_desc, buf,
276 dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
277 params->frequency, 262 params->frequency,
278 params->u.ofdm.bandwidth); 263 params->u.ofdm.bandwidth);
264 if (fe->ops.i2c_gate_ctrl)
265 fe->ops.i2c_gate_ctrl(fe, 1);
279 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 266 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
267
280 printk(KERN_WARNING "cx88-dvb: %s error " 268 printk(KERN_WARNING "cx88-dvb: %s error "
281 "(addr %02x <- %02x, err = %i)\n", 269 "(addr %02x <- %02x, err = %i)\n",
282 __FUNCTION__, pllbuf[0], pllbuf[1], err); 270 __FUNCTION__, dev->core->pll_addr, buf[0], err);
283 if (err < 0) 271 if (err < 0)
284 return err; 272 return err;
285 else 273 else
@@ -293,27 +281,27 @@ static struct mt352_config dntv_live_dvbt_pro_config = {
293 .demod_address = 0x0f, 281 .demod_address = 0x0f,
294 .no_tuner = 1, 282 .no_tuner = 1,
295 .demod_init = dntv_live_dvbt_pro_demod_init, 283 .demod_init = dntv_live_dvbt_pro_demod_init,
296 .pll_set = dntv_live_dvbt_pro_pll_set,
297}; 284};
298#endif 285#endif
299#endif 286#endif
300 287
301#ifdef HAVE_ZL10353 288#ifdef HAVE_ZL10353
302static int dvico_hybrid_tune_pll(struct dvb_frontend *fe, 289static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
303 struct dvb_frontend_parameters *params, 290 struct dvb_frontend_parameters *params)
304 u8 *pllbuf)
305{ 291{
292 u8 pllbuf[4];
306 struct cx8802_dev *dev= fe->dvb->priv; 293 struct cx8802_dev *dev= fe->dvb->priv;
307 struct i2c_msg msg = 294 struct i2c_msg msg =
308 { .addr = dev->core->pll_addr, .flags = 0, 295 { .addr = dev->core->pll_addr, .flags = 0,
309 .buf = pllbuf + 1, .len = 4 }; 296 .buf = pllbuf, .len = 4 };
310 int err; 297 int err;
311 298
312 pllbuf[0] = dev->core->pll_addr << 1; 299 dvb_pll_configure(dev->core->pll_desc, pllbuf,
313 dvb_pll_configure(dev->core->pll_desc, pllbuf + 1,
314 params->frequency, 300 params->frequency,
315 params->u.ofdm.bandwidth); 301 params->u.ofdm.bandwidth);
316 302
303 if (fe->ops.i2c_gate_ctrl)
304 fe->ops.i2c_gate_ctrl(fe, 1);
317 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 305 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
318 printk(KERN_WARNING "cx88-dvb: %s error " 306 printk(KERN_WARNING "cx88-dvb: %s error "
319 "(addr %02x <- %02x, err = %i)\n", 307 "(addr %02x <- %02x, err = %i)\n",
@@ -329,12 +317,11 @@ static int dvico_hybrid_tune_pll(struct dvb_frontend *fe,
329 317
330static struct zl10353_config dvico_fusionhdtv_hybrid = { 318static struct zl10353_config dvico_fusionhdtv_hybrid = {
331 .demod_address = 0x0F, 319 .demod_address = 0x0F,
332 .pll_set = dvico_hybrid_tune_pll, 320 .no_tuner = 1,
333}; 321};
334 322
335static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = { 323static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
336 .demod_address = 0x0F, 324 .demod_address = 0x0F,
337 .pll_set = zarlink_pll_set,
338}; 325};
339#endif 326#endif
340 327
@@ -342,21 +329,15 @@ static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
342static struct cx22702_config connexant_refboard_config = { 329static struct cx22702_config connexant_refboard_config = {
343 .demod_address = 0x43, 330 .demod_address = 0x43,
344 .output_mode = CX22702_SERIAL_OUTPUT, 331 .output_mode = CX22702_SERIAL_OUTPUT,
345 .pll_address = 0x60,
346 .pll_desc = &dvb_pll_thomson_dtt7579,
347}; 332};
348 333
349static struct cx22702_config hauppauge_novat_config = { 334static struct cx22702_config hauppauge_novat_config = {
350 .demod_address = 0x43, 335 .demod_address = 0x43,
351 .output_mode = CX22702_SERIAL_OUTPUT, 336 .output_mode = CX22702_SERIAL_OUTPUT,
352 .pll_address = 0x61,
353 .pll_desc = &dvb_pll_thomson_dtt759x,
354}; 337};
355static struct cx22702_config hauppauge_hvr1100_config = { 338static struct cx22702_config hauppauge_hvr1100_config = {
356 .demod_address = 0x63, 339 .demod_address = 0x63,
357 .output_mode = CX22702_SERIAL_OUTPUT, 340 .output_mode = CX22702_SERIAL_OUTPUT,
358 .pll_address = 0x61,
359 .pll_desc = &dvb_pll_fmd1216me,
360}; 341};
361#endif 342#endif
362 343
@@ -371,15 +352,13 @@ static int or51132_set_ts_param(struct dvb_frontend* fe,
371 352
372static struct or51132_config pchdtv_hd3000 = { 353static struct or51132_config pchdtv_hd3000 = {
373 .demod_address = 0x15, 354 .demod_address = 0x15,
374 .pll_address = 0x61,
375 .pll_desc = &dvb_pll_thomson_dtt761x,
376 .set_ts_params = or51132_set_ts_param, 355 .set_ts_params = or51132_set_ts_param,
377}; 356};
378#endif 357#endif
379 358
380#ifdef HAVE_LGDT330X 359#ifdef HAVE_LGDT330X
381static int lgdt330x_pll_set(struct dvb_frontend* fe, 360static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
382 struct dvb_frontend_parameters* params) 361 struct dvb_frontend_parameters* params)
383{ 362{
384 /* FIXME make this routine use the tuner-simple code. 363 /* FIXME make this routine use the tuner-simple code.
385 * It could probably be shared with a number of ATSC 364 * It could probably be shared with a number of ATSC
@@ -392,12 +371,12 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe,
392 { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; 371 { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 };
393 int err; 372 int err;
394 373
395 /* Put the analog decoder in standby to keep it quiet */
396 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
397
398 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); 374 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
399 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", 375 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
400 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); 376 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
377
378 if (fe->ops.i2c_gate_ctrl)
379 fe->ops.i2c_gate_ctrl(fe, 1);
401 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { 380 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
402 printk(KERN_WARNING "cx88-dvb: %s error " 381 printk(KERN_WARNING "cx88-dvb: %s error "
403 "(addr %02x <- %02x, err = %i)\n", 382 "(addr %02x <- %02x, err = %i)\n",
@@ -407,16 +386,21 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe,
407 else 386 else
408 return -EREMOTEIO; 387 return -EREMOTEIO;
409 } 388 }
410 if (core->tuner_type == TUNER_LG_TDVS_H062F) {
411 /* Set the Auxiliary Byte. */
412 buf[2] &= ~0x20;
413 buf[2] |= 0x18;
414 buf[3] = 0x50;
415 i2c_transfer(&core->i2c_adap, &msg, 1);
416 }
417 return 0; 389 return 0;
418} 390}
419 391
392static int lgdt3303_tuner_set_params(struct dvb_frontend* fe,
393 struct dvb_frontend_parameters* params)
394{
395 struct cx8802_dev *dev= fe->dvb->priv;
396 struct cx88_core *core = dev->core;
397
398 /* Put the analog decoder in standby to keep it quiet */
399 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
400
401 return lg_h06xf_pll_set(fe, &core->i2c_adap, params);
402}
403
420static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) 404static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
421{ 405{
422 struct cx8802_dev *dev= fe->dvb->priv; 406 struct cx8802_dev *dev= fe->dvb->priv;
@@ -444,7 +428,6 @@ static struct lgdt330x_config fusionhdtv_3_gold = {
444 .demod_address = 0x0e, 428 .demod_address = 0x0e,
445 .demod_chip = LGDT3302, 429 .demod_chip = LGDT3302,
446 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */ 430 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
447 .pll_set = lgdt330x_pll_set,
448 .set_ts_params = lgdt330x_set_ts_param, 431 .set_ts_params = lgdt330x_set_ts_param,
449}; 432};
450 433
@@ -452,7 +435,13 @@ static struct lgdt330x_config fusionhdtv_5_gold = {
452 .demod_address = 0x0e, 435 .demod_address = 0x0e,
453 .demod_chip = LGDT3303, 436 .demod_chip = LGDT3303,
454 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ 437 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
455 .pll_set = lgdt330x_pll_set, 438 .set_ts_params = lgdt330x_set_ts_param,
439};
440
441static struct lgdt330x_config pchdtv_hd5500 = {
442 .demod_address = 0x59,
443 .demod_chip = LGDT3303,
444 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
456 .set_ts_params = lgdt330x_set_ts_param, 445 .set_ts_params = lgdt330x_set_ts_param,
457}; 446};
458#endif 447#endif
@@ -477,8 +466,6 @@ static int nxt200x_set_pll_input(u8* buf, int input)
477 466
478static struct nxt200x_config ati_hdtvwonder = { 467static struct nxt200x_config ati_hdtvwonder = {
479 .demod_address = 0x0a, 468 .demod_address = 0x0a,
480 .pll_address = 0x61,
481 .pll_desc = &dvb_pll_tuv1236d,
482 .set_pll_input = nxt200x_set_pll_input, 469 .set_pll_input = nxt200x_set_pll_input,
483 .set_ts_params = nxt200x_set_ts_param, 470 .set_ts_params = nxt200x_set_ts_param,
484}; 471};
@@ -493,28 +480,30 @@ static int cx24123_set_ts_param(struct dvb_frontend* fe,
493 return 0; 480 return 0;
494} 481}
495 482
496static void cx24123_enable_lnb_voltage(struct dvb_frontend* fe, int on) 483static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
497{ 484{
498 struct cx8802_dev *dev= fe->dvb->priv; 485 struct cx8802_dev *dev= fe->dvb->priv;
499 struct cx88_core *core = dev->core; 486 struct cx88_core *core = dev->core;
500 487
501 if (on) 488 if (voltage == SEC_VOLTAGE_OFF) {
502 cx_write(MO_GP0_IO, 0x000006f9);
503 else
504 cx_write(MO_GP0_IO, 0x000006fB); 489 cx_write(MO_GP0_IO, 0x000006fB);
490 } else {
491 cx_write(MO_GP0_IO, 0x000006f9);
492 }
493
494 if (core->prev_set_voltage)
495 return core->prev_set_voltage(fe, voltage);
496 return 0;
505} 497}
506 498
507static struct cx24123_config hauppauge_novas_config = { 499static struct cx24123_config hauppauge_novas_config = {
508 .demod_address = 0x55, 500 .demod_address = 0x55,
509 .use_isl6421 = 1,
510 .set_ts_params = cx24123_set_ts_param, 501 .set_ts_params = cx24123_set_ts_param,
511}; 502};
512 503
513static struct cx24123_config kworld_dvbs_100_config = { 504static struct cx24123_config kworld_dvbs_100_config = {
514 .demod_address = 0x15, 505 .demod_address = 0x15,
515 .use_isl6421 = 0,
516 .set_ts_params = cx24123_set_ts_param, 506 .set_ts_params = cx24123_set_ts_param,
517 .enable_lnb_voltage = cx24123_enable_lnb_voltage,
518}; 507};
519#endif 508#endif
520 509
@@ -530,6 +519,11 @@ static int dvb_register(struct cx8802_dev *dev)
530 case CX88_BOARD_HAUPPAUGE_DVB_T1: 519 case CX88_BOARD_HAUPPAUGE_DVB_T1:
531 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, 520 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
532 &dev->core->i2c_adap); 521 &dev->core->i2c_adap);
522 if (dev->dvb.frontend != NULL) {
523 dvb_pll_attach(dev->dvb.frontend, 0x61,
524 &dev->core->i2c_adap,
525 &dvb_pll_thomson_dtt759x);
526 }
533 break; 527 break;
534 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 528 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
535 case CX88_BOARD_CONEXANT_DVB_T1: 529 case CX88_BOARD_CONEXANT_DVB_T1:
@@ -537,44 +531,92 @@ static int dvb_register(struct cx8802_dev *dev)
537 case CX88_BOARD_WINFAST_DTV1000: 531 case CX88_BOARD_WINFAST_DTV1000:
538 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, 532 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
539 &dev->core->i2c_adap); 533 &dev->core->i2c_adap);
534 if (dev->dvb.frontend != NULL) {
535 dvb_pll_attach(dev->dvb.frontend, 0x60,
536 &dev->core->i2c_adap,
537 &dvb_pll_thomson_dtt7579);
538 }
540 break; 539 break;
540 case CX88_BOARD_WINFAST_DTV2000H:
541 case CX88_BOARD_HAUPPAUGE_HVR1100: 541 case CX88_BOARD_HAUPPAUGE_HVR1100:
542 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 542 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
543 dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config, 543 dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config,
544 &dev->core->i2c_adap); 544 &dev->core->i2c_adap);
545 if (dev->dvb.frontend != NULL) {
546 dvb_pll_attach(dev->dvb.frontend, 0x61,
547 &dev->core->i2c_adap,
548 &dvb_pll_fmd1216me);
549 }
545 break; 550 break;
546#endif 551#endif
547#if defined(HAVE_MT352) || defined(HAVE_ZL10353) 552#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
548 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 553 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
549 dev->core->pll_addr = 0x60;
550 dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
551#ifdef HAVE_MT352 554#ifdef HAVE_MT352
552 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 555 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
553 &dev->core->i2c_adap); 556 &dev->core->i2c_adap);
554 if (dev->dvb.frontend != NULL) 557 if (dev->dvb.frontend != NULL) {
558 dvb_pll_attach(dev->dvb.frontend, 0x60,
559 &dev->core->i2c_adap,
560 &dvb_pll_thomson_dtt7579);
555 break; 561 break;
562 }
556#endif 563#endif
557#ifdef HAVE_ZL10353 564#ifdef HAVE_ZL10353
558 /* ZL10353 replaces MT352 on later cards */ 565 /* ZL10353 replaces MT352 on later cards */
559 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1, 566 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1,
560 &dev->core->i2c_adap); 567 &dev->core->i2c_adap);
568 if (dev->dvb.frontend != NULL) {
569 dvb_pll_attach(dev->dvb.frontend, 0x60,
570 &dev->core->i2c_adap,
571 &dvb_pll_thomson_dtt7579);
572 }
573#endif
574 break;
575 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
576#ifdef HAVE_MT352
577 /* The tin box says DEE1601, but it seems to be DTT7579
578 * compatible, with a slightly different MT352 AGC gain. */
579 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual,
580 &dev->core->i2c_adap);
581 if (dev->dvb.frontend != NULL) {
582 dvb_pll_attach(dev->dvb.frontend, 0x61,
583 &dev->core->i2c_adap,
584 &dvb_pll_thomson_dtt7579);
585 break;
586 }
587#endif
588#ifdef HAVE_ZL10353
589 /* ZL10353 replaces MT352 on later cards */
590 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1,
591 &dev->core->i2c_adap);
592 if (dev->dvb.frontend != NULL) {
593 dvb_pll_attach(dev->dvb.frontend, 0x61,
594 &dev->core->i2c_adap,
595 &dvb_pll_thomson_dtt7579);
596 }
561#endif 597#endif
562 break; 598 break;
563#endif /* HAVE_MT352 || HAVE_ZL10353 */ 599#endif /* HAVE_MT352 || HAVE_ZL10353 */
564#ifdef HAVE_MT352 600#ifdef HAVE_MT352
565 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 601 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
566 dev->core->pll_addr = 0x61;
567 dev->core->pll_desc = &dvb_pll_lg_z201;
568 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 602 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
569 &dev->core->i2c_adap); 603 &dev->core->i2c_adap);
604 if (dev->dvb.frontend != NULL) {
605 dvb_pll_attach(dev->dvb.frontend, 0x61,
606 &dev->core->i2c_adap,
607 &dvb_pll_lg_z201);
608 }
570 break; 609 break;
571 case CX88_BOARD_KWORLD_DVB_T: 610 case CX88_BOARD_KWORLD_DVB_T:
572 case CX88_BOARD_DNTV_LIVE_DVB_T: 611 case CX88_BOARD_DNTV_LIVE_DVB_T:
573 case CX88_BOARD_ADSTECH_DVB_T_PCI: 612 case CX88_BOARD_ADSTECH_DVB_T_PCI:
574 dev->core->pll_addr = 0x61;
575 dev->core->pll_desc = &dvb_pll_unknown_1;
576 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 613 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
577 &dev->core->i2c_adap); 614 &dev->core->i2c_adap);
615 if (dev->dvb.frontend != NULL) {
616 dvb_pll_attach(dev->dvb.frontend, 0x61,
617 &dev->core->i2c_adap,
618 &dvb_pll_unknown_1);
619 }
578 break; 620 break;
579 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 621 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
580#ifdef HAVE_VP3054_I2C 622#ifdef HAVE_VP3054_I2C
@@ -582,18 +624,13 @@ static int dvb_register(struct cx8802_dev *dev)
582 dev->core->pll_desc = &dvb_pll_fmd1216me; 624 dev->core->pll_desc = &dvb_pll_fmd1216me;
583 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config, 625 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config,
584 &((struct vp3054_i2c_state *)dev->card_priv)->adap); 626 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
627 if (dev->dvb.frontend != NULL) {
628 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
629 }
585#else 630#else
586 printk("%s: built without vp3054 support\n", dev->core->name); 631 printk("%s: built without vp3054 support\n", dev->core->name);
587#endif 632#endif
588 break; 633 break;
589 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
590 /* The tin box says DEE1601, but it seems to be DTT7579
591 * compatible, with a slightly different MT352 AGC gain. */
592 dev->core->pll_addr = 0x61;
593 dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
594 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual,
595 &dev->core->i2c_adap);
596 break;
597#endif 634#endif
598#ifdef HAVE_ZL10353 635#ifdef HAVE_ZL10353
599 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 636 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
@@ -601,12 +638,20 @@ static int dvb_register(struct cx8802_dev *dev)
601 dev->core->pll_desc = &dvb_pll_thomson_fe6600; 638 dev->core->pll_desc = &dvb_pll_thomson_fe6600;
602 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid, 639 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid,
603 &dev->core->i2c_adap); 640 &dev->core->i2c_adap);
641 if (dev->dvb.frontend != NULL) {
642 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params;
643 }
604 break; 644 break;
605#endif 645#endif
606#ifdef HAVE_OR51132 646#ifdef HAVE_OR51132
607 case CX88_BOARD_PCHDTV_HD3000: 647 case CX88_BOARD_PCHDTV_HD3000:
608 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, 648 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
609 &dev->core->i2c_adap); 649 &dev->core->i2c_adap);
650 if (dev->dvb.frontend != NULL) {
651 dvb_pll_attach(dev->dvb.frontend, 0x61,
652 &dev->core->i2c_adap,
653 &dvb_pll_thomson_dtt761x);
654 }
610 break; 655 break;
611#endif 656#endif
612#ifdef HAVE_LGDT330X 657#ifdef HAVE_LGDT330X
@@ -627,6 +672,9 @@ static int dvb_register(struct cx8802_dev *dev)
627 dev->core->pll_desc = &dvb_pll_microtune_4042; 672 dev->core->pll_desc = &dvb_pll_microtune_4042;
628 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 673 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
629 &dev->core->i2c_adap); 674 &dev->core->i2c_adap);
675 if (dev->dvb.frontend != NULL) {
676 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
677 }
630 } 678 }
631 break; 679 break;
632 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 680 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
@@ -643,6 +691,9 @@ static int dvb_register(struct cx8802_dev *dev)
643 dev->core->pll_desc = &dvb_pll_thomson_dtt761x; 691 dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
644 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 692 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
645 &dev->core->i2c_adap); 693 &dev->core->i2c_adap);
694 if (dev->dvb.frontend != NULL) {
695 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
696 }
646 } 697 }
647 break; 698 break;
648 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 699 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
@@ -655,10 +706,28 @@ static int dvb_register(struct cx8802_dev *dev)
655 mdelay(100); 706 mdelay(100);
656 cx_set(MO_GP0_IO, 1); 707 cx_set(MO_GP0_IO, 1);
657 mdelay(200); 708 mdelay(200);
658 dev->core->pll_addr = 0x61;
659 dev->core->pll_desc = &dvb_pll_tdvs_tua6034;
660 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, 709 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold,
661 &dev->core->i2c_adap); 710 &dev->core->i2c_adap);
711 if (dev->dvb.frontend != NULL) {
712 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
713 }
714 }
715 break;
716 case CX88_BOARD_PCHDTV_HD5500:
717 dev->ts_gen_cntrl = 0x08;
718 {
719 /* Do a hardware reset of chip before using it. */
720 struct cx88_core *core = dev->core;
721
722 cx_clear(MO_GP0_IO, 1);
723 mdelay(100);
724 cx_set(MO_GP0_IO, 1);
725 mdelay(200);
726 dev->dvb.frontend = lgdt330x_attach(&pchdtv_hd5500,
727 &dev->core->i2c_adap);
728 if (dev->dvb.frontend != NULL) {
729 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
730 }
662 } 731 }
663 break; 732 break;
664#endif 733#endif
@@ -666,6 +735,11 @@ static int dvb_register(struct cx8802_dev *dev)
666 case CX88_BOARD_ATI_HDTVWONDER: 735 case CX88_BOARD_ATI_HDTVWONDER:
667 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder, 736 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder,
668 &dev->core->i2c_adap); 737 &dev->core->i2c_adap);
738 if (dev->dvb.frontend != NULL) {
739 dvb_pll_attach(dev->dvb.frontend, 0x61,
740 &dev->core->i2c_adap,
741 &dvb_pll_tuv1236d);
742 }
669 break; 743 break;
670#endif 744#endif
671#ifdef HAVE_CX24123 745#ifdef HAVE_CX24123
@@ -673,10 +747,18 @@ static int dvb_register(struct cx8802_dev *dev)
673 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 747 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
674 dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config, 748 dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config,
675 &dev->core->i2c_adap); 749 &dev->core->i2c_adap);
750 if (dev->dvb.frontend) {
751 isl6421_attach(dev->dvb.frontend, &dev->core->i2c_adap,
752 0x08, 0x00, 0x00);
753 }
676 break; 754 break;
677 case CX88_BOARD_KWORLD_DVBS_100: 755 case CX88_BOARD_KWORLD_DVBS_100:
678 dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config, 756 dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config,
679 &dev->core->i2c_adap); 757 &dev->core->i2c_adap);
758 if (dev->dvb.frontend) {
759 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
760 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
761 }
680 break; 762 break;
681#endif 763#endif
682 default: 764 default:
@@ -690,15 +772,15 @@ static int dvb_register(struct cx8802_dev *dev)
690 } 772 }
691 773
692 if (dev->core->pll_desc) { 774 if (dev->core->pll_desc) {
693 dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min; 775 dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min;
694 dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; 776 dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max;
695 } 777 }
696 778
697 /* Put the analog decoder in standby to keep it quiet */ 779 /* Put the analog decoder in standby to keep it quiet */
698 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); 780 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
699 781
700 /* register everything */ 782 /* register everything */
701 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); 783 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
702} 784}
703 785
704/* ----------------------------------------------------------- */ 786/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index f720901e9638..7efa6def0bde 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -138,13 +138,13 @@ void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
138 return; 138 return;
139 139
140 if (core->dvbdev) { 140 if (core->dvbdev) {
141 if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl) 141 if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl)
142 core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1); 142 core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1);
143 143
144 i2c_clients_command(&core->i2c_adap, cmd, arg); 144 i2c_clients_command(&core->i2c_adap, cmd, arg);
145 145
146 if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl) 146 if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl)
147 core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0); 147 core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0);
148 } else 148 } else
149 i2c_clients_command(&core->i2c_adap, cmd, arg); 149 i2c_clients_command(&core->i2c_adap, cmd, arg);
150} 150}
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 78a63b7dd380..72b630a91f41 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -70,14 +70,33 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
70static void cx88_ir_handle_key(struct cx88_IR *ir) 70static void cx88_ir_handle_key(struct cx88_IR *ir)
71{ 71{
72 struct cx88_core *core = ir->core; 72 struct cx88_core *core = ir->core;
73 u32 gpio, data; 73 u32 gpio, data, auxgpio;
74 74
75 /* read gpio value */ 75 /* read gpio value */
76 gpio = cx_read(ir->gpio_addr); 76 gpio = cx_read(ir->gpio_addr);
77 if (core->board == CX88_BOARD_NPGTECH_REALTV_TOP10FM) {
78 /* This board apparently uses a combination of 2 GPIO
79 to represent the keys. Additionally, the second GPIO
80 can be used for parity.
81
82 Example:
83
84 for key "5"
85 gpio = 0x758, auxgpio = 0xe5 or 0xf5
86 for key "Power"
87 gpio = 0x758, auxgpio = 0xed or 0xfd
88 */
89
90 auxgpio = cx_read(MO_GP1_IO);
91 /* Take out the parity part */
92 gpio+=(gpio & 0x7fd) + (auxgpio & 0xef);
93 } else
94 auxgpio = gpio;
95
77 if (ir->polling) { 96 if (ir->polling) {
78 if (ir->last_gpio == gpio) 97 if (ir->last_gpio == auxgpio)
79 return; 98 return;
80 ir->last_gpio = gpio; 99 ir->last_gpio = auxgpio;
81 } 100 }
82 101
83 /* extract data */ 102 /* extract data */
@@ -172,12 +191,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
172 ir_type = IR_TYPE_RC5; 191 ir_type = IR_TYPE_RC5;
173 ir->sampling = 1; 192 ir->sampling = 1;
174 break; 193 break;
194 case CX88_BOARD_WINFAST_DTV2000H:
175 case CX88_BOARD_WINFAST2000XP_EXPERT: 195 case CX88_BOARD_WINFAST2000XP_EXPERT:
176 ir_codes = ir_codes_winfast; 196 ir_codes = ir_codes_winfast;
177 ir->gpio_addr = MO_GP0_IO; 197 ir->gpio_addr = MO_GP0_IO;
178 ir->mask_keycode = 0x8f8; 198 ir->mask_keycode = 0x8f8;
179 ir->mask_keyup = 0x100; 199 ir->mask_keyup = 0x100;
180 ir->polling = 1; /* ms */ 200 ir->polling = 50; /* ms */
181 break; 201 break;
182 case CX88_BOARD_IODATA_GVBCTV7E: 202 case CX88_BOARD_IODATA_GVBCTV7E:
183 ir_codes = ir_codes_iodata_bctv7e; 203 ir_codes = ir_codes_iodata_bctv7e;
@@ -228,6 +248,12 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
228 ir_type = IR_TYPE_PD; 248 ir_type = IR_TYPE_PD;
229 ir->sampling = 0xff00; /* address */ 249 ir->sampling = 0xff00; /* address */
230 break; 250 break;
251 case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
252 ir_codes = ir_codes_npgtech;
253 ir->gpio_addr = MO_GP0_IO;
254 ir->mask_keycode = 0xfa;
255 ir->polling = 50; /* ms */
256 break;
231 } 257 }
232 258
233 if (NULL == ir_codes) { 259 if (NULL == ir_codes) {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 7d16888b4a86..a9d7795a8e14 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -54,7 +54,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
54{ 54{
55 struct cx88_core *core = dev->core; 55 struct cx88_core *core = dev->core;
56 56
57 dprintk(0, "cx8802_start_dma w: %d, h: %d, f: %d\n", dev->width, dev->height, buf->vb.field); 57 dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", dev->width, dev->height, buf->vb.field);
58 58
59 /* setup fifo + format */ 59 /* setup fifo + format */
60 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 60 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
@@ -76,6 +76,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
76 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 76 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
77 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 77 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
78 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 78 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
79 case CX88_BOARD_PCHDTV_HD5500:
79 cx_write(TS_SOP_STAT, 1<<13); 80 cx_write(TS_SOP_STAT, 1<<13);
80 break; 81 break;
81 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 82 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
@@ -109,7 +110,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
109 q->count = 1; 110 q->count = 1;
110 111
111 /* enable irqs */ 112 /* enable irqs */
112 dprintk( 0, "setting the interrupt mask\n" ); 113 dprintk( 1, "setting the interrupt mask\n" );
113 cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04); 114 cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04);
114 cx_set(MO_TS_INTMSK, 0x1f0011); 115 cx_set(MO_TS_INTMSK, 0x1f0011);
115 116
@@ -122,7 +123,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
122static int cx8802_stop_dma(struct cx8802_dev *dev) 123static int cx8802_stop_dma(struct cx8802_dev *dev)
123{ 124{
124 struct cx88_core *core = dev->core; 125 struct cx88_core *core = dev->core;
125 dprintk( 0, "cx8802_stop_dma\n" ); 126 dprintk( 1, "cx8802_stop_dma\n" );
126 127
127 /* stop dma */ 128 /* stop dma */
128 cx_clear(MO_TS_DMACNTRL, 0x11); 129 cx_clear(MO_TS_DMACNTRL, 0x11);
@@ -142,10 +143,43 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
142 struct cx88_buffer *buf; 143 struct cx88_buffer *buf;
143 struct list_head *item; 144 struct list_head *item;
144 145
145 dprintk( 0, "cx8802_restart_queue\n" ); 146 dprintk( 1, "cx8802_restart_queue\n" );
146 if (list_empty(&q->active)) 147 if (list_empty(&q->active))
147 { 148 {
148 dprintk( 0, "cx8802_restart_queue: queue is empty\n" ); 149 struct cx88_buffer *prev;
150 prev = NULL;
151
152 dprintk(1, "cx8802_restart_queue: queue is empty\n" );
153
154 for (;;) {
155 if (list_empty(&q->queued))
156 return 0;
157 buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
158 if (NULL == prev) {
159 list_del(&buf->vb.queue);
160 list_add_tail(&buf->vb.queue,&q->active);
161 cx8802_start_dma(dev, q, buf);
162 buf->vb.state = STATE_ACTIVE;
163 buf->count = q->count++;
164 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
165 dprintk(1,"[%p/%d] restart_queue - first active\n",
166 buf,buf->vb.i);
167
168 } else if (prev->vb.width == buf->vb.width &&
169 prev->vb.height == buf->vb.height &&
170 prev->fmt == buf->fmt) {
171 list_del(&buf->vb.queue);
172 list_add_tail(&buf->vb.queue,&q->active);
173 buf->vb.state = STATE_ACTIVE;
174 buf->count = q->count++;
175 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
176 dprintk(1,"[%p/%d] restart_queue - move to active\n",
177 buf,buf->vb.i);
178 } else {
179 return 0;
180 }
181 prev = buf;
182 }
149 return 0; 183 return 0;
150 } 184 }
151 185
@@ -204,13 +238,13 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
204 buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma); 238 buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma);
205 239
206 if (list_empty(&cx88q->active)) { 240 if (list_empty(&cx88q->active)) {
207 dprintk( 0, "queue is empty - first active\n" ); 241 dprintk( 1, "queue is empty - first active\n" );
208 list_add_tail(&buf->vb.queue,&cx88q->active); 242 list_add_tail(&buf->vb.queue,&cx88q->active);
209 cx8802_start_dma(dev, cx88q, buf); 243 cx8802_start_dma(dev, cx88q, buf);
210 buf->vb.state = STATE_ACTIVE; 244 buf->vb.state = STATE_ACTIVE;
211 buf->count = cx88q->count++; 245 buf->count = cx88q->count++;
212 mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT); 246 mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT);
213 dprintk(0,"[%p/%d] %s - first active\n", 247 dprintk(1,"[%p/%d] %s - first active\n",
214 buf, buf->vb.i, __FUNCTION__); 248 buf, buf->vb.i, __FUNCTION__);
215 249
216 } else { 250 } else {
@@ -244,7 +278,7 @@ static void do_cancel_buffers(struct cx8802_dev *dev, char *reason, int restart)
244 } 278 }
245 if (restart) 279 if (restart)
246 { 280 {
247 dprintk(0, "restarting queue\n" ); 281 dprintk(1, "restarting queue\n" );
248 cx8802_restart_queue(dev,q); 282 cx8802_restart_queue(dev,q);
249 } 283 }
250 spin_unlock_irqrestore(&dev->slock,flags); 284 spin_unlock_irqrestore(&dev->slock,flags);
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 641a0c5a6490..1e4278b588d8 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -52,6 +52,7 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/smp_lock.h> 53#include <linux/smp_lock.h>
54#include <linux/delay.h> 54#include <linux/delay.h>
55#include <linux/config.h>
55#include <linux/kthread.h> 56#include <linux/kthread.h>
56 57
57#include "cx88.h" 58#include "cx88.h"
@@ -137,21 +138,28 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
137{ 138{
138 u32 volume; 139 u32 volume;
139 140
140#ifndef USING_CX88_ALSA 141#ifndef CONFIG_VIDEO_CX88_ALSA
141 /* restart dma; This avoids buzz in NICAM and is good in others */ 142 /* restart dma; This avoids buzz in NICAM and is good in others */
142 cx88_stop_audio_dma(core); 143 cx88_stop_audio_dma(core);
143#endif 144#endif
144 cx_write(AUD_RATE_THRES_DMD, 0x000000C0); 145 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
145#ifndef USING_CX88_ALSA 146#ifndef CONFIG_VIDEO_CX88_ALSA
146 cx88_start_audio_dma(core); 147 cx88_start_audio_dma(core);
147#endif 148#endif
148 149
149 if (cx88_boards[core->board].blackbird) { 150 if (cx88_boards[core->board].blackbird) {
150 /* sets sound input from external adc */ 151 /* sets sound input from external adc */
151 if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN) 152 switch (core->board) {
153 case CX88_BOARD_HAUPPAUGE_ROSLYN:
154 case CX88_BOARD_KWORLD_MCE200_DELUXE:
155 case CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT:
156 case CX88_BOARD_PIXELVIEW_PLAYTV_P7000:
157 case CX88_BOARD_ASUS_PVR_416:
152 cx_clear(AUD_CTL, EN_I2SIN_ENABLE); 158 cx_clear(AUD_CTL, EN_I2SIN_ENABLE);
153 else 159 break;
160 default:
154 cx_set(AUD_CTL, EN_I2SIN_ENABLE); 161 cx_set(AUD_CTL, EN_I2SIN_ENABLE);
162 }
155 163
156 cx_write(AUD_I2SINPUTCNTL, 4); 164 cx_write(AUD_I2SINPUTCNTL, 4);
157 cx_write(AUD_BAUDRATE, 1); 165 cx_write(AUD_BAUDRATE, 1);
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 846faadc9f1c..aa2a69770098 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -34,8 +34,8 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f)
34 if (dev->core->tvnorm->id & V4L2_STD_525_60) { 34 if (dev->core->tvnorm->id & V4L2_STD_525_60) {
35 /* ntsc */ 35 /* ntsc */
36 f->fmt.vbi.sampling_rate = 28636363; 36 f->fmt.vbi.sampling_rate = 28636363;
37 f->fmt.vbi.start[0] = 10 -1; 37 f->fmt.vbi.start[0] = 10;
38 f->fmt.vbi.start[1] = 273 -1; 38 f->fmt.vbi.start[1] = 273;
39 39
40 } else if (dev->core->tvnorm->id & V4L2_STD_625_50) { 40 } else if (dev->core->tvnorm->id & V4L2_STD_625_50) {
41 /* pal */ 41 /* pal */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 326a25f147f6..dc7bc35f18f4 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -25,9 +25,11 @@
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26#include <linux/kdev_t.h> 26#include <linux/kdev_t.h>
27 27
28#include <media/v4l2-common.h>
28#include <media/tuner.h> 29#include <media/tuner.h>
29#include <media/tveeprom.h> 30#include <media/tveeprom.h>
30#include <media/video-buf.h> 31#include <media/video-buf.h>
32#include <media/cx2341x.h>
31#include <media/video-buf-dvb.h> 33#include <media/video-buf-dvb.h>
32 34
33#include "btcx-risc.h" 35#include "btcx-risc.h"
@@ -35,7 +37,7 @@
35 37
36#include <linux/version.h> 38#include <linux/version.h>
37#include <linux/mutex.h> 39#include <linux/mutex.h>
38#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) 40#define CX88_VERSION_CODE KERNEL_VERSION(0,0,6)
39 41
40#ifndef TRUE 42#ifndef TRUE
41# define TRUE (1==1) 43# define TRUE (1==1)
@@ -189,6 +191,11 @@ extern struct sram_channel cx88_sram_channels[];
189#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44 191#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44
190#define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45 192#define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45
191#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46 193#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46
194#define CX88_BOARD_PCHDTV_HD5500 47
195#define CX88_BOARD_KWORLD_MCE200_DELUXE 48
196#define CX88_BOARD_PIXELVIEW_PLAYTV_P7000 49
197#define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50
198#define CX88_BOARD_WINFAST_DTV2000H 51
192 199
193enum cx88_itype { 200enum cx88_itype {
194 CX88_VMUX_COMPOSITE1 = 1, 201 CX88_VMUX_COMPOSITE1 = 1,
@@ -296,6 +303,7 @@ struct cx88_core {
296 /* config info -- dvb */ 303 /* config info -- dvb */
297 struct dvb_pll_desc *pll_desc; 304 struct dvb_pll_desc *pll_desc;
298 unsigned int pll_addr; 305 unsigned int pll_addr;
306 int (*prev_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
299 307
300 /* state info */ 308 /* state info */
301 struct task_struct *kthread; 309 struct task_struct *kthread;
@@ -391,14 +399,6 @@ struct cx8802_suspend_state {
391 int disabled; 399 int disabled;
392}; 400};
393 401
394/* TODO: move this to struct v4l2_mpeg_compression ? */
395struct blackbird_dnr {
396 u32 mode;
397 u32 type;
398 u32 spatial;
399 u32 temporal;
400};
401
402struct cx8802_dev { 402struct cx8802_dev {
403 struct cx88_core *core; 403 struct cx88_core *core;
404 spinlock_t slock; 404 spinlock_t slock;
@@ -432,8 +432,7 @@ struct cx8802_dev {
432 unsigned char ts_gen_cntrl; 432 unsigned char ts_gen_cntrl;
433 433
434 /* mpeg params */ 434 /* mpeg params */
435 struct v4l2_mpeg_compression params; 435 struct cx2341x_mpeg_params params;
436 struct blackbird_dnr dnr_params;
437}; 436};
438 437
439/* ----------------------------------------------------------- */ 438/* ----------------------------------------------------------- */
@@ -598,10 +597,6 @@ extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
598extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, 597extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file,
599 unsigned int cmd, void *arg); 598 unsigned int cmd, void *arg);
600extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd); 599extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd);
601void blackbird_set_params(struct cx8802_dev *dev,
602 struct v4l2_mpeg_compression *params);
603void blackbird_set_dnr_params(struct cx8802_dev *dev,
604 struct blackbird_dnr* dnr_params);
605 600
606/* 601/*
607 * Local variables: 602 * Local variables: