diff options
author | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
commit | bac30d1a78d0f11c613968fc8b351a91ed465386 (patch) | |
tree | e52f3c876522a2f6047a6ec1c27df2e8a79486b8 /drivers/video/matrox | |
parent | e8222502ee6157e2713da9e0792c21f4ad458d50 (diff) | |
parent | ca9ba4471c1203bb6e759b76e83167fec54fe590 (diff) |
Merge ../linux-2.6
Diffstat (limited to 'drivers/video/matrox')
-rw-r--r-- | drivers/video/matrox/matroxfb_g450.c | 2 | ||||
-rw-r--r-- | drivers/video/matrox/matroxfb_maven.c | 78 |
2 files changed, 34 insertions, 46 deletions
diff --git a/drivers/video/matrox/matroxfb_g450.c b/drivers/video/matrox/matroxfb_g450.c index c122d8743dd2..4d610b405d45 100644 --- a/drivers/video/matrox/matroxfb_g450.c +++ b/drivers/video/matrox/matroxfb_g450.c | |||
@@ -59,7 +59,7 @@ static const struct mctl g450_controls[] = | |||
59 | }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) }, | 59 | }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) }, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #define G450CTRLS (sizeof(g450_controls)/sizeof(g450_controls[0])) | 62 | #define G450CTRLS ARRAY_SIZE(g450_controls) |
63 | 63 | ||
64 | /* Return: positive number: id found | 64 | /* Return: positive number: id found |
65 | -EINVAL: id not found, return failure | 65 | -EINVAL: id not found, return failure |
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 6019710dc298..5d29a26b8cdf 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c | |||
@@ -89,12 +89,12 @@ static const struct mctl maven_controls[] = | |||
89 | }, offsetof(struct matrox_fb_info, altout.tvo_params.hue) }, | 89 | }, offsetof(struct matrox_fb_info, altout.tvo_params.hue) }, |
90 | { { V4L2_CID_GAMMA, V4L2_CTRL_TYPE_INTEGER, | 90 | { { V4L2_CID_GAMMA, V4L2_CTRL_TYPE_INTEGER, |
91 | "gamma", | 91 | "gamma", |
92 | 0, sizeof(maven_gamma)/sizeof(maven_gamma[0])-1, 1, 3, | 92 | 0, ARRAY_SIZE(maven_gamma) - 1, 1, 3, |
93 | 0, | 93 | 0, |
94 | }, offsetof(struct matrox_fb_info, altout.tvo_params.gamma) }, | 94 | }, offsetof(struct matrox_fb_info, altout.tvo_params.gamma) }, |
95 | { { MATROXFB_CID_TESTOUT, V4L2_CTRL_TYPE_BOOLEAN, | 95 | { { MATROXFB_CID_TESTOUT, V4L2_CTRL_TYPE_BOOLEAN, |
96 | "test output", | 96 | "test output", |
97 | 0, 1, 1, 0, | 97 | 0, 1, 1, 0, |
98 | 0, | 98 | 0, |
99 | }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) }, | 99 | }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) }, |
100 | { { MATROXFB_CID_DEFLICKER, V4L2_CTRL_TYPE_INTEGER, | 100 | { { MATROXFB_CID_DEFLICKER, V4L2_CTRL_TYPE_INTEGER, |
@@ -105,7 +105,7 @@ static const struct mctl maven_controls[] = | |||
105 | 105 | ||
106 | }; | 106 | }; |
107 | 107 | ||
108 | #define MAVCTRLS (sizeof(maven_controls)/sizeof(maven_controls[0])) | 108 | #define MAVCTRLS ARRAY_SIZE(maven_controls) |
109 | 109 | ||
110 | /* Return: positive number: id found | 110 | /* Return: positive number: id found |
111 | -EINVAL: id not found, return failure | 111 | -EINVAL: id not found, return failure |
@@ -129,7 +129,7 @@ static int get_ctrl_id(__u32 v4l2_id) { | |||
129 | 129 | ||
130 | struct maven_data { | 130 | struct maven_data { |
131 | struct matrox_fb_info* primary_head; | 131 | struct matrox_fb_info* primary_head; |
132 | struct i2c_client* client; | 132 | struct i2c_client client; |
133 | int version; | 133 | int version; |
134 | }; | 134 | }; |
135 | 135 | ||
@@ -970,7 +970,7 @@ static inline int maven_compute_timming(struct maven_data* md, | |||
970 | 970 | ||
971 | static int maven_program_timming(struct maven_data* md, | 971 | static int maven_program_timming(struct maven_data* md, |
972 | const struct mavenregs* m) { | 972 | const struct mavenregs* m) { |
973 | struct i2c_client* c = md->client; | 973 | struct i2c_client* c = &md->client; |
974 | 974 | ||
975 | if (m->mode == MATROXFB_OUTPUT_MODE_MONITOR) { | 975 | if (m->mode == MATROXFB_OUTPUT_MODE_MONITOR) { |
976 | LR(0x80); | 976 | LR(0x80); |
@@ -1007,7 +1007,7 @@ static int maven_program_timming(struct maven_data* md, | |||
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | static inline int maven_resync(struct maven_data* md) { | 1009 | static inline int maven_resync(struct maven_data* md) { |
1010 | struct i2c_client* c = md->client; | 1010 | struct i2c_client* c = &md->client; |
1011 | maven_set_reg(c, 0x95, 0x20); /* start whole thing */ | 1011 | maven_set_reg(c, 0x95, 0x20); /* start whole thing */ |
1012 | return 0; | 1012 | return 0; |
1013 | } | 1013 | } |
@@ -1065,48 +1065,48 @@ static int maven_set_control (struct maven_data* md, | |||
1065 | maven_compute_bwlevel(md, &blacklevel, &whitelevel); | 1065 | maven_compute_bwlevel(md, &blacklevel, &whitelevel); |
1066 | blacklevel = (blacklevel >> 2) | ((blacklevel & 3) << 8); | 1066 | blacklevel = (blacklevel >> 2) | ((blacklevel & 3) << 8); |
1067 | whitelevel = (whitelevel >> 2) | ((whitelevel & 3) << 8); | 1067 | whitelevel = (whitelevel >> 2) | ((whitelevel & 3) << 8); |
1068 | maven_set_reg_pair(md->client, 0x0e, blacklevel); | 1068 | maven_set_reg_pair(&md->client, 0x0e, blacklevel); |
1069 | maven_set_reg_pair(md->client, 0x1e, whitelevel); | 1069 | maven_set_reg_pair(&md->client, 0x1e, whitelevel); |
1070 | } | 1070 | } |
1071 | break; | 1071 | break; |
1072 | case V4L2_CID_SATURATION: | 1072 | case V4L2_CID_SATURATION: |
1073 | { | 1073 | { |
1074 | maven_set_reg(md->client, 0x20, p->value); | 1074 | maven_set_reg(&md->client, 0x20, p->value); |
1075 | maven_set_reg(md->client, 0x22, p->value); | 1075 | maven_set_reg(&md->client, 0x22, p->value); |
1076 | } | 1076 | } |
1077 | break; | 1077 | break; |
1078 | case V4L2_CID_HUE: | 1078 | case V4L2_CID_HUE: |
1079 | { | 1079 | { |
1080 | maven_set_reg(md->client, 0x25, p->value); | 1080 | maven_set_reg(&md->client, 0x25, p->value); |
1081 | } | 1081 | } |
1082 | break; | 1082 | break; |
1083 | case V4L2_CID_GAMMA: | 1083 | case V4L2_CID_GAMMA: |
1084 | { | 1084 | { |
1085 | const struct maven_gamma* g; | 1085 | const struct maven_gamma* g; |
1086 | g = maven_compute_gamma(md); | 1086 | g = maven_compute_gamma(md); |
1087 | maven_set_reg(md->client, 0x83, g->reg83); | 1087 | maven_set_reg(&md->client, 0x83, g->reg83); |
1088 | maven_set_reg(md->client, 0x84, g->reg84); | 1088 | maven_set_reg(&md->client, 0x84, g->reg84); |
1089 | maven_set_reg(md->client, 0x85, g->reg85); | 1089 | maven_set_reg(&md->client, 0x85, g->reg85); |
1090 | maven_set_reg(md->client, 0x86, g->reg86); | 1090 | maven_set_reg(&md->client, 0x86, g->reg86); |
1091 | maven_set_reg(md->client, 0x87, g->reg87); | 1091 | maven_set_reg(&md->client, 0x87, g->reg87); |
1092 | maven_set_reg(md->client, 0x88, g->reg88); | 1092 | maven_set_reg(&md->client, 0x88, g->reg88); |
1093 | maven_set_reg(md->client, 0x89, g->reg89); | 1093 | maven_set_reg(&md->client, 0x89, g->reg89); |
1094 | maven_set_reg(md->client, 0x8a, g->reg8a); | 1094 | maven_set_reg(&md->client, 0x8a, g->reg8a); |
1095 | maven_set_reg(md->client, 0x8b, g->reg8b); | 1095 | maven_set_reg(&md->client, 0x8b, g->reg8b); |
1096 | } | 1096 | } |
1097 | break; | 1097 | break; |
1098 | case MATROXFB_CID_TESTOUT: | 1098 | case MATROXFB_CID_TESTOUT: |
1099 | { | 1099 | { |
1100 | unsigned char val | 1100 | unsigned char val |
1101 | = maven_get_reg (md->client,0x8d); | 1101 | = maven_get_reg(&md->client,0x8d); |
1102 | if (p->value) val |= 0x10; | 1102 | if (p->value) val |= 0x10; |
1103 | else val &= ~0x10; | 1103 | else val &= ~0x10; |
1104 | maven_set_reg (md->client, 0x8d, val); | 1104 | maven_set_reg(&md->client, 0x8d, val); |
1105 | } | 1105 | } |
1106 | break; | 1106 | break; |
1107 | case MATROXFB_CID_DEFLICKER: | 1107 | case MATROXFB_CID_DEFLICKER: |
1108 | { | 1108 | { |
1109 | maven_set_reg(md->client, 0x93, maven_compute_deflicker(md)); | 1109 | maven_set_reg(&md->client, 0x93, maven_compute_deflicker(md)); |
1110 | } | 1110 | } |
1111 | break; | 1111 | break; |
1112 | } | 1112 | } |
@@ -1185,7 +1185,6 @@ static int maven_init_client(struct i2c_client* clnt) { | |||
1185 | MINFO_FROM(container_of(clnt->adapter, struct i2c_bit_adapter, adapter)->minfo); | 1185 | MINFO_FROM(container_of(clnt->adapter, struct i2c_bit_adapter, adapter)->minfo); |
1186 | 1186 | ||
1187 | md->primary_head = MINFO; | 1187 | md->primary_head = MINFO; |
1188 | md->client = clnt; | ||
1189 | down_write(&ACCESS_FBINFO(altout.lock)); | 1188 | down_write(&ACCESS_FBINFO(altout.lock)); |
1190 | ACCESS_FBINFO(outputs[1]).output = &maven_altout; | 1189 | ACCESS_FBINFO(outputs[1]).output = &maven_altout; |
1191 | ACCESS_FBINFO(outputs[1]).src = ACCESS_FBINFO(outputs[1]).default_src; | 1190 | ACCESS_FBINFO(outputs[1]).src = ACCESS_FBINFO(outputs[1]).default_src; |
@@ -1243,19 +1242,17 @@ static int maven_detect_client(struct i2c_adapter* adapter, int address, int kin | |||
1243 | I2C_FUNC_SMBUS_BYTE_DATA | | 1242 | I2C_FUNC_SMBUS_BYTE_DATA | |
1244 | I2C_FUNC_PROTOCOL_MANGLING)) | 1243 | I2C_FUNC_PROTOCOL_MANGLING)) |
1245 | goto ERROR0; | 1244 | goto ERROR0; |
1246 | if (!(new_client = (struct i2c_client*)kmalloc(sizeof(*new_client) + sizeof(*data), | 1245 | if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { |
1247 | GFP_KERNEL))) { | ||
1248 | err = -ENOMEM; | 1246 | err = -ENOMEM; |
1249 | goto ERROR0; | 1247 | goto ERROR0; |
1250 | } | 1248 | } |
1251 | memset(new_client, 0, sizeof(*new_client) + sizeof(*data)); | 1249 | new_client = &data->client; |
1252 | data = (struct maven_data*)(new_client + 1); | ||
1253 | i2c_set_clientdata(new_client, data); | 1250 | i2c_set_clientdata(new_client, data); |
1254 | new_client->addr = address; | 1251 | new_client->addr = address; |
1255 | new_client->adapter = adapter; | 1252 | new_client->adapter = adapter; |
1256 | new_client->driver = &maven_driver; | 1253 | new_client->driver = &maven_driver; |
1257 | new_client->flags = 0; | 1254 | new_client->flags = 0; |
1258 | strcpy(new_client->name, "maven client"); | 1255 | strlcpy(new_client->name, "maven", I2C_NAME_SIZE); |
1259 | if ((err = i2c_attach_client(new_client))) | 1256 | if ((err = i2c_attach_client(new_client))) |
1260 | goto ERROR3; | 1257 | goto ERROR3; |
1261 | err = maven_init_client(new_client); | 1258 | err = maven_init_client(new_client); |
@@ -1279,12 +1276,10 @@ static int maven_attach_adapter(struct i2c_adapter* adapter) { | |||
1279 | static int maven_detach_client(struct i2c_client* client) { | 1276 | static int maven_detach_client(struct i2c_client* client) { |
1280 | int err; | 1277 | int err; |
1281 | 1278 | ||
1282 | if ((err = i2c_detach_client(client))) { | 1279 | if ((err = i2c_detach_client(client))) |
1283 | printk(KERN_ERR "maven: Cannot deregister client\n"); | ||
1284 | return err; | 1280 | return err; |
1285 | } | ||
1286 | maven_shutdown_client(client); | 1281 | maven_shutdown_client(client); |
1287 | kfree(client); | 1282 | kfree(i2c_get_clientdata(client)); |
1288 | return 0; | 1283 | return 0; |
1289 | } | 1284 | } |
1290 | 1285 | ||
@@ -1297,20 +1292,13 @@ static struct i2c_driver maven_driver={ | |||
1297 | .detach_client = maven_detach_client, | 1292 | .detach_client = maven_detach_client, |
1298 | }; | 1293 | }; |
1299 | 1294 | ||
1300 | /* ************************** */ | 1295 | static int __init matroxfb_maven_init(void) |
1301 | 1296 | { | |
1302 | static int matroxfb_maven_init(void) { | 1297 | return i2c_add_driver(&maven_driver); |
1303 | int err; | ||
1304 | |||
1305 | err = i2c_add_driver(&maven_driver); | ||
1306 | if (err) { | ||
1307 | printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err); | ||
1308 | return err; | ||
1309 | } | ||
1310 | return 0; | ||
1311 | } | 1298 | } |
1312 | 1299 | ||
1313 | static void matroxfb_maven_exit(void) { | 1300 | static void __exit matroxfb_maven_exit(void) |
1301 | { | ||
1314 | i2c_del_driver(&maven_driver); | 1302 | i2c_del_driver(&maven_driver); |
1315 | } | 1303 | } |
1316 | 1304 | ||