Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 1 | /* |
| 2 | saa6752hs - i2c-driver for the saa6752hs by Philips |
| 3 | |
| 4 | Copyright (C) 2004 Andrew de Quincey |
| 5 | |
| 6 | AC-3 support: |
| 7 | |
| 8 | Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl> |
| 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 vs 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 Mvss Ave, Cambridge, MA 02139, USA. |
| 23 | */ |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/module.h> |
| 26 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/string.h> |
| 28 | #include <linux/timer.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include <linux/errno.h> |
| 31 | #include <linux/slab.h> |
| 32 | #include <linux/poll.h> |
| 33 | #include <linux/i2c.h> |
| 34 | #include <linux/types.h> |
Mauro Carvalho Chehab | cab462f | 2006-01-09 15:53:26 -0200 | [diff] [blame] | 35 | #include <linux/videodev2.h> |
Hans Verkuil | d8100f4 | 2013-12-14 08:28:30 -0300 | [diff] [blame] | 36 | #include <linux/init.h> |
| 37 | #include <linux/crc32.h> |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 38 | #include <media/v4l2-device.h> |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 39 | #include <media/v4l2-ctrls.h> |
Mauro Carvalho Chehab | cab462f | 2006-01-09 15:53:26 -0200 | [diff] [blame] | 40 | #include <media/v4l2-common.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000 |
| 43 | #define MPEG_VIDEO_MAX_BITRATE_MAX 27000 |
| 44 | #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 |
| 45 | #define MPEG_PID_MAX ((1 << 14) - 1) |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); |
| 49 | MODULE_AUTHOR("Andrew de Quincey"); |
| 50 | MODULE_LICENSE("GPL"); |
| 51 | |
Frederic CAND | 0a4c9c9 | 2005-05-05 16:15:52 -0700 | [diff] [blame] | 52 | enum saa6752hs_videoformat { |
| 53 | SAA6752HS_VF_D1 = 0, /* standard D1 video format: 720x576 */ |
| 54 | SAA6752HS_VF_2_3_D1 = 1,/* 2/3D1 video format: 480x576 */ |
| 55 | SAA6752HS_VF_1_2_D1 = 2,/* 1/2D1 video format: 352x576 */ |
| 56 | SAA6752HS_VF_SIF = 3, /* SIF video format: 352x288 */ |
| 57 | SAA6752HS_VF_UNKNOWN, |
| 58 | }; |
| 59 | |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 60 | struct saa6752hs_mpeg_params { |
| 61 | /* transport streams */ |
| 62 | __u16 ts_pid_pmt; |
| 63 | __u16 ts_pid_audio; |
| 64 | __u16 ts_pid_video; |
| 65 | __u16 ts_pid_pcr; |
| 66 | |
| 67 | /* audio */ |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 68 | enum v4l2_mpeg_audio_encoding au_encoding; |
| 69 | enum v4l2_mpeg_audio_l2_bitrate au_l2_bitrate; |
| 70 | enum v4l2_mpeg_audio_ac3_bitrate au_ac3_bitrate; |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 71 | |
| 72 | /* video */ |
| 73 | enum v4l2_mpeg_video_aspect vi_aspect; |
| 74 | enum v4l2_mpeg_video_bitrate_mode vi_bitrate_mode; |
| 75 | __u32 vi_bitrate; |
| 76 | __u32 vi_bitrate_peak; |
| 77 | }; |
| 78 | |
Frederic CAND | 0a4c9c9 | 2005-05-05 16:15:52 -0700 | [diff] [blame] | 79 | static const struct v4l2_format v4l2_format_table[] = |
| 80 | { |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 81 | [SAA6752HS_VF_D1] = |
| 82 | { .fmt = { .pix = { .width = 720, .height = 576 }}}, |
| 83 | [SAA6752HS_VF_2_3_D1] = |
| 84 | { .fmt = { .pix = { .width = 480, .height = 576 }}}, |
| 85 | [SAA6752HS_VF_1_2_D1] = |
| 86 | { .fmt = { .pix = { .width = 352, .height = 576 }}}, |
| 87 | [SAA6752HS_VF_SIF] = |
| 88 | { .fmt = { .pix = { .width = 352, .height = 288 }}}, |
| 89 | [SAA6752HS_VF_UNKNOWN] = |
| 90 | { .fmt = { .pix = { .width = 0, .height = 0}}}, |
Frederic CAND | 0a4c9c9 | 2005-05-05 16:15:52 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | struct saa6752hs_state { |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 94 | struct v4l2_subdev sd; |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 95 | struct v4l2_ctrl_handler hdl; |
| 96 | struct { /* video bitrate mode control cluster */ |
| 97 | struct v4l2_ctrl *video_bitrate_mode; |
| 98 | struct v4l2_ctrl *video_bitrate; |
| 99 | struct v4l2_ctrl *video_bitrate_peak; |
| 100 | }; |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 101 | u32 revision; |
| 102 | int has_ac3; |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 103 | struct saa6752hs_mpeg_params params; |
Frederic CAND | 0a4c9c9 | 2005-05-05 16:15:52 -0700 | [diff] [blame] | 104 | enum saa6752hs_videoformat video_format; |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 105 | v4l2_std_id standard; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | enum saa6752hs_command { |
| 109 | SAA6752HS_COMMAND_RESET = 0, |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 110 | SAA6752HS_COMMAND_STOP = 1, |
| 111 | SAA6752HS_COMMAND_START = 2, |
| 112 | SAA6752HS_COMMAND_PAUSE = 3, |
| 113 | SAA6752HS_COMMAND_RECONFIGURE = 4, |
| 114 | SAA6752HS_COMMAND_SLEEP = 5, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | SAA6752HS_COMMAND_RECONFIGURE_FORCE = 6, |
| 116 | |
| 117 | SAA6752HS_COMMAND_MAX |
| 118 | }; |
| 119 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 120 | static inline struct saa6752hs_state *to_state(struct v4l2_subdev *sd) |
| 121 | { |
| 122 | return container_of(sd, struct saa6752hs_state, sd); |
| 123 | } |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | /* ---------------------------------------------------------------------- */ |
| 126 | |
Hans Verkuil | d8100f4 | 2013-12-14 08:28:30 -0300 | [diff] [blame] | 127 | static const u8 PAT[] = { |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 128 | 0xc2, /* i2c register */ |
| 129 | 0x00, /* table number for encoder */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 131 | 0x47, /* sync */ |
| 132 | 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0) */ |
| 133 | 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 135 | 0x00, /* PSI pointer to start of table */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 137 | 0x00, /* tid(0) */ |
| 138 | 0xb0, 0x0d, /* section_syntax_indicator(1), section_length(13) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 140 | 0x00, 0x01, /* transport_stream_id(1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 142 | 0xc1, /* version_number(0), current_next_indicator(1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 144 | 0x00, 0x00, /* section_number(0), last_section_number(0) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 146 | 0x00, 0x01, /* program_number(1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 148 | 0xe0, 0x00, /* PMT PID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 150 | 0x00, 0x00, 0x00, 0x00 /* CRC32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
Hans Verkuil | d8100f4 | 2013-12-14 08:28:30 -0300 | [diff] [blame] | 153 | static const u8 PMT[] = { |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 154 | 0xc2, /* i2c register */ |
| 155 | 0x01, /* table number for encoder */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 157 | 0x47, /* sync */ |
| 158 | 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid */ |
| 159 | 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 161 | 0x00, /* PSI pointer to start of table */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 163 | 0x02, /* tid(2) */ |
| 164 | 0xb0, 0x17, /* section_syntax_indicator(1), section_length(23) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 166 | 0x00, 0x01, /* program_number(1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 168 | 0xc1, /* version_number(0), current_next_indicator(1) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 170 | 0x00, 0x00, /* section_number(0), last_section_number(0) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 172 | 0xe0, 0x00, /* PCR_PID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 174 | 0xf0, 0x00, /* program_info_length(0) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 176 | 0x02, 0xe0, 0x00, 0xf0, 0x00, /* video stream type(2), pid */ |
| 177 | 0x04, 0xe0, 0x00, 0xf0, 0x00, /* audio stream type(4), pid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 179 | 0x00, 0x00, 0x00, 0x00 /* CRC32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
Hans Verkuil | d8100f4 | 2013-12-14 08:28:30 -0300 | [diff] [blame] | 182 | static const u8 PMT_AC3[] = { |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 183 | 0xc2, /* i2c register */ |
| 184 | 0x01, /* table number for encoder(1) */ |
| 185 | 0x47, /* sync */ |
| 186 | |
| 187 | 0x40, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0) */ |
| 188 | 0x10, /* PMT PID (0x0010) */ |
| 189 | 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */ |
| 190 | |
| 191 | 0x00, /* PSI pointer to start of table */ |
| 192 | |
| 193 | 0x02, /* TID (2) */ |
| 194 | 0xb0, 0x1a, /* section_syntax_indicator(1), section_length(26) */ |
| 195 | |
| 196 | 0x00, 0x01, /* program_number(1) */ |
| 197 | |
| 198 | 0xc1, /* version_number(0), current_next_indicator(1) */ |
| 199 | |
| 200 | 0x00, 0x00, /* section_number(0), last_section_number(0) */ |
| 201 | |
| 202 | 0xe1, 0x04, /* PCR_PID (0x0104) */ |
| 203 | |
| 204 | 0xf0, 0x00, /* program_info_length(0) */ |
| 205 | |
| 206 | 0x02, 0xe1, 0x00, 0xf0, 0x00, /* video stream type(2), pid */ |
| 207 | 0x06, 0xe1, 0x03, 0xf0, 0x03, /* audio stream type(6), pid */ |
| 208 | 0x6a, /* AC3 */ |
| 209 | 0x01, /* Descriptor_length(1) */ |
| 210 | 0x00, /* component_type_flag(0), bsid_flag(0), mainid_flag(0), asvc_flag(0), reserved flags(0) */ |
| 211 | |
| 212 | 0xED, 0xDE, 0x2D, 0xF3 /* CRC32 BE */ |
| 213 | }; |
| 214 | |
Hans Verkuil | d8100f4 | 2013-12-14 08:28:30 -0300 | [diff] [blame] | 215 | static const struct saa6752hs_mpeg_params param_defaults = |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 216 | { |
| 217 | .ts_pid_pmt = 16, |
| 218 | .ts_pid_video = 260, |
| 219 | .ts_pid_audio = 256, |
| 220 | .ts_pid_pcr = 259, |
| 221 | |
| 222 | .vi_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3, |
| 223 | .vi_bitrate = 4000, |
| 224 | .vi_bitrate_peak = 6000, |
| 225 | .vi_bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, |
| 226 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 227 | .au_encoding = V4L2_MPEG_AUDIO_ENCODING_LAYER_2, |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 228 | .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 229 | .au_ac3_bitrate = V4L2_MPEG_AUDIO_AC3_BITRATE_256K, |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 230 | }; |
| 231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | /* ---------------------------------------------------------------------- */ |
| 233 | |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 234 | static int saa6752hs_chip_command(struct i2c_client *client, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | enum saa6752hs_command command) |
| 236 | { |
| 237 | unsigned char buf[3]; |
| 238 | unsigned long timeout; |
| 239 | int status = 0; |
| 240 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 241 | /* execute the command */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | switch(command) { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 243 | case SAA6752HS_COMMAND_RESET: |
| 244 | buf[0] = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | break; |
| 246 | |
| 247 | case SAA6752HS_COMMAND_STOP: |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 248 | buf[0] = 0x03; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | break; |
| 250 | |
| 251 | case SAA6752HS_COMMAND_START: |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 252 | buf[0] = 0x02; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | break; |
| 254 | |
| 255 | case SAA6752HS_COMMAND_PAUSE: |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 256 | buf[0] = 0x04; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | break; |
| 258 | |
| 259 | case SAA6752HS_COMMAND_RECONFIGURE: |
| 260 | buf[0] = 0x05; |
| 261 | break; |
| 262 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 263 | case SAA6752HS_COMMAND_SLEEP: |
| 264 | buf[0] = 0x06; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | break; |
| 266 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 267 | case SAA6752HS_COMMAND_RECONFIGURE_FORCE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | buf[0] = 0x07; |
| 269 | break; |
| 270 | |
| 271 | default: |
| 272 | return -EINVAL; |
| 273 | } |
| 274 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 275 | /* set it and wait for it to be so */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | i2c_master_send(client, buf, 1); |
| 277 | timeout = jiffies + HZ * 3; |
| 278 | for (;;) { |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 279 | /* get the current status */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | buf[0] = 0x10; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 281 | i2c_master_send(client, buf, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | i2c_master_recv(client, buf, 1); |
| 283 | |
| 284 | if (!(buf[0] & 0x20)) |
| 285 | break; |
| 286 | if (time_after(jiffies,timeout)) { |
| 287 | status = -ETIMEDOUT; |
| 288 | break; |
| 289 | } |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | msleep(10); |
| 292 | } |
| 293 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 294 | /* delay a bit to let encoder settle */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | msleep(50); |
| 296 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 297 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 301 | static inline void set_reg8(struct i2c_client *client, uint8_t reg, uint8_t val) |
| 302 | { |
| 303 | u8 buf[2]; |
| 304 | |
| 305 | buf[0] = reg; |
| 306 | buf[1] = val; |
| 307 | i2c_master_send(client, buf, 2); |
| 308 | } |
| 309 | |
| 310 | static inline void set_reg16(struct i2c_client *client, uint8_t reg, uint16_t val) |
| 311 | { |
| 312 | u8 buf[3]; |
| 313 | |
| 314 | buf[0] = reg; |
| 315 | buf[1] = val >> 8; |
| 316 | buf[2] = val & 0xff; |
| 317 | i2c_master_send(client, buf, 3); |
| 318 | } |
| 319 | |
| 320 | static int saa6752hs_set_bitrate(struct i2c_client *client, |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 321 | struct saa6752hs_state *h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | { |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 323 | struct saa6752hs_mpeg_params *params = &h->params; |
Mauro Carvalho Chehab | b57e557 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 324 | int tot_bitrate; |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 325 | int is_384k; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 327 | /* set the bitrate mode */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 328 | set_reg8(client, 0x71, |
| 329 | params->vi_bitrate_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 331 | /* set the video bitrate */ |
Mauro Carvalho Chehab | b57e557 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 332 | if (params->vi_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) { |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 333 | /* set the target bitrate */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 334 | set_reg16(client, 0x80, params->vi_bitrate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 336 | /* set the max bitrate */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 337 | set_reg16(client, 0x81, params->vi_bitrate_peak); |
Mauro Carvalho Chehab | b57e557 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 338 | tot_bitrate = params->vi_bitrate_peak; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } else { |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 340 | /* set the target bitrate (no max bitrate for CBR) */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 341 | set_reg16(client, 0x81, params->vi_bitrate); |
Mauro Carvalho Chehab | b57e557 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 342 | tot_bitrate = params->vi_bitrate; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 345 | /* set the audio encoding */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 346 | set_reg8(client, 0x93, |
| 347 | params->au_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 348 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 349 | /* set the audio bitrate */ |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 350 | if (params->au_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3) |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 351 | is_384k = V4L2_MPEG_AUDIO_AC3_BITRATE_384K == params->au_ac3_bitrate; |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 352 | else |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 353 | is_384k = V4L2_MPEG_AUDIO_L2_BITRATE_384K == params->au_l2_bitrate; |
| 354 | set_reg8(client, 0x94, is_384k); |
| 355 | tot_bitrate += is_384k ? 384 : 256; |
Mauro Carvalho Chehab | b57e557 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 356 | |
| 357 | /* Note: the total max bitrate is determined by adding the video and audio |
| 358 | bitrates together and also adding an extra 768kbit/s to stay on the |
| 359 | safe side. If more control should be required, then an extra MPEG control |
| 360 | should be added. */ |
| 361 | tot_bitrate += 768; |
| 362 | if (tot_bitrate > MPEG_TOTAL_TARGET_BITRATE_MAX) |
| 363 | tot_bitrate = MPEG_TOTAL_TARGET_BITRATE_MAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 365 | /* set the total bitrate */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 366 | set_reg16(client, 0xb1, tot_bitrate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 370 | static int saa6752hs_try_ctrl(struct v4l2_ctrl *ctrl) |
Frederic CAND | 0a4c9c9 | 2005-05-05 16:15:52 -0700 | [diff] [blame] | 371 | { |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 372 | struct saa6752hs_state *h = |
| 373 | container_of(ctrl->handler, struct saa6752hs_state, hdl); |
| 374 | |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 375 | switch (ctrl->id) { |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 376 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 377 | /* peak bitrate shall be >= normal bitrate */ |
| 378 | if (ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && |
| 379 | h->video_bitrate_peak->val < h->video_bitrate->val) |
| 380 | h->video_bitrate_peak->val = h->video_bitrate->val; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 381 | break; |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 382 | } |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 383 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 386 | static int saa6752hs_s_ctrl(struct v4l2_ctrl *ctrl) |
Hans Verkuil | 8b53b39 | 2008-06-27 21:18:15 -0300 | [diff] [blame] | 387 | { |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 388 | struct saa6752hs_state *h = |
| 389 | container_of(ctrl->handler, struct saa6752hs_state, hdl); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 390 | struct saa6752hs_mpeg_params *params = &h->params; |
Hans Verkuil | 8b53b39 | 2008-06-27 21:18:15 -0300 | [diff] [blame] | 391 | |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 392 | switch (ctrl->id) { |
Hans Verkuil | 8b53b39 | 2008-06-27 21:18:15 -0300 | [diff] [blame] | 393 | case V4L2_CID_MPEG_STREAM_TYPE: |
Hans Verkuil | 8b53b39 | 2008-06-27 21:18:15 -0300 | [diff] [blame] | 394 | break; |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 395 | case V4L2_CID_MPEG_STREAM_PID_PMT: |
| 396 | params->ts_pid_pmt = ctrl->val; |
| 397 | break; |
| 398 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: |
| 399 | params->ts_pid_audio = ctrl->val; |
| 400 | break; |
| 401 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: |
| 402 | params->ts_pid_video = ctrl->val; |
| 403 | break; |
| 404 | case V4L2_CID_MPEG_STREAM_PID_PCR: |
| 405 | params->ts_pid_pcr = ctrl->val; |
| 406 | break; |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 407 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 408 | params->au_encoding = ctrl->val; |
| 409 | break; |
| 410 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
| 411 | params->au_l2_bitrate = ctrl->val; |
| 412 | break; |
| 413 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: |
| 414 | params->au_ac3_bitrate = ctrl->val; |
| 415 | break; |
| 416 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: |
| 417 | break; |
| 418 | case V4L2_CID_MPEG_VIDEO_ENCODING: |
| 419 | break; |
| 420 | case V4L2_CID_MPEG_VIDEO_ASPECT: |
| 421 | params->vi_aspect = ctrl->val; |
| 422 | break; |
| 423 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
| 424 | params->vi_bitrate_mode = ctrl->val; |
| 425 | params->vi_bitrate = h->video_bitrate->val / 1000; |
| 426 | params->vi_bitrate_peak = h->video_bitrate_peak->val / 1000; |
| 427 | v4l2_ctrl_activate(h->video_bitrate_peak, |
| 428 | ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); |
| 429 | break; |
| 430 | default: |
| 431 | return -EINVAL; |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 432 | } |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 433 | return 0; |
Hans Verkuil | 8b53b39 | 2008-06-27 21:18:15 -0300 | [diff] [blame] | 434 | } |
| 435 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 436 | static int saa6752hs_init(struct v4l2_subdev *sd, u32 leading_null_bytes) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | { |
| 438 | unsigned char buf[9], buf2[4]; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 439 | struct saa6752hs_state *h = to_state(sd); |
| 440 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 441 | unsigned size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | u32 crc; |
| 443 | unsigned char localPAT[256]; |
| 444 | unsigned char localPMT[256]; |
| 445 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 446 | /* Set video format - must be done first as it resets other settings */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 447 | set_reg8(client, 0x41, h->video_format); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 449 | /* Set number of lines in input signal */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 450 | set_reg8(client, 0x40, (h->standard & V4L2_STD_525_60) ? 1 : 0); |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 451 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 452 | /* set bitrate */ |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 453 | saa6752hs_set_bitrate(client, h); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 455 | /* Set GOP structure {3, 13} */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 456 | set_reg16(client, 0x72, 0x030d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 458 | /* Set minimum Q-scale {4} */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 459 | set_reg8(client, 0x82, 0x04); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 461 | /* Set maximum Q-scale {12} */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 462 | set_reg8(client, 0x83, 0x0c); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 464 | /* Set Output Protocol */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 465 | set_reg8(client, 0xd0, 0x81); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 467 | /* Set video output stream format {TS} */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 468 | set_reg8(client, 0xb0, 0x05); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Dmitry Belimov | f03813e | 2008-08-26 13:44:40 -0300 | [diff] [blame] | 470 | /* Set leading null byte for TS */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 471 | set_reg16(client, 0xf6, leading_null_bytes); |
Dmitry Belimov | f03813e | 2008-08-26 13:44:40 -0300 | [diff] [blame] | 472 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | /* compute PAT */ |
| 474 | memcpy(localPAT, PAT, sizeof(PAT)); |
| 475 | localPAT[17] = 0xe0 | ((h->params.ts_pid_pmt >> 8) & 0x0f); |
| 476 | localPAT[18] = h->params.ts_pid_pmt & 0xff; |
| 477 | crc = crc32_be(~0, &localPAT[7], sizeof(PAT) - 7 - 4); |
| 478 | localPAT[sizeof(PAT) - 4] = (crc >> 24) & 0xFF; |
| 479 | localPAT[sizeof(PAT) - 3] = (crc >> 16) & 0xFF; |
| 480 | localPAT[sizeof(PAT) - 2] = (crc >> 8) & 0xFF; |
| 481 | localPAT[sizeof(PAT) - 1] = crc & 0xFF; |
| 482 | |
| 483 | /* compute PMT */ |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 484 | if (h->params.au_encoding == V4L2_MPEG_AUDIO_ENCODING_AC3) { |
| 485 | size = sizeof(PMT_AC3); |
| 486 | memcpy(localPMT, PMT_AC3, size); |
| 487 | } else { |
| 488 | size = sizeof(PMT); |
| 489 | memcpy(localPMT, PMT, size); |
| 490 | } |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 491 | localPMT[3] = 0x40 | ((h->params.ts_pid_pmt >> 8) & 0x0f); |
| 492 | localPMT[4] = h->params.ts_pid_pmt & 0xff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | localPMT[15] = 0xE0 | ((h->params.ts_pid_pcr >> 8) & 0x0F); |
| 494 | localPMT[16] = h->params.ts_pid_pcr & 0xFF; |
| 495 | localPMT[20] = 0xE0 | ((h->params.ts_pid_video >> 8) & 0x0F); |
| 496 | localPMT[21] = h->params.ts_pid_video & 0xFF; |
| 497 | localPMT[25] = 0xE0 | ((h->params.ts_pid_audio >> 8) & 0x0F); |
| 498 | localPMT[26] = h->params.ts_pid_audio & 0xFF; |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 499 | crc = crc32_be(~0, &localPMT[7], size - 7 - 4); |
| 500 | localPMT[size - 4] = (crc >> 24) & 0xFF; |
| 501 | localPMT[size - 3] = (crc >> 16) & 0xFF; |
| 502 | localPMT[size - 2] = (crc >> 8) & 0xFF; |
| 503 | localPMT[size - 1] = crc & 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 505 | /* Set Audio PID */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 506 | set_reg16(client, 0xc1, h->params.ts_pid_audio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 508 | /* Set Video PID */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 509 | set_reg16(client, 0xc0, h->params.ts_pid_video); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 511 | /* Set PCR PID */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 512 | set_reg16(client, 0xc4, h->params.ts_pid_pcr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 514 | /* Send SI tables */ |
Hans Verkuil | 3eea543 | 2008-08-08 13:27:16 -0300 | [diff] [blame] | 515 | i2c_master_send(client, localPAT, sizeof(PAT)); |
| 516 | i2c_master_send(client, localPMT, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 518 | /* mute then unmute audio. This removes buzzing artefacts */ |
Hans Verkuil | ff5f26b | 2008-09-06 07:00:24 -0300 | [diff] [blame] | 519 | set_reg8(client, 0xa4, 1); |
| 520 | set_reg8(client, 0xa4, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 522 | /* start it going */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | saa6752hs_chip_command(client, SAA6752HS_COMMAND_START); |
| 524 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 525 | /* readout current state */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | buf[0] = 0xE1; |
| 527 | buf[1] = 0xA7; |
| 528 | buf[2] = 0xFE; |
| 529 | buf[3] = 0x82; |
| 530 | buf[4] = 0xB0; |
| 531 | i2c_master_send(client, buf, 5); |
| 532 | i2c_master_recv(client, buf2, 4); |
| 533 | |
Robert W. Boone | 9b71521 | 2005-11-08 21:36:45 -0800 | [diff] [blame] | 534 | /* change aspect ratio */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | buf[0] = 0xE0; |
| 536 | buf[1] = 0xA7; |
| 537 | buf[2] = 0xFE; |
| 538 | buf[3] = 0x82; |
| 539 | buf[4] = 0xB0; |
| 540 | buf[5] = buf2[0]; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 541 | switch (h->params.vi_aspect) { |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 542 | case V4L2_MPEG_VIDEO_ASPECT_16x9: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | buf[6] = buf2[1] | 0x40; |
| 544 | break; |
Hans Verkuil | 86b79d66 | 2006-06-18 16:40:10 -0300 | [diff] [blame] | 545 | case V4L2_MPEG_VIDEO_ASPECT_4x3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | default: |
| 547 | buf[6] = buf2[1] & 0xBF; |
| 548 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | } |
| 550 | buf[7] = buf2[2]; |
| 551 | buf[8] = buf2[3]; |
| 552 | i2c_master_send(client, buf, 9); |
| 553 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | return 0; |
| 555 | } |
| 556 | |
Hans Verkuil | da298c6 | 2015-04-09 04:02:34 -0300 | [diff] [blame] | 557 | static int saa6752hs_get_fmt(struct v4l2_subdev *sd, |
| 558 | struct v4l2_subdev_pad_config *cfg, |
| 559 | struct v4l2_subdev_format *format) |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 560 | { |
Hans Verkuil | da298c6 | 2015-04-09 04:02:34 -0300 | [diff] [blame] | 561 | struct v4l2_mbus_framefmt *f = &format->format; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 562 | struct saa6752hs_state *h = to_state(sd); |
| 563 | |
Hans Verkuil | da298c6 | 2015-04-09 04:02:34 -0300 | [diff] [blame] | 564 | if (format->pad) |
| 565 | return -EINVAL; |
| 566 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 567 | if (h->video_format == SAA6752HS_VF_UNKNOWN) |
| 568 | h->video_format = SAA6752HS_VF_D1; |
Hans Verkuil | 51623ef | 2010-05-09 09:39:58 -0300 | [diff] [blame] | 569 | f->width = v4l2_format_table[h->video_format].fmt.pix.width; |
| 570 | f->height = v4l2_format_table[h->video_format].fmt.pix.height; |
Boris BREZILLON | f5fe58f | 2014-11-10 14:28:29 -0300 | [diff] [blame] | 571 | f->code = MEDIA_BUS_FMT_FIXED; |
Hans Verkuil | 51623ef | 2010-05-09 09:39:58 -0300 | [diff] [blame] | 572 | f->field = V4L2_FIELD_INTERLACED; |
| 573 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 574 | return 0; |
| 575 | } |
| 576 | |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 577 | static int saa6752hs_set_fmt(struct v4l2_subdev *sd, |
| 578 | struct v4l2_subdev_pad_config *cfg, |
| 579 | struct v4l2_subdev_format *format) |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 580 | { |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 581 | struct v4l2_mbus_framefmt *f = &format->format; |
| 582 | struct saa6752hs_state *h = to_state(sd); |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 583 | int dist_352, dist_480, dist_720; |
| 584 | |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 585 | if (format->pad) |
| 586 | return -EINVAL; |
| 587 | |
Boris BREZILLON | f5fe58f | 2014-11-10 14:28:29 -0300 | [diff] [blame] | 588 | f->code = MEDIA_BUS_FMT_FIXED; |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 589 | |
| 590 | dist_352 = abs(f->width - 352); |
| 591 | dist_480 = abs(f->width - 480); |
| 592 | dist_720 = abs(f->width - 720); |
| 593 | if (dist_720 < dist_480) { |
| 594 | f->width = 720; |
| 595 | f->height = 576; |
| 596 | } else if (dist_480 < dist_352) { |
| 597 | f->width = 480; |
| 598 | f->height = 576; |
| 599 | } else { |
| 600 | f->width = 352; |
| 601 | if (abs(f->height - 576) < abs(f->height - 288)) |
| 602 | f->height = 576; |
| 603 | else |
| 604 | f->height = 288; |
| 605 | } |
| 606 | f->field = V4L2_FIELD_INTERLACED; |
| 607 | f->colorspace = V4L2_COLORSPACE_SMPTE170M; |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 608 | |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 609 | if (format->which == V4L2_SUBDEV_FORMAT_TRY) { |
| 610 | cfg->try_fmt = *f; |
| 611 | return 0; |
| 612 | } |
Hans Verkuil | 51623ef | 2010-05-09 09:39:58 -0300 | [diff] [blame] | 613 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 614 | /* |
| 615 | FIXME: translate and round width/height into EMPRESS |
| 616 | subsample type: |
| 617 | |
| 618 | type | PAL | NTSC |
| 619 | --------------------------- |
| 620 | SIF | 352x288 | 352x240 |
| 621 | 1/2 D1 | 352x576 | 352x480 |
| 622 | 2/3 D1 | 480x576 | 480x480 |
| 623 | D1 | 720x576 | 720x480 |
| 624 | */ |
| 625 | |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 626 | if (f->code != MEDIA_BUS_FMT_FIXED) |
| 627 | return -EINVAL; |
| 628 | |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 629 | if (f->width == 720) |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 630 | h->video_format = SAA6752HS_VF_D1; |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 631 | else if (f->width == 480) |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 632 | h->video_format = SAA6752HS_VF_2_3_D1; |
Hans Verkuil | cabc650 | 2013-06-01 10:02:38 -0300 | [diff] [blame] | 633 | else if (f->height == 576) |
| 634 | h->video_format = SAA6752HS_VF_1_2_D1; |
| 635 | else |
| 636 | h->video_format = SAA6752HS_VF_SIF; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | static int saa6752hs_s_std(struct v4l2_subdev *sd, v4l2_std_id std) |
| 641 | { |
| 642 | struct saa6752hs_state *h = to_state(sd); |
| 643 | |
| 644 | h->standard = std; |
| 645 | return 0; |
| 646 | } |
| 647 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 648 | /* ----------------------------------------------------------------------- */ |
| 649 | |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 650 | static const struct v4l2_ctrl_ops saa6752hs_ctrl_ops = { |
| 651 | .try_ctrl = saa6752hs_try_ctrl, |
| 652 | .s_ctrl = saa6752hs_s_ctrl, |
| 653 | }; |
| 654 | |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 655 | static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 656 | .init = saa6752hs_init, |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 657 | }; |
| 658 | |
| 659 | static const struct v4l2_subdev_video_ops saa6752hs_video_ops = { |
Laurent Pinchart | 8774bed | 2014-04-28 16:53:01 -0300 | [diff] [blame] | 660 | .s_std = saa6752hs_s_std, |
Hans Verkuil | da298c6 | 2015-04-09 04:02:34 -0300 | [diff] [blame] | 661 | }; |
| 662 | |
| 663 | static const struct v4l2_subdev_pad_ops saa6752hs_pad_ops = { |
| 664 | .get_fmt = saa6752hs_get_fmt, |
Hans Verkuil | 717fd5b | 2015-04-09 06:24:36 -0300 | [diff] [blame] | 665 | .set_fmt = saa6752hs_set_fmt, |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 666 | }; |
| 667 | |
| 668 | static const struct v4l2_subdev_ops saa6752hs_ops = { |
| 669 | .core = &saa6752hs_core_ops, |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 670 | .video = &saa6752hs_video_ops, |
Hans Verkuil | da298c6 | 2015-04-09 04:02:34 -0300 | [diff] [blame] | 671 | .pad = &saa6752hs_pad_ops, |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 672 | }; |
| 673 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 674 | static int saa6752hs_probe(struct i2c_client *client, |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 675 | const struct i2c_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | { |
Axel Lin | 6af6e9c | 2014-08-10 06:41:31 -0300 | [diff] [blame] | 677 | struct saa6752hs_state *h; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 678 | struct v4l2_subdev *sd; |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 679 | struct v4l2_ctrl_handler *hdl; |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 680 | u8 addr = 0x13; |
| 681 | u8 data[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 683 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
| 684 | client->addr << 1, client->adapter->name); |
Axel Lin | 6af6e9c | 2014-08-10 06:41:31 -0300 | [diff] [blame] | 685 | |
| 686 | h = devm_kzalloc(&client->dev, sizeof(*h), GFP_KERNEL); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 687 | if (h == NULL) |
| 688 | return -ENOMEM; |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 689 | sd = &h->sd; |
| 690 | v4l2_i2c_subdev_init(sd, client, &saa6752hs_ops); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 691 | |
| 692 | i2c_master_send(client, &addr, 1); |
| 693 | i2c_master_recv(client, data, sizeof(data)); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 694 | h->revision = (data[8] << 8) | data[9]; |
| 695 | h->has_ac3 = 0; |
| 696 | if (h->revision == 0x0206) { |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 697 | h->has_ac3 = 1; |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 698 | v4l_info(client, "supports AC-3\n"); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 699 | } |
| 700 | h->params = param_defaults; |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 701 | |
| 702 | hdl = &h->hdl; |
| 703 | v4l2_ctrl_handler_init(hdl, 14); |
| 704 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 705 | V4L2_CID_MPEG_AUDIO_ENCODING, |
| 706 | h->has_ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : |
| 707 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, |
| 708 | 0x0d, V4L2_MPEG_AUDIO_ENCODING_LAYER_2); |
| 709 | |
| 710 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 711 | V4L2_CID_MPEG_AUDIO_L2_BITRATE, |
| 712 | V4L2_MPEG_AUDIO_L2_BITRATE_384K, |
| 713 | ~((1 << V4L2_MPEG_AUDIO_L2_BITRATE_256K) | |
| 714 | (1 << V4L2_MPEG_AUDIO_L2_BITRATE_384K)), |
| 715 | V4L2_MPEG_AUDIO_L2_BITRATE_256K); |
| 716 | |
| 717 | if (h->has_ac3) |
| 718 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 719 | V4L2_CID_MPEG_AUDIO_AC3_BITRATE, |
| 720 | V4L2_MPEG_AUDIO_AC3_BITRATE_384K, |
| 721 | ~((1 << V4L2_MPEG_AUDIO_AC3_BITRATE_256K) | |
| 722 | (1 << V4L2_MPEG_AUDIO_AC3_BITRATE_384K)), |
| 723 | V4L2_MPEG_AUDIO_AC3_BITRATE_256K); |
| 724 | |
| 725 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 726 | V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, |
| 727 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, |
| 728 | ~(1 << V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000), |
| 729 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); |
| 730 | |
| 731 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 732 | V4L2_CID_MPEG_VIDEO_ENCODING, |
| 733 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, |
| 734 | ~(1 << V4L2_MPEG_VIDEO_ENCODING_MPEG_2), |
| 735 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); |
| 736 | |
| 737 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 738 | V4L2_CID_MPEG_VIDEO_ASPECT, |
| 739 | V4L2_MPEG_VIDEO_ASPECT_16x9, 0x01, |
| 740 | V4L2_MPEG_VIDEO_ASPECT_4x3); |
| 741 | |
| 742 | h->video_bitrate_peak = v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 743 | V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, |
| 744 | 1000000, 27000000, 1000, 8000000); |
| 745 | |
| 746 | v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 747 | V4L2_CID_MPEG_STREAM_TYPE, |
| 748 | V4L2_MPEG_STREAM_TYPE_MPEG2_TS, |
| 749 | ~(1 << V4L2_MPEG_STREAM_TYPE_MPEG2_TS), |
| 750 | V4L2_MPEG_STREAM_TYPE_MPEG2_TS); |
| 751 | |
| 752 | h->video_bitrate_mode = v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, |
| 753 | V4L2_CID_MPEG_VIDEO_BITRATE_MODE, |
| 754 | V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 0, |
| 755 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); |
| 756 | h->video_bitrate = v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 757 | V4L2_CID_MPEG_VIDEO_BITRATE, 1000000, 27000000, 1000, 6000000); |
| 758 | v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 759 | V4L2_CID_MPEG_STREAM_PID_PMT, 0, (1 << 14) - 1, 1, 16); |
| 760 | v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 761 | V4L2_CID_MPEG_STREAM_PID_AUDIO, 0, (1 << 14) - 1, 1, 260); |
| 762 | v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 763 | V4L2_CID_MPEG_STREAM_PID_VIDEO, 0, (1 << 14) - 1, 1, 256); |
| 764 | v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, |
| 765 | V4L2_CID_MPEG_STREAM_PID_PCR, 0, (1 << 14) - 1, 1, 259); |
| 766 | sd->ctrl_handler = hdl; |
| 767 | if (hdl->error) { |
| 768 | int err = hdl->error; |
| 769 | |
| 770 | v4l2_ctrl_handler_free(hdl); |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 771 | return err; |
| 772 | } |
| 773 | v4l2_ctrl_cluster(3, &h->video_bitrate_mode); |
| 774 | v4l2_ctrl_handler_setup(hdl); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 775 | h->standard = 0; /* Assume 625 input lines */ |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 776 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | } |
| 778 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 779 | static int saa6752hs_remove(struct i2c_client *client) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | { |
Hans Verkuil | 5b73e98 | 2009-01-14 06:54:38 -0300 | [diff] [blame] | 781 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
| 782 | |
| 783 | v4l2_device_unregister_subdev(sd); |
Hans Verkuil | bb732cc | 2013-06-10 04:51:42 -0300 | [diff] [blame] | 784 | v4l2_ctrl_handler_free(&to_state(sd)->hdl); |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 785 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | } |
| 787 | |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 788 | static const struct i2c_device_id saa6752hs_id[] = { |
| 789 | { "saa6752hs", 0 }, |
| 790 | { } |
| 791 | }; |
| 792 | MODULE_DEVICE_TABLE(i2c, saa6752hs_id); |
| 793 | |
Hans Verkuil | 099bd5e | 2010-09-15 15:14:36 -0300 | [diff] [blame] | 794 | static struct i2c_driver saa6752hs_driver = { |
| 795 | .driver = { |
Hans Verkuil | 099bd5e | 2010-09-15 15:14:36 -0300 | [diff] [blame] | 796 | .name = "saa6752hs", |
| 797 | }, |
| 798 | .probe = saa6752hs_probe, |
| 799 | .remove = saa6752hs_remove, |
| 800 | .id_table = saa6752hs_id, |
Hans Verkuil | e281db58 | 2008-08-08 12:43:59 -0300 | [diff] [blame] | 801 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | |
Axel Lin | c6e8d86 | 2012-02-12 06:56:32 -0300 | [diff] [blame] | 803 | module_i2c_driver(saa6752hs_driver); |