diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-24 12:44:38 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-29 14:53:13 -0500 |
commit | c2e591fcb7aa5300cf6967edb29960628cf1831d (patch) | |
tree | fc334916c6b90395ad1583c2b8638116284a54f8 /drivers/media/dvb/frontends | |
parent | 67ea14f250c295486baa3440ca85be0b032fda95 (diff) |
V4L/DVB (9366): Move S921 driver to the proper place and allow it to compile
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/Kconfig | 11 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/Makefile | 3 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s921_core.c | 216 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s921_core.h | 114 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s921_module.c | 190 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/s921_module.h | 49 |
6 files changed, 583 insertions, 0 deletions
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 96b93e21a84b..8da1e81668e7 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -369,6 +369,17 @@ config DVB_S5H1411 | |||
369 | An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want | 369 | An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want |
370 | to support this frontend. | 370 | to support this frontend. |
371 | 371 | ||
372 | comment "ISDB-T (terrestrial) frontends" | ||
373 | depends on DVB_CORE | ||
374 | |||
375 | config DVB_S921 | ||
376 | tristate "Sharp S921 tuner" | ||
377 | depends on DVB_CORE && I2C | ||
378 | default m if DVB_FE_CUSTOMISE | ||
379 | help | ||
380 | AN ISDB-T DQPSK, QPSK, 16QAM and 64QAM 1seg tuner module. | ||
381 | Say Y when you want to support this frontend. | ||
382 | |||
372 | comment "Digital terrestrial only tuners/PLL" | 383 | comment "Digital terrestrial only tuners/PLL" |
373 | depends on DVB_CORE | 384 | depends on DVB_CORE |
374 | 385 | ||
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index aba79f4a63a7..11a5407ecdb7 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -5,6 +5,8 @@ | |||
5 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ | 5 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ |
6 | EXTRA_CFLAGS += -Idrivers/media/common/tuners/ | 6 | EXTRA_CFLAGS += -Idrivers/media/common/tuners/ |
7 | 7 | ||
8 | s921-objs := s921_module.o s921_core.o | ||
9 | |||
8 | obj-$(CONFIG_DVB_PLL) += dvb-pll.o | 10 | obj-$(CONFIG_DVB_PLL) += dvb-pll.o |
9 | obj-$(CONFIG_DVB_STV0299) += stv0299.o | 11 | obj-$(CONFIG_DVB_STV0299) += stv0299.o |
10 | obj-$(CONFIG_DVB_SP8870) += sp8870.o | 12 | obj-$(CONFIG_DVB_SP8870) += sp8870.o |
@@ -55,3 +57,4 @@ obj-$(CONFIG_DVB_CX24116) += cx24116.o | |||
55 | obj-$(CONFIG_DVB_SI21XX) += si21xx.o | 57 | obj-$(CONFIG_DVB_SI21XX) += si21xx.o |
56 | obj-$(CONFIG_DVB_STV0288) += stv0288.o | 58 | obj-$(CONFIG_DVB_STV0288) += stv0288.o |
57 | obj-$(CONFIG_DVB_STB6000) += stb6000.o | 59 | obj-$(CONFIG_DVB_STB6000) += stb6000.o |
60 | obj-$(CONFIG_DVB_S921) += s921.o | ||
diff --git a/drivers/media/dvb/frontends/s921_core.c b/drivers/media/dvb/frontends/s921_core.c new file mode 100644 index 000000000000..974b52be9aea --- /dev/null +++ b/drivers/media/dvb/frontends/s921_core.c | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | * Driver for Sharp s921 driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Markus Rechberger <mrechberger@sundtek.de> | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/delay.h> | ||
12 | #include "s921_core.h" | ||
13 | |||
14 | static int s921_isdb_init(struct s921_isdb_t *dev); | ||
15 | static int s921_isdb_set_parameters(struct s921_isdb_t *dev, struct s921_isdb_t_transmission_mode_params *params); | ||
16 | static int s921_isdb_tune(struct s921_isdb_t *dev, struct s921_isdb_t_tune_params *params); | ||
17 | static int s921_isdb_get_status(struct s921_isdb_t *dev, void *data); | ||
18 | |||
19 | static u8 init_table[]={ 0x01, 0x40, 0x02, 0x00, 0x03, 0x40, 0x04, 0x01, | ||
20 | 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, | ||
21 | 0x09, 0x00, 0x0a, 0x00, 0x0b, 0x5a, 0x0c, 0x00, | ||
22 | 0x0d, 0x00, 0x0f, 0x00, 0x13, 0x1b, 0x14, 0x80, | ||
23 | 0x15, 0x40, 0x17, 0x70, 0x18, 0x01, 0x19, 0x12, | ||
24 | 0x1a, 0x01, 0x1b, 0x12, 0x1c, 0xa0, 0x1d, 0x00, | ||
25 | 0x1e, 0x0a, 0x1f, 0x08, 0x20, 0x40, 0x21, 0xff, | ||
26 | 0x22, 0x4c, 0x23, 0x4e, 0x24, 0x4c, 0x25, 0x00, | ||
27 | 0x26, 0x00, 0x27, 0xf4, 0x28, 0x60, 0x29, 0x88, | ||
28 | 0x2a, 0x40, 0x2b, 0x40, 0x2c, 0xff, 0x2d, 0x00, | ||
29 | 0x2e, 0xff, 0x2f, 0x00, 0x30, 0x20, 0x31, 0x06, | ||
30 | 0x32, 0x0c, 0x34, 0x0f, 0x37, 0xfe, 0x38, 0x00, | ||
31 | 0x39, 0x63, 0x3a, 0x10, 0x3b, 0x10, 0x47, 0x00, | ||
32 | 0x49, 0xe5, 0x4b, 0x00, 0x50, 0xc0, 0x52, 0x20, | ||
33 | 0x54, 0x5a, 0x55, 0x5b, 0x56, 0x40, 0x57, 0x70, | ||
34 | 0x5c, 0x50, 0x5d, 0x00, 0x62, 0x17, 0x63, 0x2f, | ||
35 | 0x64, 0x6f, 0x68, 0x00, 0x69, 0x89, 0x6a, 0x00, | ||
36 | 0x6b, 0x00, 0x6c, 0x00, 0x6d, 0x00, 0x6e, 0x00, | ||
37 | 0x70, 0x00, 0x71, 0x00, 0x75, 0x00, 0x76, 0x30, | ||
38 | 0x77, 0x01, 0xaf, 0x00, 0xb0, 0xa0, 0xb2, 0x3d, | ||
39 | 0xb3, 0x25, 0xb4, 0x8b, 0xb5, 0x4b, 0xb6, 0x3f, | ||
40 | 0xb7, 0xff, 0xb8, 0xff, 0xb9, 0xfc, 0xba, 0x00, | ||
41 | 0xbb, 0x00, 0xbc, 0x00, 0xd0, 0x30, 0xe4, 0x84, | ||
42 | 0xf0, 0x48, 0xf1, 0x19, 0xf2, 0x5a, 0xf3, 0x8e, | ||
43 | 0xf4, 0x2d, 0xf5, 0x07, 0xf6, 0x5a, 0xf7, 0xba, | ||
44 | 0xf8, 0xd7 }; | ||
45 | |||
46 | static u8 c_table[]={ 0x58, 0x8a, 0x7b, 0x59, 0x8c, 0x7b, 0x5a, 0x8e, 0x5b, | ||
47 | 0x5b, 0x90, 0x5b, 0x5c, 0x92, 0x5b, 0x5d, 0x94, 0x5b, | ||
48 | 0x5e, 0x96, 0x5b, 0x5f, 0x98, 0x3b, 0x60, 0x9a, 0x3b, | ||
49 | 0x61, 0x9c, 0x3b, 0x62, 0x9e, 0x3b, 0x63, 0xa0, 0x3b, | ||
50 | 0x64, 0xa2, 0x1b, 0x65, 0xa4, 0x1b, 0x66, 0xa6, 0x1b, | ||
51 | 0x67, 0xa8, 0x1b, 0x68, 0xaa, 0x1b, 0x69, 0xac, 0x1b, | ||
52 | 0x6a, 0xae, 0x1b, 0x6b, 0xb0, 0x1b, 0x6c, 0xb2, 0x1b, | ||
53 | 0x6d, 0xb4, 0xfb, 0x6e, 0xb6, 0xfb, 0x6f, 0xb8, 0xfb, | ||
54 | 0x70, 0xba, 0xfb, 0x71, 0xbc, 0xdb, 0x72, 0xbe, 0xdb, | ||
55 | 0x73, 0xc0, 0xdb, 0x74, 0xc2, 0xdb, 0x75, 0xc4, 0xdb, | ||
56 | 0x76, 0xc6, 0xdb, 0x77, 0xc8, 0xbb, 0x78, 0xca, 0xbb, | ||
57 | 0x79, 0xcc, 0xbb, 0x7a, 0xce, 0xbb, 0x7b, 0xd0, 0xbb, | ||
58 | 0x7c, 0xd2, 0xbb, 0x7d, 0xd4, 0xbb, 0x7e, 0xd6, 0xbb, | ||
59 | 0x7f, 0xd8, 0xbb, 0x80, 0xda, 0x9b, 0x81, 0xdc, 0x9b, | ||
60 | 0x82, 0xde, 0x9b, 0x83, 0xe0, 0x9b, 0x84, 0xe2, 0x9b, | ||
61 | 0x85, 0xe4, 0x9b, 0x86, 0xe6, 0x9b, 0x87, 0xe8, 0x9b, | ||
62 | 0x88, 0xea, 0x9b, 0x89, 0xec, 0x9b }; | ||
63 | |||
64 | int s921_isdb_cmd(struct s921_isdb_t *dev, u32 cmd, void *data) { | ||
65 | switch(cmd) { | ||
66 | case ISDB_T_CMD_INIT: | ||
67 | s921_isdb_init(dev); | ||
68 | break; | ||
69 | case ISDB_T_CMD_SET_PARAM: | ||
70 | s921_isdb_set_parameters(dev, data); | ||
71 | break; | ||
72 | case ISDB_T_CMD_TUNE: | ||
73 | s921_isdb_tune(dev, data); | ||
74 | break; | ||
75 | case ISDB_T_CMD_GET_STATUS: | ||
76 | s921_isdb_get_status(dev, data); | ||
77 | break; | ||
78 | default: | ||
79 | printk("unhandled command\n"); | ||
80 | return -EINVAL; | ||
81 | } | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int s921_isdb_init(struct s921_isdb_t *dev) { | ||
86 | unsigned int i; | ||
87 | unsigned int ret; | ||
88 | printk("isdb_init\n"); | ||
89 | for (i = 0; i < sizeof(init_table); i+=2) { | ||
90 | ret = dev->i2c_write(dev->priv_dev, init_table[i], init_table[i+1]); | ||
91 | if (ret != 0) { | ||
92 | printk("i2c write failed\n"); | ||
93 | return ret; | ||
94 | } | ||
95 | } | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static int s921_isdb_set_parameters(struct s921_isdb_t *dev, struct s921_isdb_t_transmission_mode_params *params) { | ||
100 | |||
101 | int ret; | ||
102 | /* auto is sufficient for now, lateron this should be reflected in an extra interface */ | ||
103 | |||
104 | |||
105 | |||
106 | ret = dev->i2c_write(dev->priv_dev, 0xb0, 0xa0); //mod_b2); | ||
107 | ret = dev->i2c_write(dev->priv_dev, 0xb2, 0x3d); //mod_b2); | ||
108 | |||
109 | if (ret < 0) | ||
110 | return -EINVAL; | ||
111 | |||
112 | ret = dev->i2c_write(dev->priv_dev, 0xb3, 0x25); //mod_b3); | ||
113 | if (ret < 0) | ||
114 | return -EINVAL; | ||
115 | |||
116 | ret = dev->i2c_write(dev->priv_dev, 0xb4, 0x8b); //mod_b4); | ||
117 | if (ret < 0) | ||
118 | return -EINVAL; | ||
119 | |||
120 | ret = dev->i2c_write(dev->priv_dev, 0xb5, 0x4b); //mod_b5); | ||
121 | if (ret < 0) | ||
122 | return -EINVAL; | ||
123 | |||
124 | ret = dev->i2c_write(dev->priv_dev, 0xb6, 0x3f); //mod_b6); | ||
125 | if (ret < 0) | ||
126 | return -EINVAL; | ||
127 | |||
128 | ret = dev->i2c_write(dev->priv_dev, 0xb7, 0x3f); //mod_b7); | ||
129 | if (ret < 0) | ||
130 | return -EINVAL; | ||
131 | |||
132 | return E_OK; | ||
133 | } | ||
134 | |||
135 | static int s921_isdb_tune(struct s921_isdb_t *dev, struct s921_isdb_t_tune_params *params) { | ||
136 | |||
137 | int ret; | ||
138 | int index; | ||
139 | |||
140 | index = (params->frequency - 473143000)/6000000; | ||
141 | |||
142 | if (index > 48) { | ||
143 | return -EINVAL; | ||
144 | } | ||
145 | |||
146 | dev->i2c_write(dev->priv_dev, 0x47, 0x60); | ||
147 | |||
148 | ret = dev->i2c_write(dev->priv_dev, 0x68, 0x00); | ||
149 | if (ret < 0) | ||
150 | return -EINVAL; | ||
151 | |||
152 | ret = dev->i2c_write(dev->priv_dev, 0x69, 0x89); | ||
153 | if (ret < 0) | ||
154 | return -EINVAL; | ||
155 | |||
156 | ret = dev->i2c_write(dev->priv_dev, 0xf0, 0x48); | ||
157 | if (ret < 0) | ||
158 | return -EINVAL; | ||
159 | |||
160 | ret = dev->i2c_write(dev->priv_dev, 0xf1, 0x19); | ||
161 | if (ret < 0) | ||
162 | return -EINVAL; | ||
163 | |||
164 | ret = dev->i2c_write(dev->priv_dev, 0xf2, c_table[index*3]); | ||
165 | if (ret < 0) | ||
166 | return -EINVAL; | ||
167 | |||
168 | ret = dev->i2c_write(dev->priv_dev, 0xf3, c_table[index*3+1]); | ||
169 | if (ret < 0) | ||
170 | return -EINVAL; | ||
171 | |||
172 | ret = dev->i2c_write(dev->priv_dev, 0xf4, c_table[index*3+2]); | ||
173 | if (ret < 0) | ||
174 | return -EINVAL; | ||
175 | |||
176 | ret = dev->i2c_write(dev->priv_dev, 0xf5, 0xae); | ||
177 | if (ret < 0) | ||
178 | return -EINVAL; | ||
179 | |||
180 | ret = dev->i2c_write(dev->priv_dev, 0xf6, 0xb7); | ||
181 | if (ret < 0) | ||
182 | return -EINVAL; | ||
183 | |||
184 | ret = dev->i2c_write(dev->priv_dev, 0xf7, 0xba); | ||
185 | if (ret < 0) | ||
186 | return -EINVAL; | ||
187 | |||
188 | ret = dev->i2c_write(dev->priv_dev, 0xf8, 0xd7); | ||
189 | if (ret < 0) | ||
190 | return -EINVAL; | ||
191 | |||
192 | ret = dev->i2c_write(dev->priv_dev, 0x68, 0x0a); | ||
193 | if (ret < 0) | ||
194 | return -EINVAL; | ||
195 | |||
196 | ret = dev->i2c_write(dev->priv_dev, 0x69, 0x09); | ||
197 | if (ret < 0) | ||
198 | return -EINVAL; | ||
199 | |||
200 | dev->i2c_write(dev->priv_dev, 0x01, 0x40); | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static int s921_isdb_get_status(struct s921_isdb_t *dev, void *data) { | ||
205 | unsigned int *ret = (unsigned int*)data; | ||
206 | u8 ifagc_dt; | ||
207 | u8 rfagc_dt; | ||
208 | |||
209 | mdelay(10); | ||
210 | ifagc_dt = dev->i2c_read(dev->priv_dev, 0x81); | ||
211 | rfagc_dt = dev->i2c_read(dev->priv_dev, 0x82); | ||
212 | if (rfagc_dt == 0x40) { | ||
213 | *ret = 1; | ||
214 | } | ||
215 | return 0; | ||
216 | } | ||
diff --git a/drivers/media/dvb/frontends/s921_core.h b/drivers/media/dvb/frontends/s921_core.h new file mode 100644 index 000000000000..de2f10a44e72 --- /dev/null +++ b/drivers/media/dvb/frontends/s921_core.h | |||
@@ -0,0 +1,114 @@ | |||
1 | #ifndef _S921_CORE_H | ||
2 | #define _S921_CORE_H | ||
3 | //#define u8 unsigned int | ||
4 | //#define u32 unsigned int | ||
5 | |||
6 | |||
7 | |||
8 | //#define EINVAL -1 | ||
9 | #define E_OK 0 | ||
10 | |||
11 | struct s921_isdb_t { | ||
12 | void *priv_dev; | ||
13 | int (*i2c_write)(void *dev, u8 reg, u8 val); | ||
14 | int (*i2c_read)(void *dev, u8 reg); | ||
15 | }; | ||
16 | |||
17 | #define ISDB_T_CMD_INIT 0 | ||
18 | #define ISDB_T_CMD_SET_PARAM 1 | ||
19 | #define ISDB_T_CMD_TUNE 2 | ||
20 | #define ISDB_T_CMD_GET_STATUS 3 | ||
21 | |||
22 | struct s921_isdb_t_tune_params { | ||
23 | u32 frequency; | ||
24 | }; | ||
25 | |||
26 | struct s921_isdb_t_status { | ||
27 | }; | ||
28 | |||
29 | struct s921_isdb_t_transmission_mode_params { | ||
30 | u8 mode; | ||
31 | u8 layer_a_mode; | ||
32 | #define ISDB_T_LA_MODE_1 0 | ||
33 | #define ISDB_T_LA_MODE_2 1 | ||
34 | #define ISDB_T_LA_MODE_3 2 | ||
35 | u8 layer_a_carrier_modulation; | ||
36 | #define ISDB_T_LA_CM_DQPSK 0 | ||
37 | #define ISDB_T_LA_CM_QPSK 1 | ||
38 | #define ISDB_T_LA_CM_16QAM 2 | ||
39 | #define ISDB_T_LA_CM_64QAM 3 | ||
40 | #define ISDB_T_LA_CM_NOLAYER 4 | ||
41 | u8 layer_a_code_rate; | ||
42 | #define ISDB_T_LA_CR_1_2 0 | ||
43 | #define ISDB_T_LA_CR_2_3 1 | ||
44 | #define ISDB_T_LA_CR_3_4 2 | ||
45 | #define ISDB_T_LA_CR_5_6 4 | ||
46 | #define ISDB_T_LA_CR_7_8 8 | ||
47 | #define ISDB_T_LA_CR_NOLAYER 16 | ||
48 | u8 layer_a_time_interleave; | ||
49 | #define ISDB_T_LA_TI_0 0 | ||
50 | #define ISDB_T_LA_TI_1 1 | ||
51 | #define ISDB_T_LA_TI_2 2 | ||
52 | #define ISDB_T_LA_TI_4 4 | ||
53 | #define ISDB_T_LA_TI_8 8 | ||
54 | #define ISDB_T_LA_TI_16 16 | ||
55 | #define ISDB_T_LA_TI_32 32 | ||
56 | u8 layer_a_nseg; | ||
57 | |||
58 | u8 layer_b_mode; | ||
59 | #define ISDB_T_LB_MODE_1 0 | ||
60 | #define ISDB_T_LB_MODE_2 1 | ||
61 | #define ISDB_T_LB_MODE_3 2 | ||
62 | u8 layer_b_carrier_modulation; | ||
63 | #define ISDB_T_LB_CM_DQPSK 0 | ||
64 | #define ISDB_T_LB_CM_QPSK 1 | ||
65 | #define ISDB_T_LB_CM_16QAM 2 | ||
66 | #define ISDB_T_LB_CM_64QAM 3 | ||
67 | #define ISDB_T_LB_CM_NOLAYER 4 | ||
68 | u8 layer_b_code_rate; | ||
69 | #define ISDB_T_LB_CR_1_2 0 | ||
70 | #define ISDB_T_LB_CR_2_3 1 | ||
71 | #define ISDB_T_LB_CR_3_4 2 | ||
72 | #define ISDB_T_LB_CR_5_6 4 | ||
73 | #define ISDB_T_LB_CR_7_8 8 | ||
74 | #define ISDB_T_LB_CR_NOLAYER 16 | ||
75 | u8 layer_b_time_interleave; | ||
76 | #define ISDB_T_LB_TI_0 0 | ||
77 | #define ISDB_T_LB_TI_1 1 | ||
78 | #define ISDB_T_LB_TI_2 2 | ||
79 | #define ISDB_T_LB_TI_4 4 | ||
80 | #define ISDB_T_LB_TI_8 8 | ||
81 | #define ISDB_T_LB_TI_16 16 | ||
82 | #define ISDB_T_LB_TI_32 32 | ||
83 | u8 layer_b_nseg; | ||
84 | |||
85 | u8 layer_c_mode; | ||
86 | #define ISDB_T_LC_MODE_1 0 | ||
87 | #define ISDB_T_LC_MODE_2 1 | ||
88 | #define ISDB_T_LC_MODE_3 2 | ||
89 | u8 layer_c_carrier_modulation; | ||
90 | #define ISDB_T_LC_CM_DQPSK 0 | ||
91 | #define ISDB_T_LC_CM_QPSK 1 | ||
92 | #define ISDB_T_LC_CM_16QAM 2 | ||
93 | #define ISDB_T_LC_CM_64QAM 3 | ||
94 | #define ISDB_T_LC_CM_NOLAYER 4 | ||
95 | u8 layer_c_code_rate; | ||
96 | #define ISDB_T_LC_CR_1_2 0 | ||
97 | #define ISDB_T_LC_CR_2_3 1 | ||
98 | #define ISDB_T_LC_CR_3_4 2 | ||
99 | #define ISDB_T_LC_CR_5_6 4 | ||
100 | #define ISDB_T_LC_CR_7_8 8 | ||
101 | #define ISDB_T_LC_CR_NOLAYER 16 | ||
102 | u8 layer_c_time_interleave; | ||
103 | #define ISDB_T_LC_TI_0 0 | ||
104 | #define ISDB_T_LC_TI_1 1 | ||
105 | #define ISDB_T_LC_TI_2 2 | ||
106 | #define ISDB_T_LC_TI_4 4 | ||
107 | #define ISDB_T_LC_TI_8 8 | ||
108 | #define ISDB_T_LC_TI_16 16 | ||
109 | #define ISDB_T_LC_TI_32 32 | ||
110 | u8 layer_c_nseg; | ||
111 | }; | ||
112 | |||
113 | int s921_isdb_cmd(struct s921_isdb_t *dev, u32 cmd, void *data); | ||
114 | #endif | ||
diff --git a/drivers/media/dvb/frontends/s921_module.c b/drivers/media/dvb/frontends/s921_module.c new file mode 100644 index 000000000000..3cbb9cb2cf47 --- /dev/null +++ b/drivers/media/dvb/frontends/s921_module.c | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * Driver for Sharp s921 driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Markus Rechberger <mrechberger@sundtek.de> | ||
5 | * | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/delay.h> | ||
13 | #include "dvb_frontend.h" | ||
14 | #include "s921_module.h" | ||
15 | #include "s921_core.h" | ||
16 | |||
17 | static unsigned int debug = 0; | ||
18 | module_param(debug, int, 0644); | ||
19 | MODULE_PARM_DESC(debug,"s921 debugging (default off)"); | ||
20 | |||
21 | #define dprintk(fmt, args...) if (debug) do {\ | ||
22 | printk("s921 debug: " fmt, ##args); } while (0) | ||
23 | |||
24 | struct s921_state | ||
25 | { | ||
26 | struct dvb_frontend frontend; | ||
27 | fe_modulation_t current_modulation; | ||
28 | __u32 snr; | ||
29 | __u32 current_frequency; | ||
30 | __u8 addr; | ||
31 | struct s921_isdb_t dev; | ||
32 | struct i2c_adapter *i2c; | ||
33 | }; | ||
34 | |||
35 | static int s921_set_parameters(struct dvb_frontend *fe, struct dvb_frontend_parameters *param) { | ||
36 | struct s921_state *state = (struct s921_state *)fe->demodulator_priv; | ||
37 | struct s921_isdb_t_transmission_mode_params params; | ||
38 | struct s921_isdb_t_tune_params tune_params; | ||
39 | |||
40 | tune_params.frequency = param->frequency; | ||
41 | s921_isdb_cmd(&state->dev, ISDB_T_CMD_SET_PARAM, ¶ms); | ||
42 | s921_isdb_cmd(&state->dev, ISDB_T_CMD_TUNE, &tune_params); | ||
43 | mdelay(100); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static int s921_init(struct dvb_frontend *fe) { | ||
48 | printk("s921 init\n"); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static int s921_sleep(struct dvb_frontend *fe) { | ||
53 | printk("s921 sleep\n"); | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static int s921_read_status(struct dvb_frontend *fe, fe_status_t *status) | ||
58 | { | ||
59 | struct s921_state *state = (struct s921_state *)fe->demodulator_priv; | ||
60 | unsigned int ret; | ||
61 | mdelay(5); | ||
62 | s921_isdb_cmd(&state->dev, ISDB_T_CMD_GET_STATUS, &ret); | ||
63 | *status = 0; | ||
64 | |||
65 | printk("status: %02x\n", ret); | ||
66 | if (ret == 1) { | ||
67 | *status |= FE_HAS_CARRIER; | ||
68 | *status |= FE_HAS_VITERBI; | ||
69 | *status |= FE_HAS_LOCK; | ||
70 | *status |= FE_HAS_SYNC; | ||
71 | *status |= FE_HAS_SIGNAL; | ||
72 | } | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static int s921_read_ber(struct dvb_frontend *fe, __u32 *ber) | ||
78 | { | ||
79 | dprintk("read ber\n"); | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static int s921_read_snr(struct dvb_frontend *fe, __u16 *snr) | ||
84 | { | ||
85 | dprintk("read snr\n"); | ||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static int s921_read_ucblocks(struct dvb_frontend *fe, __u32 *ucblocks) | ||
90 | { | ||
91 | dprintk("read ucblocks\n"); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | static void s921_release(struct dvb_frontend *fe) | ||
96 | { | ||
97 | struct s921_state *state = (struct s921_state *)fe->demodulator_priv; | ||
98 | kfree(state); | ||
99 | } | ||
100 | |||
101 | static struct dvb_frontend_ops demod_s921={ | ||
102 | .info = { | ||
103 | .name = "SHARP S921", | ||
104 | .type = FE_OFDM, | ||
105 | .frequency_min = 473143000, | ||
106 | .frequency_max = 767143000, | ||
107 | .frequency_stepsize = 6000000, | ||
108 | .frequency_tolerance = 0, | ||
109 | .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | | ||
110 | FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | | ||
111 | FE_CAN_FEC_AUTO | | ||
112 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | | ||
113 | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | | ||
114 | FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | | ||
115 | FE_CAN_MUTE_TS | ||
116 | }, | ||
117 | .init = s921_init, | ||
118 | .sleep = s921_sleep, | ||
119 | .set_frontend = s921_set_parameters, | ||
120 | .read_snr = s921_read_snr, | ||
121 | .read_ber = s921_read_ber, | ||
122 | .read_status = s921_read_status, | ||
123 | .read_ucblocks = s921_read_ucblocks, | ||
124 | .release = s921_release, | ||
125 | }; | ||
126 | |||
127 | static int s921_write(void *dev, u8 reg, u8 val) { | ||
128 | struct s921_state *state = dev; | ||
129 | char buf[2]={reg,val}; | ||
130 | int err; | ||
131 | struct i2c_msg i2cmsgs = { | ||
132 | .addr = state->addr, | ||
133 | .flags = 0, | ||
134 | .len = 2, | ||
135 | .buf = buf | ||
136 | }; | ||
137 | |||
138 | if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) { | ||
139 | printk("%s i2c_transfer error %d\n", __FUNCTION__, err); | ||
140 | if (err < 0) | ||
141 | return err; | ||
142 | else | ||
143 | return -EREMOTEIO; | ||
144 | } | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static int s921_read(void *dev, u8 reg) { | ||
150 | struct s921_state *state = dev; | ||
151 | u8 b1; | ||
152 | int ret; | ||
153 | struct i2c_msg msg[2] = { { .addr = state->addr, | ||
154 | .flags = 0, | ||
155 | .buf = ®, .len = 1 }, | ||
156 | { .addr = state->addr, | ||
157 | .flags = I2C_M_RD, | ||
158 | .buf = &b1, .len = 1 } }; | ||
159 | |||
160 | ret = i2c_transfer(state->i2c, msg, 2); | ||
161 | if (ret != 2) | ||
162 | return ret; | ||
163 | return b1; | ||
164 | } | ||
165 | |||
166 | struct dvb_frontend* s921_attach(const struct s921_config *config, | ||
167 | struct i2c_adapter *i2c) | ||
168 | { | ||
169 | |||
170 | struct s921_state *state; | ||
171 | state = kzalloc(sizeof(struct s921_state), GFP_KERNEL); | ||
172 | memset(state, 0x0, sizeof(struct s921_state)); | ||
173 | |||
174 | state->addr = config->i2c_address; | ||
175 | state->i2c = i2c; | ||
176 | state->dev.i2c_write = &s921_write; | ||
177 | state->dev.i2c_read = &s921_read; | ||
178 | state->dev.priv_dev = state; | ||
179 | |||
180 | s921_isdb_cmd(&state->dev, ISDB_T_CMD_INIT, NULL); | ||
181 | |||
182 | memcpy(&state->frontend.ops, &demod_s921, sizeof(struct dvb_frontend_ops)); | ||
183 | state->frontend.demodulator_priv = state; | ||
184 | return &state->frontend; | ||
185 | } | ||
186 | |||
187 | EXPORT_SYMBOL_GPL(s921_attach); | ||
188 | MODULE_AUTHOR("Markus Rechberger <mrechberger@empiatech.com>"); | ||
189 | MODULE_DESCRIPTION("Sharp S921 ISDB-T 1Seg"); | ||
190 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/s921_module.h b/drivers/media/dvb/frontends/s921_module.h new file mode 100644 index 000000000000..78660424ba95 --- /dev/null +++ b/drivers/media/dvb/frontends/s921_module.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Driver for DVB-T s921 demodulator | ||
3 | * | ||
4 | * Copyright (C) 2008 Markus Rechberger <mrechberger@sundtek.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
20 | */ | ||
21 | |||
22 | #ifndef S921_MODULE_H | ||
23 | #define S921_MODULE_H | ||
24 | |||
25 | #include <linux/dvb/frontend.h> | ||
26 | #include "s921_core.h" | ||
27 | |||
28 | int s921_isdb_init(struct s921_isdb_t *dev); | ||
29 | int s921_isdb_cmd(struct s921_isdb_t *dev, u32 cmd, void *data); | ||
30 | |||
31 | struct s921_config | ||
32 | { | ||
33 | /* demodulator's I2C address */ | ||
34 | u8 i2c_address; | ||
35 | }; | ||
36 | |||
37 | #if defined(CONFIG_DVB_S921) || (defined(CONFIG_DVB_S921_MODULE) && defined(MODULE)) | ||
38 | extern struct dvb_frontend* s921_attach(const struct s921_config *config, | ||
39 | struct i2c_adapter *i2c); | ||
40 | #else | ||
41 | static inline struct dvb_frontend* s921_attach(const struct s921_config *config, | ||
42 | struct i2c_adapter *i2c) | ||
43 | { | ||
44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
45 | return NULL; | ||
46 | } | ||
47 | #endif /* CONFIG_DVB_S921 */ | ||
48 | |||
49 | #endif /* S921_H */ | ||