]>
Commit | Line | Data |
---|---|---|
a6c2ba28 | 1 | /* |
0e7072ef | 2 | em28xx.h - driver for Empia EM2800/EM2820/2840 USB video capture devices |
a6c2ba28 | 3 | |
4 | Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> | |
4ac97914 | 5 | Ludovico Cavedon <cavedon@sssup.it> |
2e7c6dc3 | 6 | Mauro Carvalho Chehab <mchehab@infradead.org> |
a6c2ba28 | 7 | |
8 | Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de> | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | */ | |
24 | ||
3acf2809 MCC |
25 | #ifndef _EM28XX_H |
26 | #define _EM28XX_H | |
a6c2ba28 | 27 | |
cb77d010 | 28 | #include <linux/videodev2.h> |
ad0ebb96 MCC |
29 | #include <media/videobuf-vmalloc.h> |
30 | ||
a6c2ba28 | 31 | #include <linux/i2c.h> |
3593cab5 | 32 | #include <linux/mutex.h> |
d5e52653 | 33 | #include <media/ir-kbd-i2c.h> |
3aefb79a MCC |
34 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) |
35 | #include <media/videobuf-dvb.h> | |
36 | #endif | |
3ca9c093 | 37 | #include "tuner-xc2028.h" |
2ba890ec | 38 | #include "em28xx-reg.h" |
3aefb79a MCC |
39 | |
40 | /* Boards supported by driver */ | |
41 | #define EM2800_BOARD_UNKNOWN 0 | |
42 | #define EM2820_BOARD_UNKNOWN 1 | |
43 | #define EM2820_BOARD_TERRATEC_CINERGY_250 2 | |
44 | #define EM2820_BOARD_PINNACLE_USB_2 3 | |
45 | #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 | |
46 | #define EM2820_BOARD_MSI_VOX_USB_2 5 | |
47 | #define EM2800_BOARD_TERRATEC_CINERGY_200 6 | |
48 | #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 | |
49 | #define EM2800_BOARD_KWORLD_USB2800 8 | |
50 | #define EM2820_BOARD_PINNACLE_DVC_90 9 | |
51 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 | |
52 | #define EM2880_BOARD_TERRATEC_HYBRID_XS 11 | |
53 | #define EM2820_BOARD_KWORLD_PVRTV2800RF 12 | |
54 | #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 | |
55 | #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 | |
56 | #define EM2800_BOARD_VGEAR_POCKETTV 15 | |
57 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 | |
58 | ||
59 | /* Limits minimum and default number of buffers */ | |
60 | #define EM28XX_MIN_BUF 4 | |
61 | #define EM28XX_DEF_BUF 8 | |
a6c2ba28 | 62 | |
596d92d5 | 63 | /* maximum number of em28xx boards */ |
3687e1e6 | 64 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ |
596d92d5 | 65 | |
a6c2ba28 | 66 | /* maximum number of frames that can be queued */ |
3acf2809 | 67 | #define EM28XX_NUM_FRAMES 5 |
a6c2ba28 | 68 | /* number of frames that get used for v4l2_read() */ |
3acf2809 | 69 | #define EM28XX_NUM_READ_FRAMES 2 |
a6c2ba28 | 70 | |
71 | /* number of buffers for isoc transfers */ | |
3acf2809 | 72 | #define EM28XX_NUM_BUFS 5 |
a6c2ba28 | 73 | |
d5e52653 MCC |
74 | /* number of packets for each buffer |
75 | windows requests only 40 packets .. so we better do the same | |
76 | this is what I found out for all alternate numbers there! | |
77 | */ | |
3acf2809 | 78 | #define EM28XX_NUM_PACKETS 40 |
a6c2ba28 | 79 | |
a6c2ba28 | 80 | /* default alternate; 0 means choose the best */ |
3acf2809 | 81 | #define EM28XX_PINOUT 0 |
a6c2ba28 | 82 | |
3acf2809 | 83 | #define EM28XX_INTERLACED_DEFAULT 1 |
a6c2ba28 | 84 | |
85 | /* | |
86 | #define (use usbview if you want to get the other alternate number infos) | |
87 | #define | |
88 | #define alternate number 2 | |
89 | #define Endpoint Address: 82 | |
90 | Direction: in | |
91 | Attribute: 1 | |
92 | Type: Isoc | |
93 | Max Packet Size: 1448 | |
94 | Interval: 125us | |
95 | ||
96 | alternate number 7 | |
97 | ||
98 | Endpoint Address: 82 | |
99 | Direction: in | |
100 | Attribute: 1 | |
101 | Type: Isoc | |
102 | Max Packet Size: 3072 | |
103 | Interval: 125us | |
104 | */ | |
105 | ||
106 | /* time to wait when stopping the isoc transfer */ | |
3acf2809 | 107 | #define EM28XX_URB_TIMEOUT msecs_to_jiffies(EM28XX_NUM_BUFS * EM28XX_NUM_PACKETS) |
a6c2ba28 | 108 | |
596d92d5 MCC |
109 | /* time in msecs to wait for i2c writes to finish */ |
110 | #define EM2800_I2C_WRITE_TIMEOUT 20 | |
111 | ||
3aefb79a MCC |
112 | enum em28xx_mode { |
113 | EM28XX_ANALOG_MODE, | |
114 | EM28XX_DIGITAL_MODE, | |
115 | }; | |
116 | ||
3acf2809 | 117 | enum em28xx_stream_state { |
a6c2ba28 | 118 | STREAM_OFF, |
119 | STREAM_INTERRUPT, | |
120 | STREAM_ON, | |
121 | }; | |
122 | ||
579f72e4 AT |
123 | struct em28xx; |
124 | ||
ad0ebb96 MCC |
125 | struct em28xx_usb_isoc_ctl { |
126 | /* max packet size of isoc transaction */ | |
127 | int max_pkt_size; | |
128 | ||
129 | /* number of allocated urbs */ | |
130 | int num_bufs; | |
131 | ||
132 | /* urb for isoc transfers */ | |
133 | struct urb **urb; | |
134 | ||
135 | /* transfer buffers for isoc transfer */ | |
136 | char **transfer_buffer; | |
137 | ||
138 | /* Last buffer command and region */ | |
139 | u8 cmd; | |
140 | int pos, size, pktsize; | |
141 | ||
142 | /* Last field: ODD or EVEN? */ | |
143 | int field; | |
144 | ||
145 | /* Stores incomplete commands */ | |
146 | u32 tmp_buf; | |
147 | int tmp_buf_len; | |
148 | ||
149 | /* Stores already requested buffers */ | |
150 | struct em28xx_buffer *buf; | |
151 | ||
152 | /* Stores the number of received fields */ | |
153 | int nfields; | |
579f72e4 AT |
154 | |
155 | /* isoc urb callback */ | |
156 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb); | |
157 | ||
ad0ebb96 MCC |
158 | }; |
159 | ||
160 | struct em28xx_fmt { | |
161 | char *name; | |
162 | u32 fourcc; /* v4l2 format id */ | |
163 | }; | |
164 | ||
165 | /* buffer for one video frame */ | |
166 | struct em28xx_buffer { | |
167 | /* common v4l buffer stuff -- must be first */ | |
168 | struct videobuf_buffer vb; | |
169 | ||
a6c2ba28 | 170 | struct list_head frame; |
a6c2ba28 | 171 | int top_field; |
ad0ebb96 MCC |
172 | int receiving; |
173 | }; | |
174 | ||
175 | struct em28xx_dmaqueue { | |
176 | struct list_head active; | |
177 | struct list_head queued; | |
ad0ebb96 MCC |
178 | |
179 | wait_queue_head_t wq; | |
180 | ||
181 | /* Counters to control buffer fill */ | |
182 | int pos; | |
a6c2ba28 | 183 | }; |
184 | ||
185 | /* io methods */ | |
3acf2809 | 186 | enum em28xx_io_method { |
a6c2ba28 | 187 | IO_NONE, |
188 | IO_READ, | |
189 | IO_MMAP, | |
190 | }; | |
191 | ||
192 | /* inputs */ | |
193 | ||
3acf2809 MCC |
194 | #define MAX_EM28XX_INPUT 4 |
195 | enum enum28xx_itype { | |
196 | EM28XX_VMUX_COMPOSITE1 = 1, | |
197 | EM28XX_VMUX_COMPOSITE2, | |
198 | EM28XX_VMUX_COMPOSITE3, | |
199 | EM28XX_VMUX_COMPOSITE4, | |
200 | EM28XX_VMUX_SVIDEO, | |
201 | EM28XX_VMUX_TELEVISION, | |
202 | EM28XX_VMUX_CABLE, | |
203 | EM28XX_VMUX_DVB, | |
204 | EM28XX_VMUX_DEBUG, | |
205 | EM28XX_RADIO, | |
a6c2ba28 | 206 | }; |
207 | ||
539c96d0 MCC |
208 | enum em28xx_amux { |
209 | EM28XX_AMUX_VIDEO, | |
210 | EM28XX_AMUX_LINE_IN, | |
211 | EM28XX_AMUX_AC97_VIDEO, | |
212 | EM28XX_AMUX_AC97_LINE_IN, | |
213 | }; | |
214 | ||
3acf2809 MCC |
215 | struct em28xx_input { |
216 | enum enum28xx_itype type; | |
a6c2ba28 | 217 | unsigned int vmux; |
539c96d0 | 218 | enum em28xx_amux amux; |
a6c2ba28 | 219 | }; |
220 | ||
3acf2809 | 221 | #define INPUT(nr) (&em28xx_boards[dev->model].input[nr]) |
a6c2ba28 | 222 | |
3acf2809 MCC |
223 | enum em28xx_decoder { |
224 | EM28XX_TVP5150, | |
225 | EM28XX_SAA7113, | |
226 | EM28XX_SAA7114 | |
a6c2ba28 | 227 | }; |
228 | ||
102a0b08 MCC |
229 | struct em28xx_reg_seq { |
230 | int reg; | |
ee6e3a86 | 231 | unsigned char val; |
102a0b08 | 232 | int sleep; |
ee6e3a86 MCC |
233 | }; |
234 | ||
3acf2809 | 235 | struct em28xx_board { |
a6c2ba28 | 236 | char *name; |
a6c2ba28 | 237 | int vchannels; |
a6c2ba28 | 238 | int tuner_type; |
239 | ||
240 | /* i2c flags */ | |
241 | unsigned int tda9887_conf; | |
242 | ||
74f38a82 | 243 | unsigned int is_em2800:1; |
a6c2ba28 | 244 | unsigned int has_msp34xx:1; |
5add9a6f | 245 | unsigned int mts_firmware:1; |
3abee53e | 246 | unsigned int has_12mhz_i2s:1; |
c8793b03 | 247 | unsigned int max_range_640_480:1; |
3aefb79a | 248 | unsigned int has_dvb:1; |
3abee53e | 249 | |
3acf2809 | 250 | enum em28xx_decoder decoder; |
a6c2ba28 | 251 | |
3acf2809 | 252 | struct em28xx_input input[MAX_EM28XX_INPUT]; |
0be43754 | 253 | struct em28xx_input radio; |
a6c2ba28 | 254 | }; |
255 | ||
3acf2809 | 256 | struct em28xx_eeprom { |
a6c2ba28 | 257 | u32 id; /* 0x9567eb1a */ |
258 | u16 vendor_ID; | |
259 | u16 product_ID; | |
260 | ||
261 | u16 chip_conf; | |
262 | ||
263 | u16 board_conf; | |
264 | ||
265 | u16 string1, string2, string3; | |
266 | ||
267 | u8 string_idx_table; | |
268 | }; | |
269 | ||
270 | /* device states */ | |
3acf2809 | 271 | enum em28xx_dev_state { |
a6c2ba28 | 272 | DEV_INITIALIZED = 0x01, |
273 | DEV_DISCONNECTED = 0x02, | |
274 | DEV_MISCONFIGURED = 0x04, | |
275 | }; | |
276 | ||
579f72e4 AT |
277 | enum em28xx_capture_mode { |
278 | EM28XX_CAPTURE_OFF = 0, | |
279 | EM28XX_ANALOG_CAPTURE, | |
280 | EM28XX_DIGITAL_CAPTURE, | |
281 | }; | |
282 | ||
6d79468d MCC |
283 | #define EM28XX_AUDIO_BUFS 5 |
284 | #define EM28XX_NUM_AUDIO_PACKETS 64 | |
285 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | |
286 | #define EM28XX_CAPTURE_STREAM_EN 1 | |
3aefb79a MCC |
287 | |
288 | /* em28xx extensions */ | |
6d79468d | 289 | #define EM28XX_AUDIO 0x10 |
3aefb79a | 290 | #define EM28XX_DVB 0x20 |
6d79468d MCC |
291 | |
292 | struct em28xx_audio { | |
293 | char name[50]; | |
294 | char *transfer_buffer[EM28XX_AUDIO_BUFS]; | |
295 | struct urb *urb[EM28XX_AUDIO_BUFS]; | |
296 | struct usb_device *udev; | |
297 | unsigned int capture_transfer_done; | |
298 | struct snd_pcm_substream *capture_pcm_substream; | |
299 | ||
300 | unsigned int hwptr_done_capture; | |
301 | struct snd_card *sndcard; | |
302 | ||
303 | int users, shutdown; | |
304 | enum em28xx_stream_state capture_stream; | |
305 | spinlock_t slock; | |
306 | }; | |
307 | ||
52284c3e MCC |
308 | struct em28xx; |
309 | ||
310 | struct em28xx_fh { | |
311 | struct em28xx *dev; | |
312 | unsigned int stream_on:1; /* Locks streams */ | |
313 | int radio; | |
314 | ||
315 | struct videobuf_queue vb_vidq; | |
316 | ||
317 | enum v4l2_buf_type type; | |
318 | }; | |
319 | ||
a6c2ba28 | 320 | /* main device struct */ |
3acf2809 | 321 | struct em28xx { |
a6c2ba28 | 322 | /* generic device properties */ |
323 | char name[30]; /* name (including minor) of the device */ | |
324 | int model; /* index in the device_data struct */ | |
e5589bef | 325 | int devno; /* marks the number of this device */ |
74f38a82 | 326 | unsigned int is_em2800:1; |
a6c2ba28 | 327 | unsigned int has_msp34xx:1; |
328 | unsigned int has_tda9887:1; | |
a225452e | 329 | unsigned int stream_on:1; /* Locks streams */ |
d7448a8d | 330 | unsigned int has_audio_class:1; |
3abee53e | 331 | unsigned int has_12mhz_i2s:1; |
c8793b03 | 332 | unsigned int max_range_640_480:1; |
3aefb79a | 333 | unsigned int has_dvb:1; |
a225452e | 334 | |
89b329ef MCC |
335 | /* Some older em28xx chips needs a waiting time after writing */ |
336 | unsigned int wait_after_write; | |
337 | ||
102a0b08 MCC |
338 | /* GPIO sequences for tuner callback */ |
339 | struct em28xx_reg_seq *analog_gpio, *digital_gpio; | |
ee6e3a86 | 340 | |
74f38a82 MCC |
341 | int video_inputs; /* number of video inputs */ |
342 | struct list_head devlist; | |
343 | ||
9bb13a6d MCC |
344 | u32 i2s_speed; /* I2S speed for audio digital stream */ |
345 | ||
3acf2809 | 346 | enum em28xx_decoder decoder; |
a6c2ba28 | 347 | |
348 | int tuner_type; /* type of the tuner */ | |
349 | int tuner_addr; /* tuner address */ | |
350 | int tda9887_conf; | |
351 | /* i2c i/o */ | |
352 | struct i2c_adapter i2c_adap; | |
353 | struct i2c_client i2c_client; | |
354 | /* video for linux */ | |
355 | int users; /* user count for exclusive use */ | |
356 | struct video_device *vdev; /* video for linux device struct */ | |
7d497f8a | 357 | v4l2_std_id norm; /* selected tv norm */ |
a6c2ba28 | 358 | int ctl_freq; /* selected frequency */ |
359 | unsigned int ctl_input; /* selected input */ | |
360 | unsigned int ctl_ainput; /* slected audio input */ | |
361 | int mute; | |
362 | int volume; | |
363 | /* frame properties */ | |
a6c2ba28 | 364 | int width; /* current frame width */ |
365 | int height; /* current frame height */ | |
a6c2ba28 | 366 | int hscale; /* horizontal scale factor (see datasheet) */ |
367 | int vscale; /* vertical scale factor (see datasheet) */ | |
368 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ | |
9e31ced8 | 369 | unsigned int video_bytesread; /* Number of bytes read */ |
a6c2ba28 | 370 | |
03910cc3 | 371 | unsigned long hash; /* eeprom hash - for boards with generic ID */ |
6ea54d93 DSL |
372 | unsigned long i2c_hash; /* i2c devicelist hash - |
373 | for boards with generic ID */ | |
03910cc3 | 374 | |
6d79468d MCC |
375 | struct em28xx_audio *adev; |
376 | ||
a6c2ba28 | 377 | /* states */ |
3acf2809 | 378 | enum em28xx_dev_state state; |
3acf2809 | 379 | enum em28xx_io_method io; |
9e31ced8 | 380 | |
d7448a8d MCC |
381 | struct work_struct request_module_wk; |
382 | ||
a6c2ba28 | 383 | /* locks */ |
5a80415b | 384 | struct mutex lock; |
d7aa8020 | 385 | /* spinlock_t queue_lock; */ |
a6c2ba28 | 386 | struct list_head inqueue, outqueue; |
387 | wait_queue_head_t open, wait_frame, wait_stream; | |
388 | struct video_device *vbi_dev; | |
0be43754 | 389 | struct video_device *radio_dev; |
a6c2ba28 | 390 | |
391 | unsigned char eedata[256]; | |
392 | ||
ad0ebb96 MCC |
393 | /* Isoc control struct */ |
394 | struct em28xx_dmaqueue vidq; | |
395 | struct em28xx_usb_isoc_ctl isoc_ctl; | |
396 | spinlock_t slock; | |
397 | ||
a6c2ba28 | 398 | /* usb transfer */ |
399 | struct usb_device *udev; /* the usb device */ | |
400 | int alt; /* alternate */ | |
401 | int max_pkt_size; /* max packet size of isoc transaction */ | |
9d4d9c05 MCC |
402 | int num_alt; /* Number of alternative settings */ |
403 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | |
3acf2809 MCC |
404 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ |
405 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ | |
a6c2ba28 | 406 | /* helper funcs that call usb_control_msg */ |
6ea54d93 | 407 | int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, |
a6c2ba28 | 408 | char *buf, int len); |
6ea54d93 DSL |
409 | int (*em28xx_read_reg) (struct em28xx *dev, u16 reg); |
410 | int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg, | |
411 | char *buf, int len); | |
412 | int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg, | |
a6c2ba28 | 413 | char *buf, int len); |
6ea54d93 | 414 | int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg); |
3aefb79a MCC |
415 | |
416 | enum em28xx_mode mode; | |
417 | ||
3421b778 | 418 | struct em28xx_dvb *dvb; |
a6c2ba28 | 419 | }; |
420 | ||
6d79468d MCC |
421 | struct em28xx_ops { |
422 | struct list_head next; | |
423 | char *name; | |
424 | int id; | |
425 | int (*init)(struct em28xx *); | |
426 | int (*fini)(struct em28xx *); | |
a3a048ce MCC |
427 | }; |
428 | ||
3acf2809 | 429 | /* Provided by em28xx-i2c.c */ |
a6c2ba28 | 430 | |
3acf2809 | 431 | void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg); |
fad7b958 | 432 | void em28xx_do_i2c_scan(struct em28xx *dev); |
3acf2809 MCC |
433 | int em28xx_i2c_register(struct em28xx *dev); |
434 | int em28xx_i2c_unregister(struct em28xx *dev); | |
a6c2ba28 | 435 | |
3acf2809 | 436 | /* Provided by em28xx-core.c */ |
a6c2ba28 | 437 | |
3acf2809 MCC |
438 | u32 em28xx_request_buffers(struct em28xx *dev, u32 count); |
439 | void em28xx_queue_unusedframes(struct em28xx *dev); | |
440 | void em28xx_release_buffers(struct em28xx *dev); | |
a6c2ba28 | 441 | |
3acf2809 | 442 | int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, |
a6c2ba28 | 443 | char *buf, int len); |
3acf2809 MCC |
444 | int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg); |
445 | int em28xx_read_reg(struct em28xx *dev, u16 reg); | |
446 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |
a6c2ba28 | 447 | int len); |
3acf2809 | 448 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); |
3acf2809 | 449 | int em28xx_audio_analog_set(struct em28xx *dev); |
539c96d0 | 450 | |
3acf2809 MCC |
451 | int em28xx_colorlevels_set_default(struct em28xx *dev); |
452 | int em28xx_capture_start(struct em28xx *dev, int start); | |
453 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); | |
3acf2809 | 454 | int em28xx_resolution_set(struct em28xx *dev); |
3acf2809 | 455 | int em28xx_set_alternate(struct em28xx *dev); |
579f72e4 AT |
456 | int em28xx_init_isoc(struct em28xx *dev, int max_packets, |
457 | int num_bufs, int max_pkt_size, | |
458 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb), | |
459 | int cap_type); | |
460 | void em28xx_uninit_isoc(struct em28xx *dev); | |
3acf2809 | 461 | |
6d79468d MCC |
462 | /* Provided by em28xx-video.c */ |
463 | int em28xx_register_extension(struct em28xx_ops *dev); | |
464 | void em28xx_unregister_extension(struct em28xx_ops *dev); | |
465 | ||
3acf2809 | 466 | /* Provided by em28xx-cards.c */ |
6ea54d93 | 467 | extern int em2800_variant_detect(struct usb_device *udev, int model); |
a94e95b4 | 468 | extern void em28xx_pre_card_setup(struct em28xx *dev); |
3acf2809 MCC |
469 | extern void em28xx_card_setup(struct em28xx *dev); |
470 | extern struct em28xx_board em28xx_boards[]; | |
471 | extern struct usb_device_id em28xx_id_table[]; | |
472 | extern const unsigned int em28xx_bcount; | |
c8793b03 | 473 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); |
ee6e3a86 | 474 | int em28xx_tuner_callback(void *ptr, int command, int arg); |
3ca9c093 | 475 | void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl); |
c8793b03 MCC |
476 | |
477 | /* Provided by em28xx-input.c */ | |
478 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ | |
479 | int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); | |
480 | int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); | |
481 | int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | |
482 | u32 *ir_raw); | |
a6c2ba28 | 483 | |
a6c2ba28 | 484 | /* printk macros */ |
485 | ||
3acf2809 | 486 | #define em28xx_err(fmt, arg...) do {\ |
f85c657f | 487 | printk(KERN_ERR fmt , ##arg); } while (0) |
a6c2ba28 | 488 | |
3acf2809 | 489 | #define em28xx_errdev(fmt, arg...) do {\ |
4ac97914 | 490 | printk(KERN_ERR "%s: "fmt,\ |
f85c657f | 491 | dev->name , ##arg); } while (0) |
a6c2ba28 | 492 | |
3acf2809 | 493 | #define em28xx_info(fmt, arg...) do {\ |
4ac97914 | 494 | printk(KERN_INFO "%s: "fmt,\ |
f85c657f | 495 | dev->name , ##arg); } while (0) |
3acf2809 | 496 | #define em28xx_warn(fmt, arg...) do {\ |
4ac97914 | 497 | printk(KERN_WARNING "%s: "fmt,\ |
f85c657f | 498 | dev->name , ##arg); } while (0) |
a6c2ba28 | 499 | |
6ea54d93 | 500 | static inline int em28xx_compression_disable(struct em28xx *dev) |
a6c2ba28 | 501 | { |
502 | /* side effect of disabling scaler and mixer */ | |
41facaa4 | 503 | return em28xx_write_regs(dev, EM28XX_R26_COMPR, "\x00", 1); |
a6c2ba28 | 504 | } |
505 | ||
6ea54d93 | 506 | static inline int em28xx_contrast_get(struct em28xx *dev) |
a6c2ba28 | 507 | { |
41facaa4 | 508 | return em28xx_read_reg(dev, EM28XX_R20_YGAIN) & 0x1f; |
a6c2ba28 | 509 | } |
510 | ||
6ea54d93 | 511 | static inline int em28xx_brightness_get(struct em28xx *dev) |
a6c2ba28 | 512 | { |
41facaa4 | 513 | return em28xx_read_reg(dev, EM28XX_R21_YOFFSET); |
a6c2ba28 | 514 | } |
515 | ||
6ea54d93 | 516 | static inline int em28xx_saturation_get(struct em28xx *dev) |
a6c2ba28 | 517 | { |
41facaa4 | 518 | return em28xx_read_reg(dev, EM28XX_R22_UVGAIN) & 0x1f; |
a6c2ba28 | 519 | } |
520 | ||
6ea54d93 | 521 | static inline int em28xx_u_balance_get(struct em28xx *dev) |
a6c2ba28 | 522 | { |
41facaa4 | 523 | return em28xx_read_reg(dev, EM28XX_R23_UOFFSET); |
a6c2ba28 | 524 | } |
525 | ||
6ea54d93 | 526 | static inline int em28xx_v_balance_get(struct em28xx *dev) |
a6c2ba28 | 527 | { |
41facaa4 | 528 | return em28xx_read_reg(dev, EM28XX_R24_VOFFSET); |
a6c2ba28 | 529 | } |
530 | ||
6ea54d93 | 531 | static inline int em28xx_gamma_get(struct em28xx *dev) |
a6c2ba28 | 532 | { |
41facaa4 | 533 | return em28xx_read_reg(dev, EM28XX_R14_GAMMA) & 0x3f; |
a6c2ba28 | 534 | } |
535 | ||
6ea54d93 | 536 | static inline int em28xx_contrast_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 537 | { |
538 | u8 tmp = (u8) val; | |
41facaa4 | 539 | return em28xx_write_regs(dev, EM28XX_R20_YGAIN, &tmp, 1); |
a6c2ba28 | 540 | } |
541 | ||
6ea54d93 | 542 | static inline int em28xx_brightness_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 543 | { |
544 | u8 tmp = (u8) val; | |
41facaa4 | 545 | return em28xx_write_regs(dev, EM28XX_R21_YOFFSET, &tmp, 1); |
a6c2ba28 | 546 | } |
547 | ||
6ea54d93 | 548 | static inline int em28xx_saturation_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 549 | { |
550 | u8 tmp = (u8) val; | |
41facaa4 | 551 | return em28xx_write_regs(dev, EM28XX_R22_UVGAIN, &tmp, 1); |
a6c2ba28 | 552 | } |
553 | ||
6ea54d93 | 554 | static inline int em28xx_u_balance_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 555 | { |
556 | u8 tmp = (u8) val; | |
41facaa4 | 557 | return em28xx_write_regs(dev, EM28XX_R23_UOFFSET, &tmp, 1); |
a6c2ba28 | 558 | } |
559 | ||
6ea54d93 | 560 | static inline int em28xx_v_balance_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 561 | { |
562 | u8 tmp = (u8) val; | |
41facaa4 | 563 | return em28xx_write_regs(dev, EM28XX_R24_VOFFSET, &tmp, 1); |
a6c2ba28 | 564 | } |
565 | ||
6ea54d93 | 566 | static inline int em28xx_gamma_set(struct em28xx *dev, s32 val) |
a6c2ba28 | 567 | { |
568 | u8 tmp = (u8) val; | |
41facaa4 | 569 | return em28xx_write_regs(dev, EM28XX_R14_GAMMA, &tmp, 1); |
a6c2ba28 | 570 | } |
571 | ||
572 | /*FIXME: maxw should be dependent of alt mode */ | |
6ea54d93 | 573 | static inline unsigned int norm_maxw(struct em28xx *dev) |
30556b23 | 574 | { |
c8793b03 | 575 | if (dev->max_range_640_480) |
7d497f8a | 576 | return 640; |
c8793b03 | 577 | else |
7d497f8a | 578 | return 720; |
30556b23 MR |
579 | } |
580 | ||
6ea54d93 | 581 | static inline unsigned int norm_maxh(struct em28xx *dev) |
a6c2ba28 | 582 | { |
c8793b03 | 583 | if (dev->max_range_640_480) |
7d497f8a | 584 | return 480; |
c8793b03 | 585 | else |
7d497f8a | 586 | return (dev->norm & V4L2_STD_625_50) ? 576 : 480; |
a6c2ba28 | 587 | } |
a6c2ba28 | 588 | #endif |