[ltp] Re: tp_smapi 0.34 and hdaps
linux-thinkpad@linux-thinkpad.org
linux-thinkpad@linux-thinkpad.org
Sun, 20 Jan 2008 14:35:37 +0100
--Boundary-00=_p40kHNMxXp9MnSk
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
> On Jan 19, 2008 7:26 PM, Yves-Alexis Perez <corsac@debian.org> wrote:
> > Jan 20 01:19:49 hidalgo kernel: bad hdaps_check_ec reply
> > 0x01,0x00,0x00,0x00
>
> Same as kionez's. Good, I think I'll just whitelist these values.
maybe its better to make the accepted values dependent on the thinkpad model,
because Lenovo might want to change these values again and we would need to
whitelist all of these values. I tried to patch tp_smapi-0.33 myself, here
you can see the result (please dont bash me ;), its my first patch to
anything kernel-related and I dont know anything about the
kernel-coding-guidelines):
--Boundary-00=_p40kHNMxXp9MnSk
Content-Type: text/x-diff;
charset="iso-8859-1";
name="tp_smapi-0.33-thinkp_r61_hdaps.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="tp_smapi-0.33-thinkp_r61_hdaps.patch"
--- tp_smapi-0.33/hdaps.c 2008-01-20 09:37:53.000000000 +0100
+++ tp_smapi-0.33/hdaps.c 2008-01-20 14:18:53.000000000 +0100
@@ -109,6 +109,9 @@
static int hdaps_users;
static DEFINE_MUTEX(hdaps_users_mtx);
+/* hdaps ec version */
+static int hdaps_ec_version;
+
/* Some models require an axis transformation to the standard representation */
static void transform_axes(int *x, int *y)
{
@@ -349,8 +352,8 @@
int ret = thinkpad_ec_read_row(&args, &data);
if (ret)
return ret;
- if (data.val[0x1]!=0x00 || data.val[0x2]!=0x60 ||
- data.val[0x3]!=0x00 || data.val[0xF]!=0x00)
+ if ( (hdaps_ec_version==1 && (data.val[0x1]!=0x00 || data.val[0x2]!=0x60 || data.val[0x3]!=0x00 || data.val[0xF]!=0x00)) ||
+ (hdaps_ec_version==2 && (data.val[0x1]!=0x01 || data.val[0x2]!=0x00 || data.val[0x3]!=0x00 || data.val[0xF]!=0x00)) )
return -EIO;
return 0;
}
@@ -748,6 +751,25 @@
/* Module stuff */
+/* hdaps_dmi_match_ec - decide which values will be accepted in hdaps_check_ec. */
+static int __init hdaps_dmi_match_ec(const struct dmi_system_id *id)
+{
+ hdaps_ec_version = (int) id->driver_data;
+ printk(KERN_INFO "hdaps: %s detected, this model uses hdaps_ec_version %d\n",
+ id->ident, hdaps_ec_version);
+ return 1;
+}
+
+#define HDAPS_DMI_MATCH_EC(vendor, model, hdaps_ec_version) { \
+ .ident = vendor " " model, \
+ .callback = hdaps_dmi_match_ec, \
+ .driver_data = (void*) (hdaps_ec_version), \
+ .matches = { \
+ DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
+ DMI_MATCH(DMI_PRODUCT_VERSION, model) \
+ } \
+}
+
/* hdaps_dmi_match_invert - found an inverted match. */
static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
{
@@ -777,6 +799,7 @@
HDAPS_DMI_MATCH_INVERT("IBM","ThinkPad R50p", HDAPS_ORIENT_INVERT_XY),
HDAPS_DMI_MATCH_INVERT("IBM","ThinkPad T41p", HDAPS_ORIENT_INVERT_XY),
HDAPS_DMI_MATCH_INVERT("IBM","ThinkPad T42p", HDAPS_ORIENT_INVERT_XY),
+
HDAPS_DMI_MATCH_INVERT("LENOVO","ThinkPad T60", HDAPS_ORIENT_SWAP | HDAPS_ORIENT_INVERT_Y),
HDAPS_DMI_MATCH_INVERT("LENOVO","ThinkPad T61", HDAPS_ORIENT_SWAP),
HDAPS_DMI_MATCH_INVERT("LENOVO","ThinkPad X40", HDAPS_ORIENT_INVERT_Y),
@@ -786,7 +809,35 @@
{ .ident = NULL }
};
+ struct dmi_system_id hdaps_ec_list[] = {
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad R50", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad R50p", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad R51", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad R52", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T41", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T41p", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T42", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T42p", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T43", 1),
+ HDAPS_DMI_MATCH_EC("IBM","ThinkPad T43p", 1),
+
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad R60", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad R61", 2),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad T60", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad T61", 2),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad X40", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad X41", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad X41t", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad X60", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad X61s", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad Z60m", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad Z60t", 1),
+ HDAPS_DMI_MATCH_EC("LENOVO","ThinkPad Z61m", 1),
+ { .ident = NULL }
+ };
+
dmi_check_system(hdaps_whitelist); /* default to normal axes */
+ dmi_check_system(hdaps_ec_list);
/* Init timer before platform_driver_register, in case of suspend */
init_timer(&hdaps_timer);
--Boundary-00=_p40kHNMxXp9MnSk--