Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
f6fc5049
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6fc5049
编写于
11月 29, 2009
作者:
M
Mauro Carvalho Chehab
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
V4L/DVB (13538): ir-common: Use a dynamic keycode table
Signed-off-by:
N
Mauro Carvalho Chehab
<
mchehab@redhat.com
>
上级
055cd556
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
8 deletion
+92
-8
drivers/media/common/ir-functions.c
drivers/media/common/ir-functions.c
+11
-8
drivers/media/common/ir-keytable.c
drivers/media/common/ir-keytable.c
+75
-0
include/media/ir-common.h
include/media/ir-common.h
+6
-0
未找到文件。
drivers/media/common/ir-functions.c
浏览文件 @
f6fc5049
...
...
@@ -59,12 +59,20 @@ int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
{
ir
->
ir_type
=
ir_type
;
/* FIXME: Add the proper code to dynamically allocate IR table */
ir
->
keytable
.
size
=
ir_roundup_tablesize
(
ir_codes
->
size
);
ir
->
keytable
.
scan
=
kzalloc
(
ir
->
keytable
.
size
*
sizeof
(
struct
ir_scancode
),
GFP_KERNEL
);
if
(
!
ir
->
keytable
.
scan
)
return
-
ENOMEM
;
ir_set_keycode_table
(
dev
,
ir_codes
);
IR_dprintk
(
1
,
"Allocated space for %d keycode entries (%zd bytes)
\n
"
,
ir
->
keytable
.
size
,
ir
->
keytable
.
size
*
sizeof
(
ir
->
keytable
.
scan
));
clear_bit
(
0
,
dev
->
keybit
);
ir_copy_table
(
&
ir
->
keytable
,
ir_codes
);
ir_set_keycode_table
(
dev
,
&
ir
->
keytable
);
clear_bit
(
0
,
dev
->
keybit
);
set_bit
(
EV_KEY
,
dev
->
evbit
);
if
(
repeat
)
set_bit
(
EV_REP
,
dev
->
evbit
);
...
...
@@ -73,11 +81,6 @@ int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
}
EXPORT_SYMBOL_GPL
(
ir_input_init
);
void
ir_input_free
(
struct
input_dev
*
input_dev
)
{
/* FIXME: Add the proper code to free allocated resources */
}
EXPORT_SYMBOL_GPL
(
ir_input_free
);
void
ir_input_nokey
(
struct
input_dev
*
dev
,
struct
ir_input_state
*
ir
)
{
...
...
drivers/media/common/ir-keytable.c
浏览文件 @
f6fc5049
...
...
@@ -7,6 +7,68 @@
#include <media/ir-common.h>
#define IR_TAB_MIN_SIZE 32
/**
* ir_roundup_tablesize() - gets an optimum value for the table size
* @n_elems: minimum number of entries to store keycodes
*
* This routine is used to choose the keycode table size.
*
* In order to have some empty space for new keycodes,
* and knowing in advance that kmalloc allocates only power of two
* segments, it optimizes the allocated space to have some spare space
* for those new keycodes by using the maximum number of entries that
* will be effectively be allocated by kmalloc.
* In order to reduce the quantity of table resizes, it has a minimum
* table size of IR_TAB_MIN_SIZE.
*/
int
ir_roundup_tablesize
(
int
n_elems
)
{
size_t
size
;
if
(
n_elems
<
IR_TAB_MIN_SIZE
)
n_elems
=
IR_TAB_MIN_SIZE
;
/*
* As kmalloc only allocates sizes of power of two, get as
* much entries as possible for the allocated memory segment
*/
size
=
roundup_pow_of_two
(
n_elems
*
sizeof
(
struct
ir_scancode
));
n_elems
=
size
/
sizeof
(
struct
ir_scancode
);
return
n_elems
;
}
/**
* ir_copy_table() - copies a keytable, discarding the unused entries
* @destin: destin table
* @origin: origin table
*
* Copies all entries where the keycode is not KEY_UNKNOWN/KEY_RESERVED
*/
int
ir_copy_table
(
struct
ir_scancode_table
*
destin
,
const
struct
ir_scancode_table
*
origin
)
{
int
i
,
j
=
0
;
for
(
i
=
0
;
i
<
origin
->
size
;
i
++
)
{
if
(
origin
->
scan
[
i
].
keycode
!=
KEY_UNKNOWN
&&
origin
->
scan
[
i
].
keycode
!=
KEY_RESERVED
)
{
memcpy
(
&
destin
->
scan
[
j
],
&
origin
->
scan
[
i
],
sizeof
(
struct
ir_scancode
));
j
++
;
}
}
destin
->
size
=
j
;
IR_dprintk
(
1
,
"Copied %d scancodes to the new keycode table
\n
"
,
j
);
return
0
;
}
/**
* ir_getkeycode() - get a keycode at the evdev scancode ->keycode table
* @dev: the struct input_dev device descriptor
...
...
@@ -152,3 +214,16 @@ int ir_set_keycode_table(struct input_dev *input_dev,
return
0
;
}
void
ir_input_free
(
struct
input_dev
*
dev
)
{
struct
ir_scancode_table
*
rc_tab
=
input_get_drvdata
(
dev
);
IR_dprintk
(
1
,
"Freed keycode table
\n
"
);
rc_tab
->
size
=
0
;
kfree
(
rc_tab
->
scan
);
rc_tab
->
scan
=
NULL
;
}
EXPORT_SYMBOL_GPL
(
ir_input_free
);
include/media/ir-common.h
浏览文件 @
f6fc5049
...
...
@@ -54,6 +54,8 @@ struct ir_input_state {
/* configuration */
int
ir_type
;
struct
ir_scancode_table
keytable
;
/* key info */
u32
ir_key
;
/* ir scancode */
u32
keycode
;
/* linux key code */
...
...
@@ -121,6 +123,10 @@ u32 ir_g_keycode_from_table(struct input_dev *input_dev,
int
ir_set_keycode_table
(
struct
input_dev
*
input_dev
,
struct
ir_scancode_table
*
rc_tab
);
int
ir_roundup_tablesize
(
int
n_elems
);
int
ir_copy_table
(
struct
ir_scancode_table
*
destin
,
const
struct
ir_scancode_table
*
origin
);
void
ir_input_free
(
struct
input_dev
*
input_dev
);
/* scancode->keycode map tables from ir-keymaps.c */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录