diff options
Diffstat (limited to 'drivers/misc/sony-laptop.c')
-rw-r--r-- | drivers/misc/sony-laptop.c | 108 |
1 files changed, 90 insertions, 18 deletions
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index 2787e1ce8911..bc863f5efd5d 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -1220,11 +1220,35 @@ static u8 sony_pic_call3(u8 dev, u8 fn, u8 v) | |||
1220 | 1220 | ||
1221 | /* camera tests and poweron/poweroff */ | 1221 | /* camera tests and poweron/poweroff */ |
1222 | #define SONYPI_CAMERA_PICTURE 5 | 1222 | #define SONYPI_CAMERA_PICTURE 5 |
1223 | #define SONYPI_CAMERA_MUTE_MASK 0x40 | ||
1224 | #define SONYPI_CAMERA_CONTROL 0x10 | 1223 | #define SONYPI_CAMERA_CONTROL 0x10 |
1225 | #define SONYPI_CAMERA_STATUS 7 | 1224 | |
1226 | #define SONYPI_CAMERA_STATUS_READY 0x2 | 1225 | #define SONYPI_CAMERA_BRIGHTNESS 0 |
1227 | #define SONYPI_CAMERA_STATUS_POSITION 0x4 | 1226 | #define SONYPI_CAMERA_CONTRAST 1 |
1227 | #define SONYPI_CAMERA_HUE 2 | ||
1228 | #define SONYPI_CAMERA_COLOR 3 | ||
1229 | #define SONYPI_CAMERA_SHARPNESS 4 | ||
1230 | |||
1231 | #define SONYPI_CAMERA_EXPOSURE_MASK 0xC | ||
1232 | #define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3 | ||
1233 | #define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30 | ||
1234 | #define SONYPI_CAMERA_MUTE_MASK 0x40 | ||
1235 | |||
1236 | /* the rest don't need a loop until not 0xff */ | ||
1237 | #define SONYPI_CAMERA_AGC 6 | ||
1238 | #define SONYPI_CAMERA_AGC_MASK 0x30 | ||
1239 | #define SONYPI_CAMERA_SHUTTER_MASK 0x7 | ||
1240 | |||
1241 | #define SONYPI_CAMERA_SHUTDOWN_REQUEST 7 | ||
1242 | #define SONYPI_CAMERA_CONTROL 0x10 | ||
1243 | |||
1244 | #define SONYPI_CAMERA_STATUS 7 | ||
1245 | #define SONYPI_CAMERA_STATUS_READY 0x2 | ||
1246 | #define SONYPI_CAMERA_STATUS_POSITION 0x4 | ||
1247 | |||
1248 | #define SONYPI_DIRECTION_BACKWARDS 0x4 | ||
1249 | |||
1250 | #define SONYPI_CAMERA_REVISION 8 | ||
1251 | #define SONYPI_CAMERA_ROMVERSION 9 | ||
1228 | 1252 | ||
1229 | static int __sony_pic_camera_ready(void) | 1253 | static int __sony_pic_camera_ready(void) |
1230 | { | 1254 | { |
@@ -1234,14 +1258,13 @@ static int __sony_pic_camera_ready(void) | |||
1234 | return (v != 0xff && (v & SONYPI_CAMERA_STATUS_READY)); | 1258 | return (v != 0xff && (v & SONYPI_CAMERA_STATUS_READY)); |
1235 | } | 1259 | } |
1236 | 1260 | ||
1237 | static int sony_pic_camera_off(void) | 1261 | static int __sony_pic_camera_off(void) |
1238 | { | 1262 | { |
1239 | if (!camera) { | 1263 | if (!camera) { |
1240 | printk(KERN_WARNING DRV_PFX "camera control not enabled\n"); | 1264 | printk(KERN_WARNING DRV_PFX "camera control not enabled\n"); |
1241 | return -ENODEV; | 1265 | return -ENODEV; |
1242 | } | 1266 | } |
1243 | 1267 | ||
1244 | mutex_lock(&spic_dev.lock); | ||
1245 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE, | 1268 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE, |
1246 | SONYPI_CAMERA_MUTE_MASK), | 1269 | SONYPI_CAMERA_MUTE_MASK), |
1247 | ITERATIONS_SHORT); | 1270 | ITERATIONS_SHORT); |
@@ -1250,23 +1273,20 @@ static int sony_pic_camera_off(void) | |||
1250 | sony_pic_call2(0x91, 0); | 1273 | sony_pic_call2(0x91, 0); |
1251 | spic_dev.camera_power = 0; | 1274 | spic_dev.camera_power = 0; |
1252 | } | 1275 | } |
1253 | mutex_unlock(&spic_dev.lock); | ||
1254 | return 0; | 1276 | return 0; |
1255 | } | 1277 | } |
1256 | 1278 | ||
1257 | static int sony_pic_camera_on(void) | 1279 | static int __sony_pic_camera_on(void) |
1258 | { | 1280 | { |
1259 | int i, j, x; | 1281 | int i, j, x; |
1260 | int result = 0; | ||
1261 | 1282 | ||
1262 | if (!camera) { | 1283 | if (!camera) { |
1263 | printk(KERN_WARNING DRV_PFX "camera control not enabled\n"); | 1284 | printk(KERN_WARNING DRV_PFX "camera control not enabled\n"); |
1264 | return -ENODEV; | 1285 | return -ENODEV; |
1265 | } | 1286 | } |
1266 | 1287 | ||
1267 | mutex_lock(&spic_dev.lock); | ||
1268 | if (spic_dev.camera_power) | 1288 | if (spic_dev.camera_power) |
1269 | goto out_unlock; | 1289 | return 0; |
1270 | 1290 | ||
1271 | for (j = 5; j > 0; j--) { | 1291 | for (j = 5; j > 0; j--) { |
1272 | 1292 | ||
@@ -1285,8 +1305,7 @@ static int sony_pic_camera_on(void) | |||
1285 | 1305 | ||
1286 | if (j == 0) { | 1306 | if (j == 0) { |
1287 | printk(KERN_WARNING DRV_PFX "failed to power on camera\n"); | 1307 | printk(KERN_WARNING DRV_PFX "failed to power on camera\n"); |
1288 | result = -ENODEV; | 1308 | return -ENODEV; |
1289 | goto out_unlock; | ||
1290 | } | 1309 | } |
1291 | 1310 | ||
1292 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTROL, | 1311 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTROL, |
@@ -1294,9 +1313,6 @@ static int sony_pic_camera_on(void) | |||
1294 | ITERATIONS_SHORT); | 1313 | ITERATIONS_SHORT); |
1295 | 1314 | ||
1296 | spic_dev.camera_power = 1; | 1315 | spic_dev.camera_power = 1; |
1297 | |||
1298 | out_unlock: | ||
1299 | mutex_unlock(&spic_dev.lock); | ||
1300 | return 0; | 1316 | return 0; |
1301 | } | 1317 | } |
1302 | 1318 | ||
@@ -1310,10 +1326,13 @@ static ssize_t sony_pic_camerapower_store(struct device *dev, | |||
1310 | return -EINVAL; | 1326 | return -EINVAL; |
1311 | 1327 | ||
1312 | value = simple_strtoul(buffer, NULL, 10); | 1328 | value = simple_strtoul(buffer, NULL, 10); |
1329 | |||
1330 | mutex_lock(&spic_dev.lock); | ||
1313 | if (value) | 1331 | if (value) |
1314 | result = sony_pic_camera_on(); | 1332 | result = __sony_pic_camera_on(); |
1315 | else | 1333 | else |
1316 | result = sony_pic_camera_off(); | 1334 | result = __sony_pic_camera_off(); |
1335 | mutex_unlock(&spic_dev.lock); | ||
1317 | 1336 | ||
1318 | if (result) | 1337 | if (result) |
1319 | return result; | 1338 | return result; |
@@ -1331,6 +1350,59 @@ static ssize_t sony_pic_camerapower_show(struct device *dev, | |||
1331 | return count; | 1350 | return count; |
1332 | } | 1351 | } |
1333 | 1352 | ||
1353 | /* External camera command (exported to the motion eye v4l driver) */ | ||
1354 | int sony_pic_camera_command(int command, u8 value) | ||
1355 | { | ||
1356 | if (!camera) | ||
1357 | return -EIO; | ||
1358 | |||
1359 | mutex_lock(&spic_dev.lock); | ||
1360 | |||
1361 | switch (command) { | ||
1362 | case SONYPI_COMMAND_SETCAMERA: | ||
1363 | if (value) | ||
1364 | __sony_pic_camera_on(); | ||
1365 | else | ||
1366 | __sony_pic_camera_off(); | ||
1367 | break; | ||
1368 | case SONYPI_COMMAND_SETCAMERABRIGHTNESS: | ||
1369 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_BRIGHTNESS, value), | ||
1370 | ITERATIONS_SHORT); | ||
1371 | break; | ||
1372 | case SONYPI_COMMAND_SETCAMERACONTRAST: | ||
1373 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTRAST, value), | ||
1374 | ITERATIONS_SHORT); | ||
1375 | break; | ||
1376 | case SONYPI_COMMAND_SETCAMERAHUE: | ||
1377 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_HUE, value), | ||
1378 | ITERATIONS_SHORT); | ||
1379 | break; | ||
1380 | case SONYPI_COMMAND_SETCAMERACOLOR: | ||
1381 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_COLOR, value), | ||
1382 | ITERATIONS_SHORT); | ||
1383 | break; | ||
1384 | case SONYPI_COMMAND_SETCAMERASHARPNESS: | ||
1385 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_SHARPNESS, value), | ||
1386 | ITERATIONS_SHORT); | ||
1387 | break; | ||
1388 | case SONYPI_COMMAND_SETCAMERAPICTURE: | ||
1389 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE, value), | ||
1390 | ITERATIONS_SHORT); | ||
1391 | break; | ||
1392 | case SONYPI_COMMAND_SETCAMERAAGC: | ||
1393 | wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_AGC, value), | ||
1394 | ITERATIONS_SHORT); | ||
1395 | break; | ||
1396 | default: | ||
1397 | printk(KERN_ERR DRV_PFX "sony_pic_camera_command invalid: %d\n", | ||
1398 | command); | ||
1399 | break; | ||
1400 | } | ||
1401 | mutex_unlock(&spic_dev.lock); | ||
1402 | return 0; | ||
1403 | } | ||
1404 | EXPORT_SYMBOL(sony_pic_camera_command); | ||
1405 | |||
1334 | /* gprs/edge modem (SZ460N and SZ210P), thanks to Joshua Wise */ | 1406 | /* gprs/edge modem (SZ460N and SZ210P), thanks to Joshua Wise */ |
1335 | static void sony_pic_set_wwanpower(u8 state) | 1407 | static void sony_pic_set_wwanpower(u8 state) |
1336 | { | 1408 | { |