Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
e0749be9
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e0749be9
编写于
10月 14, 2006
作者:
L
Len Brown
浏览文件
操作
浏览文件
下载
差异文件
Pull msi-laptop into test branch
上级
ed3269a3
8c4c731a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
422 addition
and
0 deletion
+422
-0
MAINTAINERS
MAINTAINERS
+7
-0
drivers/misc/Kconfig
drivers/misc/Kconfig
+19
-0
drivers/misc/Makefile
drivers/misc/Makefile
+1
-0
drivers/misc/msi-laptop.c
drivers/misc/msi-laptop.c
+395
-0
未找到文件。
MAINTAINERS
浏览文件 @
e0749be9
...
...
@@ -1998,6 +1998,13 @@ M: rubini@ipvvis.unipv.it
L: linux-kernel@vger.kernel.org
S: Maintained
MSI LAPTOP SUPPORT
P: Lennart Poettering
M: mzxreary@0pointer.de
L: https://tango.0pointer.de/mailman/listinfo/s270-linux
W: http://0pointer.de/lennart/tchibo.html
S: Maintained
MTRR AND SIMILAR SUPPORT [i386]
P: Richard Gooch
M: rgooch@atnf.csiro.au
...
...
drivers/misc/Kconfig
浏览文件 @
e0749be9
...
...
@@ -57,4 +57,23 @@ config TIFM_7XX1
To compile this driver as a module, choose M here: the module will
be called tifm_7xx1.
config MSI_LAPTOP
tristate "MSI Laptop Extras"
depends on X86
depends on ACPI_EC
depends on BACKLIGHT_CLASS_DEVICE
---help---
This is a driver for laptops built by MSI (MICRO-STAR
INTERNATIONAL):
MSI MegaBook S270 (MS-1013)
Cytron/TCM/Medion/Tchibo MD96100/SAM2000
It adds support for Bluetooth, WLAN and LCD brightness control.
More information about this driver is available at
<http://0pointer.de/lennart/tchibo.html>.
If you have an MSI S270 laptop, say Y or M here.
endmenu
drivers/misc/Makefile
浏览文件 @
e0749be9
...
...
@@ -5,6 +5,7 @@ obj- := misc.o # Dummy rule to force built-in.o to be made
obj-$(CONFIG_IBM_ASM)
+=
ibmasm/
obj-$(CONFIG_HDPU_FEATURES)
+=
hdpuftrs/
obj-$(CONFIG_MSI_LAPTOP)
+=
msi-laptop.o
obj-$(CONFIG_LKDTM)
+=
lkdtm.o
obj-$(CONFIG_TIFM_CORE)
+=
tifm_core.o
obj-$(CONFIG_TIFM_7XX1)
+=
tifm_7xx1.o
drivers/misc/msi-laptop.c
0 → 100644
浏览文件 @
e0749be9
/*-*-linux-c-*-*/
/*
Copyright (C) 2006 Lennart Poettering <mzxreary (at) 0pointer (dot) de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
/*
* msi-laptop.c - MSI S270 laptop support. This laptop is sold under
* various brands, including "Cytron/TCM/Medion/Tchibo MD96100".
*
* This driver exports a few files in /sys/devices/platform/msi-laptop-pf/:
*
* lcd_level - Screen brightness: contains a single integer in the
* range 0..8. (rw)
*
* auto_brightness - Enable automatic brightness control: contains
* either 0 or 1. If set to 1 the hardware adjusts the screen
* brightness automatically when the power cord is
* plugged/unplugged. (rw)
*
* wlan - WLAN subsystem enabled: contains either 0 or 1. (ro)
*
* bluetooth - Bluetooth subsystem enabled: contains either 0 or 1
* Please note that this file is constantly 0 if no Bluetooth
* hardware is available. (ro)
*
* In addition to these platform device attributes the driver
* registers itself in the Linux backlight control subsystem and is
* available to userspace under /sys/class/backlight/msi-laptop-bl/.
*
* This driver might work on other laptops produced by MSI. If you
* want to try it you can pass force=1 as argument to the module which
* will force it to load even when the DMI data doesn't identify the
* laptop as MSI S270. YMMV.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/backlight.h>
#include <linux/platform_device.h>
#include <linux/autoconf.h>
#define MSI_DRIVER_VERSION "0.5"
#define MSI_LCD_LEVEL_MAX 9
#define MSI_EC_COMMAND_WIRELESS 0x10
#define MSI_EC_COMMAND_LCD_LEVEL 0x11
static
int
force
;
module_param
(
force
,
bool
,
0
);
MODULE_PARM_DESC
(
force
,
"Force driver load, ignore DMI data"
);
static
int
auto_brightness
;
module_param
(
auto_brightness
,
int
,
0
);
MODULE_PARM_DESC
(
auto_brightness
,
"Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)"
);
/* Hardware access */
static
int
set_lcd_level
(
int
level
)
{
u8
buf
[
2
];
if
(
level
<
0
||
level
>=
MSI_LCD_LEVEL_MAX
)
return
-
EINVAL
;
buf
[
0
]
=
0x80
;
buf
[
1
]
=
(
u8
)
(
level
*
31
);
return
ec_transaction
(
MSI_EC_COMMAND_LCD_LEVEL
,
buf
,
sizeof
(
buf
),
NULL
,
0
);
}
static
int
get_lcd_level
(
void
)
{
u8
wdata
=
0
,
rdata
;
int
result
;
result
=
ec_transaction
(
MSI_EC_COMMAND_LCD_LEVEL
,
&
wdata
,
1
,
&
rdata
,
1
);
if
(
result
<
0
)
return
result
;
return
(
int
)
rdata
/
31
;
}
static
int
get_auto_brightness
(
void
)
{
u8
wdata
=
4
,
rdata
;
int
result
;
result
=
ec_transaction
(
MSI_EC_COMMAND_LCD_LEVEL
,
&
wdata
,
1
,
&
rdata
,
1
);
if
(
result
<
0
)
return
result
;
return
!!
(
rdata
&
8
);
}
static
int
set_auto_brightness
(
int
enable
)
{
u8
wdata
[
2
],
rdata
;
int
result
;
wdata
[
0
]
=
4
;
result
=
ec_transaction
(
MSI_EC_COMMAND_LCD_LEVEL
,
wdata
,
1
,
&
rdata
,
1
);
if
(
result
<
0
)
return
result
;
wdata
[
0
]
=
0x84
;
wdata
[
1
]
=
(
rdata
&
0xF7
)
|
(
enable
?
8
:
0
);
return
ec_transaction
(
MSI_EC_COMMAND_LCD_LEVEL
,
wdata
,
2
,
NULL
,
0
);
}
static
int
get_wireless_state
(
int
*
wlan
,
int
*
bluetooth
)
{
u8
wdata
=
0
,
rdata
;
int
result
;
result
=
ec_transaction
(
MSI_EC_COMMAND_WIRELESS
,
&
wdata
,
1
,
&
rdata
,
1
);
if
(
result
<
0
)
return
-
1
;
if
(
wlan
)
*
wlan
=
!!
(
rdata
&
8
);
if
(
bluetooth
)
*
bluetooth
=
!!
(
rdata
&
128
);
return
0
;
}
/* Backlight device stuff */
static
int
bl_get_brightness
(
struct
backlight_device
*
b
)
{
return
get_lcd_level
();
}
static
int
bl_update_status
(
struct
backlight_device
*
b
)
{
return
set_lcd_level
(
b
->
props
->
brightness
);
}
static
struct
backlight_properties
msibl_props
=
{
.
owner
=
THIS_MODULE
,
.
get_brightness
=
bl_get_brightness
,
.
update_status
=
bl_update_status
,
.
max_brightness
=
MSI_LCD_LEVEL_MAX
-
1
,
};
static
struct
backlight_device
*
msibl_device
;
/* Platform device */
static
ssize_t
show_wlan
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
int
ret
,
enabled
;
ret
=
get_wireless_state
(
&
enabled
,
NULL
);
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%i
\n
"
,
enabled
);
}
static
ssize_t
show_bluetooth
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
int
ret
,
enabled
;
ret
=
get_wireless_state
(
NULL
,
&
enabled
);
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%i
\n
"
,
enabled
);
}
static
ssize_t
show_lcd_level
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
int
ret
;
ret
=
get_lcd_level
();
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%i
\n
"
,
ret
);
}
static
ssize_t
store_lcd_level
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
int
level
,
ret
;
if
(
sscanf
(
buf
,
"%i"
,
&
level
)
!=
1
||
(
level
<
0
||
level
>=
MSI_LCD_LEVEL_MAX
))
return
-
EINVAL
;
ret
=
set_lcd_level
(
level
);
if
(
ret
<
0
)
return
ret
;
return
count
;
}
static
ssize_t
show_auto_brightness
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
int
ret
;
ret
=
get_auto_brightness
();
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%i
\n
"
,
ret
);
}
static
ssize_t
store_auto_brightness
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
int
enable
,
ret
;
if
(
sscanf
(
buf
,
"%i"
,
&
enable
)
!=
1
||
(
enable
!=
(
enable
&
1
)))
return
-
EINVAL
;
ret
=
set_auto_brightness
(
enable
);
if
(
ret
<
0
)
return
ret
;
return
count
;
}
static
DEVICE_ATTR
(
lcd_level
,
0644
,
show_lcd_level
,
store_lcd_level
);
static
DEVICE_ATTR
(
auto_brightness
,
0644
,
show_auto_brightness
,
store_auto_brightness
);
static
DEVICE_ATTR
(
bluetooth
,
0444
,
show_bluetooth
,
NULL
);
static
DEVICE_ATTR
(
wlan
,
0444
,
show_wlan
,
NULL
);
static
struct
attribute
*
msipf_attributes
[]
=
{
&
dev_attr_lcd_level
.
attr
,
&
dev_attr_auto_brightness
.
attr
,
&
dev_attr_bluetooth
.
attr
,
&
dev_attr_wlan
.
attr
,
NULL
};
static
struct
attribute_group
msipf_attribute_group
=
{
.
attrs
=
msipf_attributes
};
static
struct
platform_driver
msipf_driver
=
{
.
driver
=
{
.
name
=
"msi-laptop-pf"
,
.
owner
=
THIS_MODULE
,
}
};
static
struct
platform_device
*
msipf_device
;
/* Initialization */
static
struct
dmi_system_id
__initdata
msi_dmi_table
[]
=
{
{
.
ident
=
"MSI S270"
,
.
matches
=
{
DMI_MATCH
(
DMI_SYS_VENDOR
,
"MICRO-STAR INT'L CO.,LTD"
),
DMI_MATCH
(
DMI_PRODUCT_NAME
,
"MS-1013"
),
}
},
{
.
ident
=
"Medion MD96100"
,
.
matches
=
{
DMI_MATCH
(
DMI_SYS_VENDOR
,
"NOTEBOOK"
),
DMI_MATCH
(
DMI_PRODUCT_NAME
,
"SAM2000"
),
}
},
{
}
};
static
int
__init
msi_init
(
void
)
{
int
ret
;
if
(
acpi_disabled
)
return
-
ENODEV
;
if
(
!
force
&&
!
dmi_check_system
(
msi_dmi_table
))
return
-
ENODEV
;
if
(
auto_brightness
<
0
||
auto_brightness
>
2
)
return
-
EINVAL
;
/* Register backlight stuff */
msibl_device
=
backlight_device_register
(
"msi-laptop-bl"
,
NULL
,
&
msibl_props
);
if
(
IS_ERR
(
msibl_device
))
return
PTR_ERR
(
msibl_device
);
ret
=
platform_driver_register
(
&
msipf_driver
);
if
(
ret
)
goto
fail_backlight
;
/* Register platform stuff */
msipf_device
=
platform_device_alloc
(
"msi-laptop-pf"
,
-
1
);
if
(
!
msipf_device
)
{
ret
=
-
ENOMEM
;
goto
fail_platform_driver
;
}
ret
=
platform_device_add
(
msipf_device
);
if
(
ret
)
goto
fail_platform_device1
;
ret
=
sysfs_create_group
(
&
msipf_device
->
dev
.
kobj
,
&
msipf_attribute_group
);
if
(
ret
)
goto
fail_platform_device2
;
/* Disable automatic brightness control by default because
* this module was probably loaded to do brightness control in
* software. */
if
(
auto_brightness
!=
2
)
set_auto_brightness
(
auto_brightness
);
printk
(
KERN_INFO
"msi-laptop: driver "
MSI_DRIVER_VERSION
" successfully loaded.
\n
"
);
return
0
;
fail_platform_device2:
platform_device_del
(
msipf_device
);
fail_platform_device1:
platform_device_put
(
msipf_device
);
fail_platform_driver:
platform_driver_unregister
(
&
msipf_driver
);
fail_backlight:
backlight_device_unregister
(
msibl_device
);
return
ret
;
}
static
void
__exit
msi_cleanup
(
void
)
{
sysfs_remove_group
(
&
msipf_device
->
dev
.
kobj
,
&
msipf_attribute_group
);
platform_device_unregister
(
msipf_device
);
platform_driver_unregister
(
&
msipf_driver
);
backlight_device_unregister
(
msibl_device
);
/* Enable automatic brightness control again */
if
(
auto_brightness
!=
2
)
set_auto_brightness
(
1
);
printk
(
KERN_INFO
"msi-laptop: driver unloaded.
\n
"
);
}
module_init
(
msi_init
);
module_exit
(
msi_cleanup
);
MODULE_AUTHOR
(
"Lennart Poettering"
);
MODULE_DESCRIPTION
(
"MSI Laptop Support"
);
MODULE_VERSION
(
MSI_DRIVER_VERSION
);
MODULE_LICENSE
(
"GPL"
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录