Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 1 | /* |
Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 2 | */ |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #ifndef MSP3400_H |
| 5 | #define MSP3400_H |
| 6 | |
| 7 | /* ---------------------------------------------------------------------- */ |
| 8 | |
Hans Verkuil | 53b0a1c | 2006-01-09 15:32:39 -0200 | [diff] [blame^] | 9 | #define msp_err(fmt, arg...) \ |
| 10 | printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ |
| 11 | i2c_adapter_id(client->adapter), client->addr , ## arg) |
| 12 | #define msp_warn(fmt, arg...) \ |
| 13 | printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \ |
| 14 | i2c_adapter_id(client->adapter), client->addr , ## arg) |
| 15 | #define msp_info(fmt, arg...) \ |
| 16 | printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ |
| 17 | i2c_adapter_id(client->adapter), client->addr , ## arg) |
| 18 | |
| 19 | /* level 1 debug. */ |
| 20 | #define msp_dbg1(fmt, arg...) \ |
| 21 | do { \ |
| 22 | if (debug) \ |
| 23 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->driver.name, \ |
| 24 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ |
| 25 | } while (0) |
| 26 | |
| 27 | /* level 2 debug. */ |
| 28 | #define msp_dbg2(fmt, arg...) \ |
| 29 | do { \ |
| 30 | if (debug >= 2) \ |
| 31 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ |
| 32 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ |
| 33 | } while (0) |
| 34 | |
| 35 | /* level 3 debug. Use with care. */ |
| 36 | #define msp_dbg3(fmt, arg...) \ |
| 37 | do { \ |
| 38 | if (debug >= 16) \ |
| 39 | printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ |
| 40 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ |
| 41 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | struct msp_matrix { |
| 44 | int input; |
| 45 | int output; |
| 46 | }; |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | /* ioctl for MSP_SET_MATRIX will have to be registered */ |
| 49 | #define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) |
| 50 | |
Hans Verkuil | 53b0a1c | 2006-01-09 15:32:39 -0200 | [diff] [blame^] | 51 | /* This macro is allowed for *constants* only, gcc must calculate it |
| 52 | at compile time. Remember -- no floats in kernel mode */ |
| 53 | #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24))) |
| 54 | |
| 55 | #define MSP_MODE_AM_DETECT 0 |
| 56 | #define MSP_MODE_FM_RADIO 2 |
| 57 | #define MSP_MODE_FM_TERRA 3 |
| 58 | #define MSP_MODE_FM_SAT 4 |
| 59 | #define MSP_MODE_FM_NICAM1 5 |
| 60 | #define MSP_MODE_FM_NICAM2 6 |
| 61 | #define MSP_MODE_AM_NICAM 7 |
| 62 | #define MSP_MODE_BTSC 8 |
| 63 | #define MSP_MODE_EXTERN 9 |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define SCART_MASK 0 |
| 66 | #define SCART_IN1 1 |
| 67 | #define SCART_IN2 2 |
| 68 | #define SCART_IN1_DA 3 |
| 69 | #define SCART_IN2_DA 4 |
| 70 | #define SCART_IN3 5 |
| 71 | #define SCART_IN4 6 |
| 72 | #define SCART_MONO 7 |
| 73 | #define SCART_MUTE 8 |
| 74 | |
| 75 | #define SCART_DSP_IN 0 |
| 76 | #define SCART1_OUT 1 |
| 77 | #define SCART2_OUT 2 |
| 78 | |
Hans Verkuil | 53b0a1c | 2006-01-09 15:32:39 -0200 | [diff] [blame^] | 79 | #define OPMODE_AUTO -1 |
| 80 | #define OPMODE_MANUAL 0 |
| 81 | #define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */ |
| 82 | #define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */ |
| 83 | |
| 84 | /* module parameters */ |
| 85 | extern int debug; |
| 86 | extern int once; |
| 87 | extern int amsound; |
| 88 | extern int standard; |
| 89 | extern int dolby; |
| 90 | extern int stereo_threshold; |
| 91 | |
| 92 | struct msp_state { |
| 93 | int rev1, rev2; |
| 94 | |
| 95 | int opmode; |
| 96 | int mode; |
| 97 | int norm; |
| 98 | int stereo; |
| 99 | int nicam_on; |
| 100 | int acb; |
| 101 | int in_scart; |
| 102 | int i2s_mode; |
| 103 | int main, second; /* sound carrier */ |
| 104 | int input; |
| 105 | int source; /* see msp34xxg_set_source */ |
| 106 | |
| 107 | /* v4l2 */ |
| 108 | int audmode; |
| 109 | int rxsubchans; |
| 110 | |
| 111 | int muted; |
| 112 | int volume, balance; |
| 113 | int bass, treble; |
| 114 | |
| 115 | /* thread */ |
| 116 | struct task_struct *kthread; |
| 117 | wait_queue_head_t wq; |
| 118 | int restart:1; |
| 119 | int watch_stereo:1; |
| 120 | }; |
| 121 | |
| 122 | #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ |
| 123 | |
| 124 | #define HAVE_NICAM(state) (((state->rev2 >> 8) & 0xff) != 0) |
| 125 | #define HAVE_RADIO(state) ((state->rev1 & 0x0f) >= 'G'-'@') |
| 126 | |
| 127 | /* msp3400-driver.c */ |
| 128 | int msp_write_dem(struct i2c_client *client, int addr, int val); |
| 129 | int msp_write_dsp(struct i2c_client *client, int addr, int val); |
| 130 | int msp_read_dem(struct i2c_client *client, int addr); |
| 131 | int msp_read_dsp(struct i2c_client *client, int addr); |
| 132 | int msp_reset(struct i2c_client *client); |
| 133 | void msp_set_scart(struct i2c_client *client, int in, int out); |
| 134 | void msp_set_mute(struct i2c_client *client); |
| 135 | void msp_set_audio(struct i2c_client *client); |
| 136 | int msp_modus(struct i2c_client *client, int norm); |
| 137 | int msp_standard(int norm); |
| 138 | int msp_sleep(struct msp_state *state, int timeout); |
| 139 | |
| 140 | /* msp3400-kthreads.c */ |
| 141 | const char *msp_standard_mode_name(int mode); |
| 142 | void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2); |
| 143 | void msp3400c_setmode(struct i2c_client *client, int type); |
| 144 | void msp3400c_setstereo(struct i2c_client *client, int mode); |
| 145 | int autodetect_stereo(struct i2c_client *client); |
| 146 | int msp3400c_thread(void *data); |
| 147 | int msp3410d_thread(void *data); |
| 148 | int msp34xxg_thread(void *data); |
| 149 | void msp34xxg_detect_stereo(struct i2c_client *client); |
| 150 | void msp34xxg_set_audmode(struct i2c_client *client, int audmode); |
| 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | #endif /* MSP3400_H */ |