飞思卡尔的开发包 提供了两个选项
Preconfig Min Profile
FSL gnome release package
第一个选项没有编译GTK gstreamer 和X11
第二个选项编译后又太大了。
我只需要能运行GTK的最小配置。所以选择了第一个选项。然后./ltib -c
添加了GTK,gstreamer X11
而且由于我的板子上不是矩阵键盘。是接到GPIO的按键。所以我修改了程序。添加了GPIO BUTTON的定义
#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
static struct gpio_keys_button mx23evk_gpio_buttons[] = {
{
.gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DETECT),
.type = EV_KEY,
.code = KEY_A,//KEY_VOLUMEUP,
.desc = "SW105",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA0),
.type = EV_KEY,
.code = KEY_B,//KEY_UP,
.desc = "SW108",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA1),
.type = EV_KEY,
.code = KEY_C,//KEY_DOWN,
.desc = "SW107",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA2),
.type = EV_KEY,
.code = KEY_D,//KEY_VOLUMEDOWN,
.desc = "SW106",
.active_low = 1,
.wakeup = 1,
},
{
.gpio = MXS_PIN_TO_GPIO(PINID_SSP1_CMD),
.type = EV_KEY,
.code = KEY_E,//KEY_ESC,
.desc = "SW109",
.active_low = 1,
.wakeup = 1,
},
};
static struct gpio_keys_platform_data mx23evk_gpio_button_data = {
.buttons = mx23evk_gpio_buttons,
.nbuttons = ARRAY_SIZE(mx23evk_gpio_buttons),
};
static struct platform_device mx23evk_gpio_button_device = {
.name = "gpio-keys",
.id = -1,
.num_resources = 0,
.dev = {
.platform_data = &mx23evk_gpio_button_data,
}
};
static void __init mx23_init_gpio_keyboard(void)
{
platform_device_register(&mx23evk_gpio_button_device);
}
int __init mx23_device_init(void)
{
..........
..........
//在设备初始化的地方添加了调用
mx23_init_gpio_keyboard();
return 0;
}
然后配置内核驱动
--- Keyboards
<*> GPIO Buttons
程序下载运行启动的时候显示
input: gpio-keys as /class/input/input0
input: mxs-kbd as /class/input/input1
input: MXS touchscreen as /class/input/input2
证明按键驱动已经加载。并且添加打印信息也证明按键按下时执行到了gpio_keys.c static void gpio_keys_report_event(struct work_struct *work)这个函数。而且
input_event(input, type, button->code, !!state);这个函数内部执行有效按键检查也通过了。
static void gpio_keys_report_event(struct work_struct *work)
{
struct gpio_button_data *bdata =
container_of(work, struct gpio_button_data, work);
struct gpio_keys_button *button = bdata->button;
struct input_dev *input = bdata->input;
unsigned int type = button->type ?: EV_KEY;
int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
/*inkfish debug*/
printk(KERN_INFO "%s %s %d\r\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_INFO "type=%d, button->code=%d, state=%d\r\n", type, button->code, state);
input_event(input, type, button->code, !!state);
input_sync(input);
}
void input_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
{
unsigned long flags;
if (is_event_supported(type, dev->evbit, EV_MAX)) {
/*inkfish debug*/
printk(KERN_INFO "%s %s %d\r\n", __FILE__, __FUNCTION__, __LINE__);
spin_lock_irqsave(&dev->event_lock, flags);
add_input_randomness(type, code, value);
input_handle_event(dev, type, code, value);
spin_unlock_irqrestore(&dev->event_lock, flags);
}
}
现在的问题是我要如何设置X启动的时候能正确的加载按键驱动。
Xfbdev -keybd gpio-keys,,device=/dev/input/event0
(EE) XKB: Couldn't open rules file /usr/share/X11/xkb/rules/base
(EE) XKB: No components provided for device Virtual core keyboard
Couldn't find keyboard driver gpio-keys
这样执行的结果不对。 |