diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-08-12 18:08:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-12 19:07:29 -0400 |
commit | 10546355323e4826d13e62f85ac6198385a817a9 (patch) | |
tree | 7e51dcb04003d253cee8718a01f5c36f88d19351 | |
parent | 73b7d92f6106e2f55206b8672e5ccf6206689899 (diff) |
matrox maven: convert to a new-style i2c driver
The legacy i2c model is going away soon, so switch to the new model.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Petr Vandrovec <VANDROVE@vc.cvut.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/video/matrox/i2c-matroxfb.c | 12 | ||||
-rw-r--r-- | drivers/video/matrox/matroxfb_maven.c | 95 | ||||
-rw-r--r-- | include/linux/i2c-id.h | 2 |
3 files changed, 50 insertions, 59 deletions
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index 9478439b73d6..c14e3e2212b3 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c | |||
@@ -107,7 +107,6 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo, | |||
107 | b->mask.data = data; | 107 | b->mask.data = data; |
108 | b->mask.clock = clock; | 108 | b->mask.clock = clock; |
109 | b->adapter.owner = THIS_MODULE; | 109 | b->adapter.owner = THIS_MODULE; |
110 | b->adapter.id = I2C_HW_B_G400; | ||
111 | snprintf(b->adapter.name, sizeof(b->adapter.name), name, | 110 | snprintf(b->adapter.name, sizeof(b->adapter.name), name, |
112 | minfo->fbcon.node); | 111 | minfo->fbcon.node); |
113 | i2c_set_adapdata(&b->adapter, b); | 112 | i2c_set_adapdata(&b->adapter, b); |
@@ -182,6 +181,17 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) { | |||
182 | MAT_DATA, MAT_CLK, "MAVEN:fb%u", 0); | 181 | MAT_DATA, MAT_CLK, "MAVEN:fb%u", 0); |
183 | if (err) | 182 | if (err) |
184 | printk(KERN_INFO "i2c-matroxfb: Could not register Maven i2c bus. Continuing anyway.\n"); | 183 | printk(KERN_INFO "i2c-matroxfb: Could not register Maven i2c bus. Continuing anyway.\n"); |
184 | else { | ||
185 | struct i2c_board_info maven_info = { | ||
186 | I2C_BOARD_INFO("maven", 0x1b), | ||
187 | }; | ||
188 | unsigned short const addr_list[2] = { | ||
189 | 0x1b, I2C_CLIENT_END | ||
190 | }; | ||
191 | |||
192 | i2c_new_probed_device(&m2info->maven.adapter, | ||
193 | &maven_info, addr_list); | ||
194 | } | ||
185 | } | 195 | } |
186 | return m2info; | 196 | return m2info; |
187 | fail_ddc1:; | 197 | fail_ddc1:; |
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 2ad06b0125c3..042408a8c631 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include <linux/matroxfb.h> | 19 | #include <linux/matroxfb.h> |
20 | #include <asm/div64.h> | 20 | #include <asm/div64.h> |
21 | 21 | ||
22 | #define MAVEN_I2CID (0x1B) | ||
23 | |||
24 | #define MGATVO_B 1 | 22 | #define MGATVO_B 1 |
25 | #define MGATVO_C 2 | 23 | #define MGATVO_C 2 |
26 | 24 | ||
@@ -128,7 +126,7 @@ static int get_ctrl_id(__u32 v4l2_id) { | |||
128 | 126 | ||
129 | struct maven_data { | 127 | struct maven_data { |
130 | struct matrox_fb_info* primary_head; | 128 | struct matrox_fb_info* primary_head; |
131 | struct i2c_client client; | 129 | struct i2c_client *client; |
132 | int version; | 130 | int version; |
133 | }; | 131 | }; |
134 | 132 | ||
@@ -974,7 +972,7 @@ static inline int maven_compute_timming(struct maven_data* md, | |||
974 | 972 | ||
975 | static int maven_program_timming(struct maven_data* md, | 973 | static int maven_program_timming(struct maven_data* md, |
976 | const struct mavenregs* m) { | 974 | const struct mavenregs* m) { |
977 | struct i2c_client* c = &md->client; | 975 | struct i2c_client *c = md->client; |
978 | 976 | ||
979 | if (m->mode == MATROXFB_OUTPUT_MODE_MONITOR) { | 977 | if (m->mode == MATROXFB_OUTPUT_MODE_MONITOR) { |
980 | LR(0x80); | 978 | LR(0x80); |
@@ -1011,7 +1009,7 @@ static int maven_program_timming(struct maven_data* md, | |||
1011 | } | 1009 | } |
1012 | 1010 | ||
1013 | static inline int maven_resync(struct maven_data* md) { | 1011 | static inline int maven_resync(struct maven_data* md) { |
1014 | struct i2c_client* c = &md->client; | 1012 | struct i2c_client *c = md->client; |
1015 | maven_set_reg(c, 0x95, 0x20); /* start whole thing */ | 1013 | maven_set_reg(c, 0x95, 0x20); /* start whole thing */ |
1016 | return 0; | 1014 | return 0; |
1017 | } | 1015 | } |
@@ -1069,48 +1067,48 @@ static int maven_set_control (struct maven_data* md, | |||
1069 | maven_compute_bwlevel(md, &blacklevel, &whitelevel); | 1067 | maven_compute_bwlevel(md, &blacklevel, &whitelevel); |
1070 | blacklevel = (blacklevel >> 2) | ((blacklevel & 3) << 8); | 1068 | blacklevel = (blacklevel >> 2) | ((blacklevel & 3) << 8); |
1071 | whitelevel = (whitelevel >> 2) | ((whitelevel & 3) << 8); | 1069 | whitelevel = (whitelevel >> 2) | ((whitelevel & 3) << 8); |
1072 | maven_set_reg_pair(&md->client, 0x0e, blacklevel); | 1070 | maven_set_reg_pair(md->client, 0x0e, blacklevel); |
1073 | maven_set_reg_pair(&md->client, 0x1e, whitelevel); | 1071 | maven_set_reg_pair(md->client, 0x1e, whitelevel); |
1074 | } | 1072 | } |
1075 | break; | 1073 | break; |
1076 | case V4L2_CID_SATURATION: | 1074 | case V4L2_CID_SATURATION: |
1077 | { | 1075 | { |
1078 | maven_set_reg(&md->client, 0x20, p->value); | 1076 | maven_set_reg(md->client, 0x20, p->value); |
1079 | maven_set_reg(&md->client, 0x22, p->value); | 1077 | maven_set_reg(md->client, 0x22, p->value); |
1080 | } | 1078 | } |
1081 | break; | 1079 | break; |
1082 | case V4L2_CID_HUE: | 1080 | case V4L2_CID_HUE: |
1083 | { | 1081 | { |
1084 | maven_set_reg(&md->client, 0x25, p->value); | 1082 | maven_set_reg(md->client, 0x25, p->value); |
1085 | } | 1083 | } |
1086 | break; | 1084 | break; |
1087 | case V4L2_CID_GAMMA: | 1085 | case V4L2_CID_GAMMA: |
1088 | { | 1086 | { |
1089 | const struct maven_gamma* g; | 1087 | const struct maven_gamma* g; |
1090 | g = maven_compute_gamma(md); | 1088 | g = maven_compute_gamma(md); |
1091 | maven_set_reg(&md->client, 0x83, g->reg83); | 1089 | maven_set_reg(md->client, 0x83, g->reg83); |
1092 | maven_set_reg(&md->client, 0x84, g->reg84); | 1090 | maven_set_reg(md->client, 0x84, g->reg84); |
1093 | maven_set_reg(&md->client, 0x85, g->reg85); | 1091 | maven_set_reg(md->client, 0x85, g->reg85); |
1094 | maven_set_reg(&md->client, 0x86, g->reg86); | 1092 | maven_set_reg(md->client, 0x86, g->reg86); |
1095 | maven_set_reg(&md->client, 0x87, g->reg87); | 1093 | maven_set_reg(md->client, 0x87, g->reg87); |
1096 | maven_set_reg(&md->client, 0x88, g->reg88); | 1094 | maven_set_reg(md->client, 0x88, g->reg88); |
1097 | maven_set_reg(&md->client, 0x89, g->reg89); | 1095 | maven_set_reg(md->client, 0x89, g->reg89); |
1098 | maven_set_reg(&md->client, 0x8a, g->reg8a); | 1096 | maven_set_reg(md->client, 0x8a, g->reg8a); |
1099 | maven_set_reg(&md->client, 0x8b, g->reg8b); | 1097 | maven_set_reg(md->client, 0x8b, g->reg8b); |
1100 | } | 1098 | } |
1101 | break; | 1099 | break; |
1102 | case MATROXFB_CID_TESTOUT: | 1100 | case MATROXFB_CID_TESTOUT: |
1103 | { | 1101 | { |
1104 | unsigned char val | 1102 | unsigned char val |
1105 | = maven_get_reg(&md->client,0x8d); | 1103 | = maven_get_reg(md->client, 0x8d); |
1106 | if (p->value) val |= 0x10; | 1104 | if (p->value) val |= 0x10; |
1107 | else val &= ~0x10; | 1105 | else val &= ~0x10; |
1108 | maven_set_reg(&md->client, 0x8d, val); | 1106 | maven_set_reg(md->client, 0x8d, val); |
1109 | } | 1107 | } |
1110 | break; | 1108 | break; |
1111 | case MATROXFB_CID_DEFLICKER: | 1109 | case MATROXFB_CID_DEFLICKER: |
1112 | { | 1110 | { |
1113 | maven_set_reg(&md->client, 0x93, maven_compute_deflicker(md)); | 1111 | maven_set_reg(md->client, 0x93, maven_compute_deflicker(md)); |
1114 | } | 1112 | } |
1115 | break; | 1113 | break; |
1116 | } | 1114 | } |
@@ -1189,6 +1187,7 @@ static int maven_init_client(struct i2c_client* clnt) { | |||
1189 | MINFO_FROM(container_of(clnt->adapter, struct i2c_bit_adapter, adapter)->minfo); | 1187 | MINFO_FROM(container_of(clnt->adapter, struct i2c_bit_adapter, adapter)->minfo); |
1190 | 1188 | ||
1191 | md->primary_head = MINFO; | 1189 | md->primary_head = MINFO; |
1190 | md->client = clnt; | ||
1192 | down_write(&ACCESS_FBINFO(altout.lock)); | 1191 | down_write(&ACCESS_FBINFO(altout.lock)); |
1193 | ACCESS_FBINFO(outputs[1]).output = &maven_altout; | 1192 | ACCESS_FBINFO(outputs[1]).output = &maven_altout; |
1194 | ACCESS_FBINFO(outputs[1]).src = ACCESS_FBINFO(outputs[1]).default_src; | 1193 | ACCESS_FBINFO(outputs[1]).src = ACCESS_FBINFO(outputs[1]).default_src; |
@@ -1232,14 +1231,11 @@ static int maven_shutdown_client(struct i2c_client* clnt) { | |||
1232 | return 0; | 1231 | return 0; |
1233 | } | 1232 | } |
1234 | 1233 | ||
1235 | static const unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; | 1234 | static int maven_probe(struct i2c_client *client, |
1236 | I2C_CLIENT_INSMOD; | 1235 | const struct i2c_device_id *id) |
1237 | 1236 | { | |
1238 | static struct i2c_driver maven_driver; | 1237 | struct i2c_adapter *adapter = client->adapter; |
1239 | 1238 | int err = -ENODEV; | |
1240 | static int maven_detect_client(struct i2c_adapter* adapter, int address, int kind) { | ||
1241 | int err = 0; | ||
1242 | struct i2c_client* new_client; | ||
1243 | struct maven_data* data; | 1239 | struct maven_data* data; |
1244 | 1240 | ||
1245 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA | | 1241 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA | |
@@ -1250,50 +1246,37 @@ static int maven_detect_client(struct i2c_adapter* adapter, int address, int kin | |||
1250 | err = -ENOMEM; | 1246 | err = -ENOMEM; |
1251 | goto ERROR0; | 1247 | goto ERROR0; |
1252 | } | 1248 | } |
1253 | new_client = &data->client; | 1249 | i2c_set_clientdata(client, data); |
1254 | i2c_set_clientdata(new_client, data); | 1250 | err = maven_init_client(client); |
1255 | new_client->addr = address; | ||
1256 | new_client->adapter = adapter; | ||
1257 | new_client->driver = &maven_driver; | ||
1258 | new_client->flags = 0; | ||
1259 | strlcpy(new_client->name, "maven", I2C_NAME_SIZE); | ||
1260 | if ((err = i2c_attach_client(new_client))) | ||
1261 | goto ERROR3; | ||
1262 | err = maven_init_client(new_client); | ||
1263 | if (err) | 1251 | if (err) |
1264 | goto ERROR4; | 1252 | goto ERROR4; |
1265 | return 0; | 1253 | return 0; |
1266 | ERROR4:; | 1254 | ERROR4:; |
1267 | i2c_detach_client(new_client); | ||
1268 | ERROR3:; | ||
1269 | kfree(data); | 1255 | kfree(data); |
1270 | ERROR0:; | 1256 | ERROR0:; |
1271 | return err; | 1257 | return err; |
1272 | } | 1258 | } |
1273 | 1259 | ||
1274 | static int maven_attach_adapter(struct i2c_adapter* adapter) { | 1260 | static int maven_remove(struct i2c_client *client) |
1275 | if (adapter->id == I2C_HW_B_G400) | 1261 | { |
1276 | return i2c_probe(adapter, &addr_data, &maven_detect_client); | ||
1277 | return 0; | ||
1278 | } | ||
1279 | |||
1280 | static int maven_detach_client(struct i2c_client* client) { | ||
1281 | int err; | ||
1282 | |||
1283 | if ((err = i2c_detach_client(client))) | ||
1284 | return err; | ||
1285 | maven_shutdown_client(client); | 1262 | maven_shutdown_client(client); |
1286 | kfree(i2c_get_clientdata(client)); | 1263 | kfree(i2c_get_clientdata(client)); |
1287 | return 0; | 1264 | return 0; |
1288 | } | 1265 | } |
1289 | 1266 | ||
1267 | static const struct i2c_device_id maven_id[] = { | ||
1268 | { "maven", 0 }, | ||
1269 | { } | ||
1270 | }; | ||
1271 | MODULE_DEVICE_TABLE(i2c, maven_id); | ||
1272 | |||
1290 | static struct i2c_driver maven_driver={ | 1273 | static struct i2c_driver maven_driver={ |
1291 | .driver = { | 1274 | .driver = { |
1292 | .name = "maven", | 1275 | .name = "maven", |
1293 | }, | 1276 | }, |
1294 | .id = I2C_DRIVERID_MGATVO, | 1277 | .probe = maven_probe, |
1295 | .attach_adapter = maven_attach_adapter, | 1278 | .remove = maven_remove, |
1296 | .detach_client = maven_detach_client, | 1279 | .id_table = maven_id, |
1297 | }; | 1280 | }; |
1298 | 1281 | ||
1299 | static int __init matroxfb_maven_init(void) | 1282 | static int __init matroxfb_maven_init(void) |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 4862398e05bf..bf34c5f4c051 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -39,7 +39,6 @@ | |||
39 | #define I2C_DRIVERID_SAA7111A 8 /* video input processor */ | 39 | #define I2C_DRIVERID_SAA7111A 8 /* video input processor */ |
40 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ | 40 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ |
41 | #define I2C_DRIVERID_SAA7110 22 /* video decoder */ | 41 | #define I2C_DRIVERID_SAA7110 22 /* video decoder */ |
42 | #define I2C_DRIVERID_MGATVO 23 /* Matrox TVOut */ | ||
43 | #define I2C_DRIVERID_SAA5249 24 /* SAA5249 and compatibles */ | 42 | #define I2C_DRIVERID_SAA5249 24 /* SAA5249 and compatibles */ |
44 | #define I2C_DRIVERID_PCF8583 25 /* real time clock */ | 43 | #define I2C_DRIVERID_PCF8583 25 /* real time clock */ |
45 | #define I2C_DRIVERID_SAB3036 26 /* SAB3036 tuner */ | 44 | #define I2C_DRIVERID_SAB3036 26 /* SAB3036 tuner */ |
@@ -95,7 +94,6 @@ | |||
95 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ | 94 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ |
96 | #define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ | 95 | #define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ |
97 | #define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */ | 96 | #define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */ |
98 | #define I2C_HW_B_G400 0x010009 /* Matrox G400 */ | ||
99 | #define I2C_HW_B_I810 0x01000a /* Intel I810 */ | 97 | #define I2C_HW_B_I810 0x01000a /* Intel I810 */ |
100 | #define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */ | 98 | #define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */ |
101 | #define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */ | 99 | #define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */ |