aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorIke Panhc <ike.pan@canonical.com>2010-10-01 03:39:40 -0400
committerMatthew Garrett <mjg@redhat.com>2010-10-21 09:36:50 -0400
commit26c81d5c9a88af404a5fef43caa259e8637fec94 (patch)
treedce10bc349f2be5d07749650ab962eb91a68b321 /drivers/platform
parentdfa7f6fe0ad7697ba43303bf37487987409b1b91 (diff)
ideapad: use EC command to control camera
Signed-off-by: Ike Panhc <ike.pan@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/ideapad_acpi.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/platform/x86/ideapad_acpi.c b/drivers/platform/x86/ideapad_acpi.c
index 1f736d143022..e45fc50b93dc 100644
--- a/drivers/platform/x86/ideapad_acpi.c
+++ b/drivers/platform/x86/ideapad_acpi.c
@@ -35,6 +35,7 @@
35#define IDEAPAD_DEV_KILLSW 4 35#define IDEAPAD_DEV_KILLSW 4
36 36
37struct ideapad_private { 37struct ideapad_private {
38 acpi_handle handle;
38 struct rfkill *rfk[5]; 39 struct rfkill *rfk[5];
39}; 40};
40 41
@@ -207,24 +208,28 @@ static ssize_t show_ideapad_cam(struct device *dev,
207 struct device_attribute *attr, 208 struct device_attribute *attr,
208 char *buf) 209 char *buf)
209{ 210{
210 int state = ideapad_dev_get_state(IDEAPAD_DEV_CAMERA); 211 struct ideapad_private *priv = dev_get_drvdata(dev);
211 if (state < 0) 212 acpi_handle handle = priv->handle;
212 return state; 213 unsigned long result;
213 214
214 return sprintf(buf, "%d\n", state); 215 if (read_ec_data(handle, 0x1D, &result))
216 return sprintf(buf, "-1\n");
217 return sprintf(buf, "%lu\n", result);
215} 218}
216 219
217static ssize_t store_ideapad_cam(struct device *dev, 220static ssize_t store_ideapad_cam(struct device *dev,
218 struct device_attribute *attr, 221 struct device_attribute *attr,
219 const char *buf, size_t count) 222 const char *buf, size_t count)
220{ 223{
224 struct ideapad_private *priv = dev_get_drvdata(dev);
225 acpi_handle handle = priv->handle;
221 int ret, state; 226 int ret, state;
222 227
223 if (!count) 228 if (!count)
224 return 0; 229 return 0;
225 if (sscanf(buf, "%i", &state) != 1) 230 if (sscanf(buf, "%i", &state) != 1)
226 return -EINVAL; 231 return -EINVAL;
227 ret = ideapad_dev_set_state(IDEAPAD_DEV_CAMERA, !!state); 232 ret = write_ec_cmd(handle, 0x1E, state);
228 if (ret < 0) 233 if (ret < 0)
229 return ret; 234 return ret;
230 return count; 235 return count;
@@ -330,6 +335,7 @@ static int ideapad_acpi_add(struct acpi_device *adevice)
330 } 335 }
331 } 336 }
332 337
338 priv->handle = adevice->handle;
333 dev_set_drvdata(&adevice->dev, priv); 339 dev_set_drvdata(&adevice->dev, priv);
334 for (i = IDEAPAD_DEV_WLAN; i <= IDEAPAD_DEV_KILLSW; i++) { 340 for (i = IDEAPAD_DEV_WLAN; i <= IDEAPAD_DEV_KILLSW; i++) {
335 if (!devs_present[i]) 341 if (!devs_present[i])