From 0c5fa48c4e1fda614d3f6a01dfbba1b7df4e2776 Mon Sep 17 00:00:00 2001 From: Sungho Park Date: Mon, 30 Apr 2012 18:01:42 +0900 Subject: [PATCH] upload tizen1.0 source Change-Id: I28ce31522eddcc3e62ed8513811c40d06d2baf09 --- .mailmap | 107 ++++ arch/x86/configs/i386_emul_defconfig | 18 +- drivers/char/Kconfig | 9 + drivers/char/Makefile | 2 + drivers/char/virtio-gl.c | 312 +++++++++ drivers/input/Kconfig | 7 + drivers/input/Makefile | 1 + drivers/input/keyboard/atkbd.c | 3 +- drivers/input/sec-input-bridge.c | 416 ++++++++++++ drivers/maru/maru_bl.c | 12 +- drivers/maru/maru_codec.c | 834 +++++++++++++++---------- drivers/maru/maru_fb.c | 14 +- drivers/maru/maru_power_supply.c | 14 + include/linux/input/sec-input-bridge.h | 31 + include/linux/virtio_ids.h | 1 + kernel/power/main.c | 7 + kernel/sys.c | 12 + net/9p/client.c | 3 + net/9p/trans_virtio.c | 3 + package/pkginfo.manifest | 4 +- 20 files changed, 1453 insertions(+), 357 deletions(-) create mode 100644 .mailmap mode change 100644 => 100755 drivers/char/Kconfig mode change 100644 => 100755 drivers/char/Makefile create mode 100755 drivers/char/virtio-gl.c create mode 100644 drivers/input/sec-input-bridge.c create mode 100644 include/linux/input/sec-input-bridge.h mode change 100644 => 100755 include/linux/virtio_ids.h diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000000..a62e6a84fd1e --- /dev/null +++ b/.mailmap @@ -0,0 +1,107 @@ +# +# This list is used by git-shortlog to fix a few botched name translations +# in the git archive, either because the author's full name was messed up +# and/or not always written the same way, making contributions from the +# same person appearing not to be so or badly displayed. +# +# repo-abbrev: /pub/scm/linux/kernel/git/ +# + +Aaron Durbin +Adam Oldham +Adam Radford +Adrian Bunk +Alan Cox +Alan Cox +Aleksey Gorelov +Al Viro +Al Viro +Andreas Herrmann +Andrew Morton +Andrew Vasquez +Andy Adamson +Arnaud Patard +Arnd Bergmann +Axel Dyks +Ben Gardner +Ben M Cahill +Björn Steinbrink +Brian Avery +Brian King +Christoph Hellwig +Corey Minyard +David Brownell +David Woodhouse +Dmitry Eremin-Solenikov +Domen Puncer +Douglas Gilbert +Ed L. Cashin +Evgeniy Polyakov +Felipe W Damasio +Felix Kuhling +Felix Moeller +Filipe Lautert +Franck Bui-Huu +Frank Zago +Greg Kroah-Hartman +Greg Kroah-Hartman +Greg Kroah-Hartman +Henk Vergonet +Henrik Kretzschmar +Herbert Xu +Jacob Shin +James Bottomley +James Bottomley +James E Wilson +James Ketrenos +Jean Tourrilhes +Jeff Garzik +Jens Axboe +Jens Osterkamp +John Stultz +Juha Yrjola +Juha Yrjola +Juha Yrjola +Kay Sievers +Kenneth W Chen +Koushik +Leonid I Ananiev +Linas Vepstas +Mark Brown +Matthieu CASTET +Michael Buesch +Michael Buesch +Michel Dänzer +Mitesh shah +Morten Welinder +Morten Welinder +Morten Welinder +Morten Welinder +Nguyen Anh Quynh +Paolo 'Blaisorblade' Giarrusso +Patrick Mochel +Peter A Jonsson +Peter Oruba +Peter Oruba +Praveen BP +Rajesh Shah +Ralf Baechle +Ralf Wildenhues +Rémi Denis-Courmont +Rudolf Marek +Rui Saraiva +Sachin P Sant +Sam Ravnborg +Sascha Hauer +S.Çağlar Onur +Simon Kelley +Stéphane Witzmann +Stephen Hemminger +Tejun Heo +Thomas Graf +Tony Luck +Tsuneo Yoshioka +Uwe Kleine-König +Uwe Kleine-König +Uwe Kleine-König +Valdis Kletnieks diff --git a/arch/x86/configs/i386_emul_defconfig b/arch/x86/configs/i386_emul_defconfig index dc64864ffab6..3cdbb4765e16 100644 --- a/arch/x86/configs/i386_emul_defconfig +++ b/arch/x86/configs/i386_emul_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.32.9 -# Fri Feb 17 13:23:24 2012 +# Thu Mar 8 16:47:36 2012 # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -183,7 +183,8 @@ CONFIG_HAVE_DMA_API_DEBUG=y # GCOV-based kernel profiling # # CONFIG_GCOV_KERNEL is not set -# CONFIG_SLOW_WORK is not set +CONFIG_SLOW_WORK=y +# CONFIG_SLOW_WORK_DEBUG is not set CONFIG_HAVE_GENERIC_DMA_COHERENT=y CONFIG_SLABINFO=y CONFIG_RT_MUTEXES=y @@ -1103,6 +1104,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 # CONFIG_INPUT_JOYDEV is not set CONFIG_INPUT_EVDEV=y # CONFIG_INPUT_EVBUG is not set +CONFIG_INPUT_SECBRIDGE=y # # Input Device Drivers @@ -1276,6 +1278,7 @@ CONFIG_NVRAM=y # CONFIG_TCG_TPM is not set # CONFIG_TELCLOCK is not set CONFIG_VDPRAM_DEVICE=y +CONFIG_VIRTIOGL=y CONFIG_DEVPORT=y CONFIG_I2C=y CONFIG_I2C_BOARDINFO=y @@ -1354,6 +1357,7 @@ CONFIG_I2C_I801=y CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y # CONFIG_GPIOLIB is not set # CONFIG_W1 is not set +CONFIG_POWER_SUPPLY=y # CONFIG_POWER_SUPPLY_DEBUG is not set # CONFIG_PDA_POWER is not set # CONFIG_BATTERY_DS2760 is not set @@ -2317,7 +2321,15 @@ CONFIG_SUNRPC_GSS=y CONFIG_RPCSEC_GSS_KRB5=y # CONFIG_RPCSEC_GSS_SPKM3 is not set # CONFIG_SMB_FS is not set -# CONFIG_CIFS is not set +CONFIG_CIFS=y +# CONFIG_CIFS_STATS is not set +# CONFIG_CIFS_WEAK_PW_HASH is not set +# CONFIG_CIFS_UPCALL is not set +CONFIG_CIFS_XATTR=y +# CONFIG_CIFS_POSIX is not set +# CONFIG_CIFS_DEBUG2 is not set +# CONFIG_CIFS_DFS_UPCALL is not set +# CONFIG_CIFS_EXPERIMENTAL is not set # CONFIG_NCP_FS is not set # CONFIG_CODA_FS is not set # CONFIG_AFS_FS is not set diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig old mode 100644 new mode 100755 index 8965e41fb4dd..1047c57d227c --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -1097,6 +1097,7 @@ config UV_MMTIMER source "drivers/char/tpm/Kconfig" + config TELCLOCK tristate "Telecom clock driver for ATCA SBC" depends on EXPERIMENTAL && X86 @@ -1115,6 +1116,14 @@ config VDPRAM_DEVICE ---help--- vdpram is telephony simulator works with the event injector. +config VIRTIOGL + tristate "Virtio userspace memory transport" + depends on VIRTIO_PCI + default n + help + A Driver to facilitate transferring data from userspace to a + hypervisor (eg. qemu) + config DEVPORT bool depends on !M68K diff --git a/drivers/char/Makefile b/drivers/char/Makefile old mode 100644 new mode 100755 index badb3ec6af44..9e641972c91f --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -99,6 +99,8 @@ obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o obj-$(CONFIG_GPIO_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_VIRTIOGL) += virtio-gl.o + obj-$(CONFIG_MWAVE) += mwave/ obj-$(CONFIG_AGP) += agp/ obj-$(CONFIG_PCMCIA) += pcmcia/ diff --git a/drivers/char/virtio-gl.c b/drivers/char/virtio-gl.c new file mode 100755 index 000000000000..b13a45fa5e08 --- /dev/null +++ b/drivers/char/virtio-gl.c @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2010 Intel Corporation + * + * Author: Ian Molton + * + * 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; version 2 of the License. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VIRTIO_ID_GL 6 +#define DEVICE_NAME "glmem" + +/* Define to use debugging checksums on transfers */ +#undef DEBUG_GLIO + +struct virtio_gl_data { + char *buffer; + int pages; + unsigned int pid; +}; + +struct virtio_gl_header { + int pid; + int buf_size; + int r_buf_size; +#ifdef DEBUG_GLIO + int sum; +#endif + char buffer; +} __packed; + +#define to_virtio_gl_data(a) ((struct virtio_gl_data *)(a)->private_data) + +#ifdef DEBUG_GLIO +#define SIZE_OUT_HEADER (sizeof(int)*4) +#define SIZE_IN_HEADER (sizeof(int)*2) +#else +#define SIZE_OUT_HEADER (sizeof(int)*3) +#define SIZE_IN_HEADER sizeof(int) +#endif + +static struct virtqueue *vq; + + +/* This is videobuf_vmalloc_to_sg() from videobuf-dma-sg.c with + * some modifications + */ +static struct scatterlist *vmalloc_to_sg(struct scatterlist *sg_list, + unsigned char *virt, unsigned int pages) +{ + struct page *pg; + + /* unaligned */ + BUG_ON((ulong)virt & ~PAGE_MASK); + + /* Fill with elements for the data */ + while (pages) { + pg = vmalloc_to_page(virt); + if (!pg) + goto err; + + sg_set_page(sg_list, pg, PAGE_SIZE, 0); + virt += PAGE_SIZE; + sg_list++; + pages--; + } + + return sg_list; + +err: + kfree(sg_list); + return NULL; +} + +static int put_data(struct virtio_gl_data *gldata) +{ + struct scatterlist *sg, *sg_list; + unsigned int count, ret, o_page, i_page, sg_entries; + struct virtio_gl_header *header = + (struct virtio_gl_header *)gldata->buffer; + + ret = header->buf_size; + + o_page = (header->buf_size + PAGE_SIZE-1) >> PAGE_SHIFT; + i_page = (header->r_buf_size + PAGE_SIZE-1) >> PAGE_SHIFT; + + header->pid = gldata->pid; + + if ((o_page && i_page) && + (o_page > gldata->pages || i_page > gldata->pages)) { + i_page = 0; + } + + if (o_page > gldata->pages) + o_page = gldata->pages; + + if (i_page > gldata->pages) + i_page = gldata->pages; + + if (!o_page) + o_page = 1; + + sg_entries = o_page + i_page; + + sg_list = kcalloc(sg_entries, sizeof(struct scatterlist), GFP_KERNEL); + + if (!sg_list) { + ret = -EIO; + goto out; + } + + sg_init_table(sg_list, sg_entries); + + sg = vmalloc_to_sg(sg_list, gldata->buffer, o_page); + sg = vmalloc_to_sg(sg, gldata->buffer, i_page); + + if (!sg) { + ret = -EIO; + goto out_free; + } + + /* Transfer data */ + if (vq->vq_ops->add_buf(vq, sg_list, o_page, i_page, (void *)1) >= 0) { + vq->vq_ops->kick(vq); + /* Chill out until it's done with the buffer. */ + while (!vq->vq_ops->get_buf(vq, &count)) + cpu_relax(); + } + +out_free: + kfree(sg_list); +out: + return ret; +} + +static void free_buffer(struct virtio_gl_data *gldata) +{ + if (gldata->buffer) { + vfree(gldata->buffer); + gldata->buffer = NULL; + } +} + +static int glmem_open(struct inode *inode, struct file *file) +{ + struct virtio_gl_data *gldata = kzalloc(sizeof(struct virtio_gl_data), + GFP_KERNEL); + + if (!gldata) + return -ENXIO; + + gldata->pid = pid_nr(task_pid(current)); + + file->private_data = gldata; + + return 0; +} + +static int glmem_mmap(struct file *filp, struct vm_area_struct *vma) +{ + struct virtio_gl_data *gldata = to_virtio_gl_data(filp); + int pages = (vma->vm_end - vma->vm_start) / PAGE_SIZE; + + /* Set a reasonable limit */ + if (pages > 16) + return -ENOMEM; + + /* for now, just allow one buffer to be mmap()ed. */ + if (gldata->buffer) + return -EIO; + + gldata->buffer = vmalloc_user(pages*PAGE_SIZE); + + if (!gldata->buffer) + return -ENOMEM; + + gldata->pages = pages; + + if (remap_vmalloc_range(vma, gldata->buffer, 0) < 0) { + vfree(gldata->buffer); + return -EIO; + } + + vma->vm_flags |= VM_DONTEXPAND; + + return 0; +} + +static int glmem_fsync(struct file *filp, int datasync) +{ + struct virtio_gl_data *gldata = to_virtio_gl_data(filp); + + put_data(gldata); + + return 0; +} + +static int glmem_release(struct inode *inode, struct file *file) +{ + struct virtio_gl_data *gldata = to_virtio_gl_data(file); + + if (gldata && gldata->buffer) { + struct virtio_gl_header *header = + (struct virtio_gl_header *)gldata->buffer; + + /* Make sure the host hears about the process ending / dying */ + header->pid = gldata->pid; + header->buf_size = SIZE_OUT_HEADER + 2; + header->r_buf_size = SIZE_IN_HEADER; + *(short *)(&header->buffer) = -1; + + put_data(gldata); + free_buffer(gldata); + } + + kfree(gldata); + + return 0; +} + +static const struct file_operations glmem_fops = { + .owner = THIS_MODULE, + .open = glmem_open, + .mmap = glmem_mmap, + .fsync = glmem_fsync, + .release = glmem_release, +}; + +static struct miscdevice glmem_dev = { + MISC_DYNAMIC_MINOR, + DEVICE_NAME, + &glmem_fops +}; + +static int glmem_probe(struct virtio_device *vdev) +{ + int ret; + + /* We expect a single virtqueue. */ + vq = virtio_find_single_vq(vdev, NULL, "output"); + if (IS_ERR(vq)) + return PTR_ERR(vq); + + ret = misc_register(&glmem_dev); + if (ret) { + printk(KERN_ERR "glmem: cannot register glmem_dev as misc"); + return -ENODEV; + } + + return 0; +} + +static void __devexit glmem_remove(struct virtio_device *vdev) +{ + vdev->config->reset(vdev); + misc_deregister(&glmem_dev); + vdev->config->del_vqs(vdev); +} + +static struct virtio_device_id id_table[] = { + { VIRTIO_ID_GL, VIRTIO_DEV_ANY_ID }, + { 0 }, +}; + +static struct virtio_driver virtio_gl_driver = { + .driver = { + .name = KBUILD_MODNAME, + .owner = THIS_MODULE, + }, + .id_table = id_table, + .probe = glmem_probe, + .remove = __devexit_p(glmem_remove), +}; + +static int __init glmem_init(void) +{ + return register_virtio_driver(&virtio_gl_driver); +} + +static void __exit glmem_exit(void) +{ + unregister_virtio_driver(&virtio_gl_driver); +} + +module_init(glmem_init); +module_exit(glmem_exit); + +MODULE_DEVICE_TABLE(virtio, id_table); +MODULE_DESCRIPTION("Virtio gl passthrough driver"); +MODULE_LICENSE("GPL v2"); + diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index cd50c00ab20f..789bf24ae887 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -158,6 +158,13 @@ config XEN_KBDDEV_FRONTEND keyboard and mouse device driver. It communicates with a back-end in another domain. +config INPUT_SECBRIDGE + bool "Specific input event handler for Samsung" + depends on INPUT + default n + help + This driver implements the sec-input-bridge + comment "Input Device Drivers" source "drivers/input/keyboard/Kconfig" diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 4c9c745a7020..be0af27d1abd 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -25,3 +25,4 @@ obj-$(CONFIG_INPUT_MISC) += misc/ obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o obj-$(CONFIG_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o +obj-$(CONFIG_INPUT_SECBRIDGE) += sec-input-bridge.o diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index a977436f84a3..b024f0149175 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -537,8 +537,9 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, } #ifndef SIM_SKINCODE - printk(KERN_DEBUG "atkbd.c: Conversion Received code = (%d)%03x, keycode = (%d)%03x\n", +/* printk(KERN_DEBUG "atkbd.c: Conversion Received code = (%d)%03x, keycode = (%d)%03x\n", code, code, keycode, keycode); +*/ #endif input_event(dev, EV_KEY, keycode, value); input_sync(dev); diff --git a/drivers/input/sec-input-bridge.c b/drivers/input/sec-input-bridge.c new file mode 100644 index 000000000000..a69ee3e36ff0 --- /dev/null +++ b/drivers/input/sec-input-bridge.c @@ -0,0 +1,416 @@ +/* + * sec-input-bridge.c - Specific control inpt event bridge for Samsung Electronics + * + * Copyright (C) 2010 Samsung Electronics + * Yongsul Oh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include + +extern int bkl_warning_operation(int on_off, int gamma); + +#ifdef CONFIG_KERNEL_LOGGING +int rb_dump_ram_log_extract_to_file(char* file_path); +#ifdef CONFIG_RB_DUMP_USE_NAND +int rb_dump_nand_log_extract_to_file(char* file_path); +#endif +#endif // CONFIG_RB_DUMP_USE_NAND + +struct sec_input_bridge { + struct sec_input_bridge_platform_data *pdata; + struct work_struct work; + struct mutex lock; + struct platform_device *dev; + + u8 check_index; +}; + +static void input_bridge_set_ids(struct input_device_id *ids, unsigned int type, unsigned int code) +{ + switch (type) { + case EV_KEY: + ids->flags = INPUT_DEVICE_ID_MATCH_KEYBIT; + __set_bit(code, ids->keybit); + break; + + case EV_REL: + ids->flags = INPUT_DEVICE_ID_MATCH_RELBIT; + __set_bit(code, ids->relbit); + break; + + case EV_ABS: + ids->flags = INPUT_DEVICE_ID_MATCH_ABSBIT; + __set_bit(code, ids->absbit); + break; + + case EV_MSC: + ids->flags = INPUT_DEVICE_ID_MATCH_MSCIT; + __set_bit(code, ids->mscbit); + break; + + case EV_SW: + ids->flags = INPUT_DEVICE_ID_MATCH_SWBIT; + __set_bit(code, ids->swbit); + break; + + case EV_LED: + ids->flags = INPUT_DEVICE_ID_MATCH_LEDBIT; + __set_bit(code, ids->ledbit); + break; + + case EV_SND: + ids->flags = INPUT_DEVICE_ID_MATCH_SNDBIT; + __set_bit(code, ids->sndbit); + break; + + case EV_FF: + ids->flags = INPUT_DEVICE_ID_MATCH_FFBIT; + __set_bit(code, ids->ffbit); + break; + + case EV_PWR: + /* do nothing */ + break; + + default: + printk(KERN_ERR + "input_bridge_set_ids: unknown type %u (code %u)\n", + type, code); + return; + } + + ids->flags |= INPUT_DEVICE_ID_MATCH_EVBIT; + __set_bit(type, ids->evbit); +} + +static void input_bridge_work(struct work_struct *work) { + struct sec_input_bridge *bridge = container_of(work, + struct sec_input_bridge, work); + int state = -EINVAL; + char env_str[16]; + char *envp[] = { env_str, NULL }; + +#ifdef CONFIG_KERNEL_LOGGING + rb_dump_ram_log_extract_to_file(NULL); +#ifdef CONFIG_RB_DUMP_USE_NAND + rb_dump_nand_log_extract_to_file(NULL); +#endif +#endif + + mutex_lock(&bridge->lock); + + if (bridge->pdata->send_uevent) { + sprintf(env_str, "%s=%s", bridge->pdata->uevent_env_str , bridge->pdata->uevent_env_value); + state = kobject_uevent_env(&bridge->dev->dev.kobj, bridge->pdata->uevent_action, envp); +// state = kobject_uevent(&bridge->dev->dev.kobj, bridge->pdata->uevent_action); + if (state != 0) + printk(KERN_ERR + " with action : %d\n",bridge->pdata->uevent_action); + } + + if (bridge->pdata->pre_event_func && (state == 0)) { + bridge->pdata->pre_event_func(bridge->pdata->event_data); + } + + /* LCD on/off to confirm action*/ +#if 0 // emulator + ssleep(2); + + for (i=0 ; i<8 ; i++) { + bkl_warning_operation(1, 0); + msleep(500); + + bkl_warning_operation(1, 10); + msleep(500); + } + + /* recovery first state*/ + bkl_warning_operation(0, 0); +#endif + + mutex_unlock(&bridge->lock); +} + +static void input_bridge_event(struct input_handle *handle, unsigned int type, + unsigned int code, int value) +{ + int rep_check; + + struct input_handler *sec_bridge_handler = handle->handler; + struct sec_input_bridge *sec_bridge = sec_bridge_handler->private; + + rep_check = test_bit(EV_REP,sec_bridge_handler->id_table->evbit); + rep_check = (rep_check << 1) | 1; + + switch (type) { + case EV_KEY: + if ( value & rep_check ) { + printk(KERN_INFO + "sec-input-bridge: KEY input intercepted, type : %d , code : %d , value %d, index : %d, mkey_max : %d \n", + type,code,value, sec_bridge->check_index, sec_bridge->pdata->num_mkey); + if ( sec_bridge->pdata->mkey_map[sec_bridge->check_index].code == code) { + sec_bridge->check_index++; + printk(KERN_INFO "sec-input-bridge: code ok!\n"); + if ( (sec_bridge->check_index) >= (sec_bridge->pdata->num_mkey) ) { + printk(KERN_INFO "sec-input-bridge: index is max \n"); + schedule_work(&sec_bridge->work); + sec_bridge->check_index = 0; + } + } else { + sec_bridge->check_index = 0; + } + } + break; + + default: + break; + } + +} + +static int input_bridge_connect(struct input_handler *handler, + struct input_dev *dev, + const struct input_device_id *id) +{ + struct input_handle *handle; + int error; + + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); + if (!handle) + return -ENOMEM; + + handle->dev = dev; + handle->handler = handler; + handle->name = "sec-input-bridge"; + + error = input_register_handle(handle); + if (error) { + printk(KERN_ERR + "sec-input-bridge: Failed to register input bridge handler, " + "error %d\n", error); + kfree(handle); + return error; + } + + error = input_open_device(handle); + if (error) { + printk(KERN_ERR + "sec-input-bridge: Failed to open input bridge device, " + "error %d\n", error); + input_unregister_handle(handle); + kfree(handle); + return error; + } + + return 0; +} + +static void input_bridge_disconnect(struct input_handle *handle) +{ + input_close_device(handle); + input_unregister_handle(handle); + kfree(handle); +} + +static struct input_handler input_bridge_handler = { + .event = input_bridge_event, + .connect = input_bridge_connect, + .disconnect = input_bridge_disconnect, + .name = "sec-input-bridge", +}; + +static int __devinit sec_input_bridge_probe(struct platform_device *dev) +{ + struct sec_input_bridge_platform_data *pdata; + struct sec_input_bridge *bridge; + struct input_device_id *input_bridge_ids; + + int state; + int i; + + pdata = dev->dev.platform_data; + if (!pdata) { + dev_err(&dev->dev, "No samsung input bridge platform data.\n"); + return -EINVAL; + } + + if (pdata->num_mkey == 0) { + dev_err(&dev->dev, "No samsung input bridge platform data. num_mkey == 0\n"); + return -EINVAL; + } + + bridge = kzalloc(sizeof(struct sec_input_bridge), GFP_KERNEL); + if (!bridge) + return -ENOMEM; + + input_bridge_ids = kzalloc(sizeof(struct input_device_id[(pdata->num_mkey +1)]), GFP_KERNEL); + if(!input_bridge_ids) { + kfree(bridge); + return -ENOMEM; + } + memset(input_bridge_ids, 0x00, sizeof(input_bridge_ids)); + + for( i=0 ; i < pdata->num_mkey ; i++ ) { + input_bridge_set_ids(&input_bridge_ids[i], pdata->mkey_map[i].type, pdata->mkey_map[i].code); + } + + input_bridge_handler.private = bridge; + input_bridge_handler.id_table = input_bridge_ids; + + state = input_register_handler(&input_bridge_handler); + if (state) + goto input_register_fail; + + bridge->dev = dev; + bridge->pdata = pdata; + + INIT_WORK(&bridge->work, input_bridge_work); + mutex_init(&bridge->lock); + + platform_set_drvdata(dev, bridge); + + return 0; + +input_register_fail: + cancel_work_sync(&bridge->work); + mutex_destroy(&bridge->lock); + kfree(bridge); + kfree(input_bridge_ids); + + return state; + +} + +static int __devexit sec_input_bridge_remove(struct platform_device *dev) +{ + struct sec_input_bridge *bridge = platform_get_drvdata(dev); + + cancel_work_sync(&bridge->work); + mutex_destroy(&bridge->lock); + kfree(input_bridge_handler.id_table); + input_unregister_handler(&input_bridge_handler); + kfree(bridge); + platform_set_drvdata(dev, NULL); + + return 0; +} + + +#ifdef CONFIG_PM +static int sec_input_bridge_suspend(struct platform_device *dev, pm_message_t state) +{ + return 0; +} + +static int sec_input_bridge_resume(struct platform_device *dev) +{ + return 0; +} +#else +#define sec_input_bridge_suspend NULL +#define sec_input_bridge_resume NULL +#endif + +static struct platform_driver sec_input_bridge_driver = { + .probe = sec_input_bridge_probe, + .remove = __devexit_p(sec_input_bridge_remove), + .suspend = sec_input_bridge_suspend, + .resume = sec_input_bridge_resume, + .driver = { + .name = "samsung_input_bridge", + }, +}; + +static const struct sec_input_bridge_mkey emul_mkey_map[] = { + { .type = EV_KEY , .code = KEY_VOLUMEUP }, + { .type = EV_KEY , .code = KEY_VOLUMEDOWN }, + { .type = EV_KEY , .code = KEY_FRONT }, + { .type = EV_KEY , .code = KEY_FRONT }, + { .type = EV_KEY , .code = KEY_VOLUMEUP }, + { .type = EV_KEY , .code = KEY_VOLUMEDOWN }, + { .type = EV_KEY , .code = KEY_VOLUMEUP }, + { .type = EV_KEY , .code = KEY_FRONT }, +}; + +static struct sec_input_bridge_platform_data emul_input_bridge_data = { + + .mkey_map = emul_mkey_map , + .num_mkey = ARRAY_SIZE(emul_mkey_map), + + .send_uevent = 1, + .uevent_action = KOBJ_CHANGE, + .uevent_env_str = "RB_DUMP", + .uevent_env_value = "ON", +}; + +static struct platform_device emul_input_bridge = { + .name = "samsung_input_bridge", + .id = -1, + .dev = { + .platform_data = &emul_input_bridge_data, + }, +}; + +//static struct platform_device *sec_input_bridge_device; + +static int __init sec_input_bridge_init(void) +{ + int err = 0; + + platform_device_register(&emul_input_bridge); + + err = platform_driver_register(&sec_input_bridge_driver); + + /* + if (!err) { + sec_input_bridge_device = platform_device_alloc("samsung_input_bridge", 0); + if (sec_input_bridge_device) + err = platform_device_add(sec_input_bridge_device); + else + err = -ENOMEM; + + if (err) { + platform_device_put(sec_input_bridge_device); + platform_driver_unregister(&sec_input_bridge_driver); + return err; + } + } + */ + return err; +} + +static void __exit sec_input_bridge_exit(void) +{ + platform_driver_unregister(&sec_input_bridge_driver); +} + + +module_init(sec_input_bridge_init); + +#ifdef CONFIG_CHARGER_DETECT_BOOT +charger_module_init(sec_input_bridge_init); +#endif + +module_exit(sec_input_bridge_exit); + +MODULE_AUTHOR("Yongsul Oh "); +MODULE_DESCRIPTION("Input Event -> Specific Control Bridge"); +MODULE_LICENSE("GPL"); diff --git a/drivers/maru/maru_bl.c b/drivers/maru/maru_bl.c index 370b33c1fe77..10c9ed4316c6 100644 --- a/drivers/maru/maru_bl.c +++ b/drivers/maru/maru_bl.c @@ -77,16 +77,16 @@ static int marubl_send_intensity(struct backlight_device *bd) unsigned int off = 0; if (bd->props.power != FB_BLANK_UNBLANK) { - intensity = 0; - off = 1; + intensity = 0; + off = 1; } if (bd->props.state & BL_CORE_FBBLANK) { - intensity = 0; - off = 1; + intensity = 0; + off = 1; } if (bd->props.state & BL_CORE_SUSPENDED) { - intensity = 0; - off = 1; + intensity = 0; + off = 1; } // if (bd->props.state & GENERICBL_BATTLOW) // intensity &= bl_machinfo->limit_mask; diff --git a/drivers/maru/maru_codec.c b/drivers/maru/maru_codec.c index 5b75ed16fa7e..084568c196f2 100644 --- a/drivers/maru/maru_codec.c +++ b/drivers/maru/maru_codec.c @@ -45,44 +45,52 @@ #include #include -#include "avformat.h" +#ifdef CODEC_HOST +#include "avformat.h" +#endif -#define DRIVER_NAME "codec" -#define CODEC_MAJOR 240 +#define DRIVER_NAME "codec" +#define CODEC_MAJOR 240 MODULE_DESCRIPTION("Virtual Codec Device Driver"); MODULE_AUTHOR("Kitae KIM av_class = srcctx->av_class; - dstctx->codec = srcctx->codec; - dstctx->extradata = srcctx->extradata; - dstctx->opaque = srcctx->opaque; - dstctx->get_buffer = srcctx->get_buffer; - dstctx->release_buffer = srcctx->release_buffer; - dstctx->stats_out = srcctx->stats_out; - dstctx->stats_in = srcctx->stats_in; - dstctx->rc_override = srcctx->rc_override; - dstctx->rc_eq = srcctx->rc_eq; - dstctx->slice_offset = srcctx->slice_offset; - dstctx->get_format = srcctx->get_format; - dstctx->internal_buffer = srcctx->internal_buffer; - dstctx->intra_matrix = srcctx->intra_matrix; - dstctx->inter_matrix = srcctx->inter_matrix; - dstctx->reget_buffer = srcctx->reget_buffer; - dstctx->execute = srcctx->execute; - dstctx->thread_opaque = srcctx->thread_opaque; - dstctx->execute2 = srcctx->execute2; + AVCodecContext *srcctx) { + dstctx->av_class = srcctx->av_class; + dstctx->codec = srcctx->codec; + dstctx->extradata = srcctx->extradata; + dstctx->opaque = srcctx->opaque; + dstctx->get_buffer = srcctx->get_buffer; + dstctx->release_buffer = srcctx->release_buffer; + dstctx->stats_out = srcctx->stats_out; + dstctx->stats_in = srcctx->stats_in; + dstctx->rc_override = srcctx->rc_override; + dstctx->rc_eq = srcctx->rc_eq; + dstctx->slice_offset = srcctx->slice_offset; + dstctx->get_format = srcctx->get_format; + dstctx->internal_buffer = srcctx->internal_buffer; + dstctx->intra_matrix = srcctx->intra_matrix; + dstctx->inter_matrix = srcctx->inter_matrix; + dstctx->reget_buffer = srcctx->reget_buffer; + dstctx->execute = srcctx->execute; + dstctx->thread_opaque = srcctx->thread_opaque; + dstctx->execute2 = srcctx->execute2; } #endif +/* Another way to copy data between guest and host. */ #ifdef CODEC_HOST static ssize_t svcodec_write (struct file *file, const char __user *buf, - size_t count, loff_t *fops) + size_t count, loff_t *fops) { - struct _param paramInfo; - AVCodecParserContext tempParserCtx; - AVCodecContext tempCtx; - int i; - - if (!svcodec) { - printk(KERN_ERR "[%s]:Fail to get codec device info\n", __func__); - } - - if (copy_from_user(¶mInfo, buf, sizeof(struct _param))) { - printk(KERN_ERR "[%s]:Fail to copy\n", __func__); - } - - for (i = 0; i < paramInfo.in_args_num; i++) { - writel(paramInfo.in_args[i], svcodec->ioaddr + CODEC_IN_PARAM); - } - - /* guest to host */ - if (paramInfo.apiIndex == EMUL_AVCODEC_OPEN) { - AVCodecContext *ctx; - ctx = (AVCodecContext*)paramInfo.in_args[0]; - if (ctx) { - memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); - writel((uint32_t)ctx->extradata, svcodec->ioaddr + CODEC_IN_PARAM); - } - } else if (paramInfo.apiIndex == EMUL_AVCODEC_DECODE_VIDEO) { - AVCodecContext *ctx; - ctx = (AVCodecContext*)paramInfo.in_args[0]; - memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); - } else if (paramInfo.apiIndex == EMUL_AVCODEC_ENCODE_VIDEO) { - AVCodecContext *ctx; - uint32_t buf_size; - ctx = (AVCodecContext*)paramInfo.in_args[0]; - buf_size = *(uint32_t*)paramInfo.in_args[2]; - writel((uint32_t)ctx->coded_frame, svcodec->ioaddr + CODEC_IN_PARAM); - svcodec->imgBuf = kmalloc(buf_size, GFP_KERNEL); - writel((uint32_t)svcodec->imgBuf, svcodec->ioaddr + CODEC_IN_PARAM); - } else if (paramInfo.apiIndex == EMUL_AV_PICTURE_COPY) { - int pix_fmt; - int width, height; - int size; - pix_fmt = *(int*)paramInfo.in_args[1]; - width = *(int*)paramInfo.in_args[2]; - height = *(int*)paramInfo.in_args[3]; - size = get_picture_size(pix_fmt, width, height); - svcodec->imgBuf = kmalloc(size, GFP_KERNEL); - writel((uint32_t)svcodec->imgBuf, svcodec->ioaddr + CODEC_IN_PARAM); - } else if (paramInfo.apiIndex == EMUL_AV_PARSER_PARSE) { - AVCodecParserContext *parserctx; - AVCodecContext *ctx; - parserctx = (AVCodecParserContext*)paramInfo.in_args[0]; - ctx = (AVCodecContext*)paramInfo.in_args[1]; - memcpy(&tempParserCtx, parserctx, sizeof(AVCodecParserContext)); - memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); - } - - // return value - if (paramInfo.ret != 0) - writel((uint32_t)paramInfo.ret, svcodec->ioaddr + CODEC_RETURN_VALUE); - - // api index - writel((uint32_t)paramInfo.apiIndex, svcodec->ioaddr + CODEC_API_INDEX); - - /* host to guest */ - if (paramInfo.apiIndex == EMUL_AVCODEC_OPEN) { - AVCodecContext *ctx; - AVCodec *codec; - ctx = (AVCodecContext*)paramInfo.in_args[0]; - codec = (AVCodec*)paramInfo.in_args[1]; - if (ctx) { - restore_codec_context(ctx, &tempCtx); - ctx->codec = codec; - } - } else if (paramInfo.apiIndex == EMUL_AVCODEC_DECODE_VIDEO) { - AVCodecContext *ctx; - AVFrame *frame; - ctx = (AVCodecContext*)paramInfo.in_args[0]; - frame = (AVFrame*)paramInfo.in_args[1]; - restore_codec_context(ctx, &tempCtx); - ctx->coded_frame = frame; - } else if (paramInfo.apiIndex == EMUL_AVCODEC_ENCODE_VIDEO) { - uint32_t buf_size; - buf_size = *(uint32_t*)paramInfo.in_args[2]; - if (copy_to_user((void*)paramInfo.in_args[1], svcodec->imgBuf, buf_size)) { - printk(KERN_ERR "[%s]:Fail to copy_to_user\n", __func__); - } - kfree(svcodec->imgBuf); - svcodec->imgBuf = NULL; + struct _param paramInfo; + AVCodecParserContext tempParserCtx; + AVCodecContext tempCtx; + int i; + + mutex_lock(&codec_mutex); + + if (!svcodec) { + printk(KERN_ERR "[%s]:Fail to get codec device info\n", __func__); + } + + if (copy_from_user(¶mInfo, buf, sizeof(struct _param))) { + printk(KERN_ERR "[%s]:Fail to copy\n", __func__); + } + + for (i = 0; i < paramInfo.inArgsNum; i++) { + writel(paramInfo.inArgs[i], svcodec->ioaddr + CODEC_IN_PARAM); + } + + /* guest to host */ + if (paramInfo.apiIndex == EMUL_AVCODEC_OPEN) { + AVCodecContext *ctx; + + ctx = (AVCodecContext*)paramInfo.inArgs[0]; + if (ctx) { + memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); + writel((uint32_t)ctx->extradata, svcodec->ioaddr + CODEC_IN_PARAM); + } + } else if (paramInfo.apiIndex == EMUL_AVCODEC_DECODE_VIDEO) { + AVCodecContext *ctx; + + ctx = (AVCodecContext*)paramInfo.inArgs[0]; + memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); + } else if (paramInfo.apiIndex == EMUL_AVCODEC_ENCODE_VIDEO) { + AVCodecContext *ctx; + uint32_t buf_size; + + ctx = (AVCodecContext*)paramInfo.inArgs[0]; + buf_size = *(uint32_t*)paramInfo.inArgs[2]; + writel((uint32_t)ctx->coded_frame, svcodec->ioaddr + CODEC_IN_PARAM); + svcodec->imgBuf = kmalloc(buf_size, GFP_KERNEL); + writel((uint32_t)svcodec->imgBuf, svcodec->ioaddr + CODEC_IN_PARAM); } else if (paramInfo.apiIndex == EMUL_AV_PICTURE_COPY) { - int pix_fmt; - int width, height; - int size; - pix_fmt = *(int*)paramInfo.in_args[1]; - width = *(int*)paramInfo.in_args[2]; - height = *(int*)paramInfo.in_args[3]; - size = get_picture_size(pix_fmt, width, height); - if (copy_to_user((void*)paramInfo.in_args[4], svcodec->imgBuf, size)) { - printk(KERN_ERR "[%s]:Fail to copy_to_user\n", __func__); - } - kfree(svcodec->imgBuf); - svcodec->imgBuf = NULL; - } else if (paramInfo.apiIndex == EMUL_AV_PARSER_PARSE) { - AVCodecParserContext *parserctx; - AVCodecContext *ctx; - uint8_t *outbuf; - int *outbuf_size; - - parserctx = (AVCodecParserContext*)paramInfo.in_args[0]; - ctx = (AVCodecContext*)paramInfo.in_args[1]; - outbuf_size = (int*)paramInfo.in_args[3]; - parserctx->priv_data = tempParserCtx.priv_data; - parserctx->parser = tempParserCtx.parser; - restore_codec_context(ctx, &tempCtx); - } - - return 0; + int pix_fmt; + int width, height; + int size; + + pix_fmt = *(int*)paramInfo.inArgs[1]; + width = *(int*)paramInfo.inArgs[2]; + height = *(int*)paramInfo.inArgs[3]; + size = get_picture_size(pix_fmt, width, height); + svcodec->imgBuf = kmalloc(size, GFP_KERNEL); + writel((uint32_t)svcodec->imgBuf, svcodec->ioaddr + CODEC_IN_PARAM); + } else if (paramInfo.apiIndex == EMUL_AV_PARSER_PARSE) { + AVCodecParserContext *parserctx; + AVCodecContext *ctx; + + parserctx = (AVCodecParserContext*)paramInfo.inArgs[0]; + ctx = (AVCodecContext*)paramInfo.inArgs[1]; + memcpy(&tempParserCtx, parserctx, sizeof(AVCodecParserContext)); + memcpy(&tempCtx, ctx, sizeof(AVCodecContext)); + } + + /* return value */ + if (paramInfo.ret != 0) { + writel((uint32_t)paramInfo.ret, svcodec->ioaddr + CODEC_RETURN_VALUE); + } + + /* context index */ + writel((uint32_t)paramInfo.ctxIndex, svcodec->ioaddr + CODEC_CONTEXT_INDEX); + + /* api index */ + writel((uint32_t)paramInfo.apiIndex, svcodec->ioaddr + CODEC_API_INDEX); + + /* host to guest */ + if (paramInfo.apiIndex == EMUL_AVCODEC_OPEN) { + AVCodecContext *ctx; + AVCodec *codec; + ctx = (AVCodecContext*)paramInfo.inArgs[0]; + codec = (AVCodec*)paramInfo.inArgs[1]; + if (ctx) { + restore_codec_context(ctx, &tempCtx); + ctx->codec = codec; + } + } else if (paramInfo.apiIndex == EMUL_AVCODEC_DECODE_VIDEO) { + AVCodecContext *ctx; + AVFrame *frame; + ctx = (AVCodecContext*)paramInfo.inArgs[0]; + frame = (AVFrame*)paramInfo.inArgs[1]; + restore_codec_context(ctx, &tempCtx); + ctx->coded_frame = frame; + } else if (paramInfo.apiIndex == EMUL_AVCODEC_ENCODE_VIDEO) { + uint32_t buf_size; + buf_size = *(uint32_t*)paramInfo.inArgs[2]; + if (copy_to_user((void*)paramInfo.inArgs[1], svcodec->imgBuf, buf_size)) { + printk(KERN_ERR "[%s]:Fail to copy_to_user\n", __func__); + } + kfree(svcodec->imgBuf); + svcodec->imgBuf = NULL; + } else if (paramInfo.apiIndex == EMUL_AV_PICTURE_COPY) { + int pix_fmt; + int width, height; + int size; + pix_fmt = *(int*)paramInfo.inArgs[1]; + width = *(int*)paramInfo.inArgs[2]; + height = *(int*)paramInfo.inArgs[3]; + size = get_picture_size(pix_fmt, width, height); + if (copy_to_user((void*)paramInfo.inArgs[4], svcodec->imgBuf, size)) { + printk(KERN_ERR "[%s]:Fail to copy_to_user\n", __func__); + } + kfree(svcodec->imgBuf); + svcodec->imgBuf = NULL; + } else if (paramInfo.apiIndex == EMUL_AV_PARSER_PARSE) { + AVCodecParserContext *parserctx; + AVCodecContext *ctx; + uint8_t *outbuf; + int *outbuf_size; + + parserctx = (AVCodecParserContext*)paramInfo.inArgs[0]; + ctx = (AVCodecContext*)paramInfo.inArgs[1]; + outbuf_size = (int*)paramInfo.inArgs[3]; + parserctx->priv_data = tempParserCtx.priv_data; + parserctx->parser = tempParserCtx.parser; + restore_codec_context(ctx, &tempCtx); + } + + mutex_unlock(&codec_mutex); + + return 0; } -#else +#else +/* Copy data between guest and host using mmap operation. */ static ssize_t svcodec_write (struct file *file, const char __user *buf, - size_t count, loff_t *fops) + size_t count, loff_t *fops) { - struct _param paramInfo; + struct _param paramInfo; + + mutex_lock(&codec_mutex); + + if (!svcodec) { + printk(KERN_ERR "[%s]:Fail to get codec device info\n", __func__); + } + + if (copy_from_user(¶mInfo, buf, sizeof(struct _param))) { + printk(KERN_ERR "[%s]:Fail to get codec parameter info from user\n", __func__); + } + +#if 0 + if (paramInfo.apiIndex == EMUL_INIT_MMAP_INDEX) { + int i; + if (svcodec->useMmap[USABLE_MMAP_MAX_SIZE] == 0) { + for (i = 0; i < USABLE_MMAP_MAX_SIZE; i++) { + svcodec->useMmap[i] = 1; + printk(KERN_DEBUG "Reset useMmap[%d]=%d\n", i, svcodec->useMmap[i]); + } + } + return 0; + } +#endif - if (!svcodec) { - printk(KERN_ERR "[%s]:Fail to get codec device info\n", __func__); - } + if (paramInfo.apiIndex == EMUL_GET_MMAP_INDEX) { + int i; + int *mmapIndex; + + mmapIndex = (int*)paramInfo.ret; + + printk(KERN_DEBUG "[%s] before available useMmap count:%d\n", + __func__, (USABLE_MMAP_MAX_SIZE - svcodec->useMmap[USABLE_MMAP_MAX_SIZE])); + for (i = 0; i < USABLE_MMAP_MAX_SIZE; i++) { + printk(KERN_DEBUG "useMmap[%d]=%d\n", i, svcodec->useMmap[i]); + if (svcodec->useMmap[i] == 1) { + svcodec->useMmap[i] = 0; + printk(KERN_DEBUG "useMmap[%d]=%d\n", i, svcodec->useMmap[i]); + (svcodec->useMmap[USABLE_MMAP_MAX_SIZE])++; + file->private_data = &svcodec->useMmap[i]; + printk(KERN_DEBUG "[%s] after available useMmap count:%d\n", + __func__, (USABLE_MMAP_MAX_SIZE - svcodec->useMmap[USABLE_MMAP_MAX_SIZE])); + printk(KERN_DEBUG "[%s] return %d as the index of mmap\n", __func__, i); + + break; + } + } + + if (i == USABLE_MMAP_MAX_SIZE) { + printk(KERN_INFO "[%s] Usable mmap is none\n", __func__); + i = -1; + } +#if 0 + else { + svcodec->useMmap[i] = 0; + (svcodec->useMmap[USABLE_MMAP_MAX_SIZE])++; + printk(KERN_DEBUG "[%s] available useMmap count:%d\n", + __func__, (USABLE_MMAP_MAX_SIZE - svcodec->useMmap[USABLE_MMAP_MAX_SIZE])); + printk(KERN_DEBUG "[%s] useMmap[%d]=%d\n", __func__, i, svcodec->useMmap[i]); + } +#endif - if (copy_from_user(¶mInfo, buf, sizeof(struct _param))) { - printk(KERN_ERR "[%s]:Fail to get codec parameter info from user\n", __func__); - } + if (copy_to_user((void*)mmapIndex, &i, sizeof(int))) { + printk(KERN_ERR "[%s]:Fail to copy_to_user\n", __func__); + } + mutex_unlock(&codec_mutex); - writel((uint32_t)paramInfo.apiIndex, svcodec->ioaddr + CODEC_API_INDEX); + return 0; + } - return 0; -} +#if 0 + else if (paramInfo.apiIndex == EMUL_RESET_MMAP_INDEX) { + int index; + index = paramInfo.mmapOffset; + svcodec->useMmap[index] = 1; + printk(KERN_DEBUG "useMmap[%d] is available from now\n", index); + mutex_unlock(&codec_mutex); + + return 0; + } #endif -static ssize_t svcodec_read (struct file *file, char __user *buf, - size_t count, loff_t *fops) -{ - SVCODEC_LOG("\n"); - if (!svcodec) { - printk(KERN_ERR "[%s] : Fail to get codec device info\n", __func__); + if (paramInfo.apiIndex == EMUL_AVCODEC_ALLOC_CONTEXT) { + writel((uint32_t)file, svcodec->ioaddr + CODEC_FILE_INDEX); } - return 0; -} -static int svcodec_mmap (struct file *file, struct vm_area_struct *vm) -{ - unsigned long off; - unsigned long phys_addr; - unsigned long size; - int ret = -1; - - off = vm->vm_pgoff << PAGE_SHIFT; - phys_addr = (PAGE_ALIGN(svcodec->mem_start) + off) >> PAGE_SHIFT; - size = vm->vm_end - vm->vm_start; - printk(KERN_DEBUG "svcodec_mmap\n"); - - if (size > svcodec->mem_size) { - printk(KERN_ERR "Over mapping size\n"); - return -EINVAL; - } + writel((uint32_t)paramInfo.ctxIndex, svcodec->ioaddr + CODEC_CONTEXT_INDEX); - ret = remap_pfn_range(vm, vm->vm_start, phys_addr, size, vm->vm_page_prot); - if (ret < 0) { - printk(KERN_ERR "Failed to remap page range\n"); - return -EAGAIN; - } + writel((uint32_t)paramInfo.mmapOffset, svcodec->ioaddr + CODEC_MMAP_OFFSET); - vm->vm_flags |= VM_IO; - vm->vm_flags |= VM_RESERVED; + writel((uint32_t)paramInfo.apiIndex, svcodec->ioaddr + CODEC_API_INDEX); - return 0; + mutex_unlock(&codec_mutex); + + return 0; } +#endif -static int svcodec_release (struct inode *inode, struct file *file) +static ssize_t svcodec_read (struct file *file, char __user *buf, + size_t count, loff_t *fops) { - printk(KERN_DEBUG "[%s]\n", __func__); - if (svcodec->imgBuf) { - kfree(svcodec->imgBuf); - svcodec->imgBuf = NULL; - printk(KERN_DEBUG "[%s]release codec device module\n", __func__); - } - module_put(THIS_MODULE); - return 0; + if (!svcodec) { + printk(KERN_ERR "[%s] : Fail to get codec device info\n", __func__); + } + return 0; } -struct file_operations svcodec_fops = { - .owner = THIS_MODULE, - .read = svcodec_read, - .write = svcodec_write, - .open = svcodec_open, - .mmap = svcodec_mmap, - .release = svcodec_release, -}; +static int svcodec_mmap (struct file *file, struct vm_area_struct *vm) +{ + unsigned long off; + unsigned long phys_addr; + unsigned long size; + int ret = -1; + + off = vm->vm_pgoff << PAGE_SHIFT; + phys_addr = (PAGE_ALIGN(svcodec->mem_start) + off) >> PAGE_SHIFT; + size = vm->vm_end - vm->vm_start; + printk(KERN_DEBUG "svcodec_mmap\n"); + + if (size > svcodec->mem_size) { + printk(KERN_ERR "Over mapping size\n"); + return -EINVAL; + } + + ret = remap_pfn_range(vm, vm->vm_start, phys_addr, size, vm->vm_page_prot); + if (ret < 0) { + printk(KERN_ERR "Failed to remap page range\n"); + return -EAGAIN; + } + + vm->vm_flags |= VM_IO; + vm->vm_flags |= VM_RESERVED; + + return 0; +} -static void __devinit svcodec_remove (struct pci_dev *pci_dev) +static int svcodec_open (struct inode *inode, struct file *file) { - if (svcodec) { - if (svcodec->ioaddr) { - iounmap(svcodec->ioaddr); - svcodec->ioaddr = 0; - } + int i; - if (svcodec->memaddr) { - iounmap(svcodec->memaddr); - svcodec->memaddr = 0; - } + mutex_lock(&codec_mutex); - if (svcodec->io_start) { - release_mem_region(svcodec->io_start, svcodec->io_size); - svcodec->io_start = 0; - } + printk(KERN_DEBUG "[%s]\n", __func__); + printk(KERN_DEBUG "[%s] struct file :%p\n", __func__, file); - if (svcodec->mem_start) { - release_mem_region(svcodec->mem_start, svcodec->mem_size); - svcodec->mem_start = 0; + if (svcodec->useMmap[USABLE_MMAP_MAX_SIZE] == 0) { + for (i = 0; i < USABLE_MMAP_MAX_SIZE; i++) { + svcodec->useMmap[i] = 1; + printk(KERN_DEBUG "Reset useMmap[%d]=%d\n", i, svcodec->useMmap[i]); } - - kfree(svcodec); } - pci_disable_device(pci_dev); + + try_module_get(THIS_MODULE); + mutex_unlock(&codec_mutex); + + return 0; } -static int __devinit svcodec_probe (struct pci_dev *pci_dev, - const struct pci_device_id *pci_id) +static int svcodec_release (struct inode *inode, struct file *file) { - int ret; + int max_size = USABLE_MMAP_MAX_SIZE; - svcodec = (svcodec_dev*)kmalloc(sizeof(svcodec_dev), GFP_KERNEL); - memset(svcodec, 0x00, sizeof(svcodec_dev)); + mutex_lock(&codec_mutex); - svcodec->dev = pci_dev; + printk(KERN_DEBUG "[%s] close %s\n", __func__, DRIVER_NAME); +#ifdef CODEC_HOST + if (svcodec->imgBuf) { + kfree(svcodec->imgBuf); + svcodec->imgBuf = NULL; + printk(KERN_DEBUG "[%s]release codec device module\n", __func__); + } +#endif - if (pci_enable_device(pci_dev)) { - printk(KERN_ERR "[%s] : pci_enable_device failed\n", __func__); - goto err_rel; - } + (svcodec->useMmap[max_size])--; + *(uint8_t*)file->private_data = 1; + printk(KERN_DEBUG "[%s] available useMmap count:%d\n", + __func__, (max_size - svcodec->useMmap[max_size])); - pci_set_master(pci_dev); + /* notify qemu of closing codec device. */ + printk(KERN_DEBUG "[%s] struct file : %p\n", __func__, file); + writel((uint32_t)file, svcodec->ioaddr + CODEC_CLOSED); - ret = -EIO; +#ifdef CODEC_DEBUG + int i; + for (i = 0; i < max_size; i++) { + printk(KERN_DEBUG "useMmap[%d]=%d\n", i, svcodec->useMmap[i]); + } +#endif + module_put(THIS_MODULE); - svcodec->mem_start = pci_resource_start(pci_dev, 0); - svcodec->mem_size = pci_resource_len(pci_dev, 0); + mutex_unlock(&codec_mutex); - if (!svcodec->mem_start) { - printk(KERN_ERR "[%s] : pci_resource_start failed\n", __func__); - goto err_out; - } - - if (!request_mem_region(svcodec->mem_start, svcodec->mem_size, DRIVER_NAME)) { - printk(KERN_ERR "[%s] : request_mem_region failed\n", __func__); - goto err_out; - } + return 0; +} - svcodec->io_start = pci_resource_start(pci_dev, 1); - svcodec->io_size = pci_resource_len(pci_dev, 1); +struct file_operations svcodec_fops = { + .owner = THIS_MODULE, + .read = svcodec_read, + .write = svcodec_write, + .open = svcodec_open, + .mmap = svcodec_mmap, + .release = svcodec_release, +}; - if (!svcodec->io_start) { - printk(KERN_ERR "[%s] : pci_resource_start failed\n", __func__); - goto err_mem_region; - } +static void __devinit svcodec_remove (struct pci_dev *pci_dev) +{ + if (svcodec) { + if (svcodec->ioaddr) { + iounmap(svcodec->ioaddr); + svcodec->ioaddr = 0; + } + +#if 0 + if (svcodec->memaddr) { + iounmap(svcodec->memaddr); + svcodec->memaddr = 0; + } +#endif - if (!request_mem_region(svcodec->io_start, svcodec->io_size, DRIVER_NAME)) { - printk(KERN_ERR "[%s] : request_io_region failed\n", __func__); - goto err_mem_region; - } + if (svcodec->io_start) { + release_mem_region(svcodec->io_start, svcodec->io_size); + svcodec->io_start = 0; + } - svcodec->memaddr = ioremap(svcodec->mem_start, svcodec->mem_size); - if (!svcodec->memaddr) { - printk(KERN_ERR "[%s] : ioremap failed\n", __func__); - goto err_io_region; - } + if (svcodec->mem_start) { + release_mem_region(svcodec->mem_start, svcodec->mem_size); + svcodec->mem_start = 0; + } - svcodec->ioaddr = ioremap_nocache(svcodec->io_start, svcodec->io_size); - if (!svcodec->ioaddr) { - printk(KERN_ERR "[%s] : ioremap failed\n", __func__); - goto err_mem_unmap; - } - if (register_chrdev(CODEC_MAJOR, DRIVER_NAME, &svcodec_fops)) { - printk(KERN_ERR "[%s] : register_chrdev failed\n", __func__); - goto err_io_unmap; - } + kfree(svcodec); + } + pci_disable_device(pci_dev); +} - return 0; +static int __devinit svcodec_probe (struct pci_dev *pci_dev, + const struct pci_device_id *pci_id) +{ + int ret; + + svcodec = (svcodec_dev*)kmalloc(sizeof(svcodec_dev), GFP_KERNEL); + memset(svcodec, 0x00, sizeof(svcodec_dev)); + + svcodec->dev = pci_dev; + + if (pci_enable_device(pci_dev)) { + printk(KERN_ERR "[%s] : pci_enable_device failed\n", __func__); + goto err_rel; + } + + pci_set_master(pci_dev); + + ret = -EIO; + + svcodec->mem_start = pci_resource_start(pci_dev, 0); + svcodec->mem_size = pci_resource_len(pci_dev, 0); + + if (!svcodec->mem_start) { + printk(KERN_ERR "[%s] : pci_resource_start failed\n", __func__); + goto err_out; + } + + if (!request_mem_region(svcodec->mem_start, svcodec->mem_size, DRIVER_NAME)) { + printk(KERN_ERR "[%s] : request_mem_region failed\n", __func__); + goto err_out; + } + + svcodec->io_start = pci_resource_start(pci_dev, 1); + svcodec->io_size = pci_resource_len(pci_dev, 1); + + if (!svcodec->io_start) { + printk(KERN_ERR "[%s] : pci_resource_start failed\n", __func__); + goto err_mem_region; + } + + if (!request_mem_region(svcodec->io_start, svcodec->io_size, DRIVER_NAME)) { + printk(KERN_ERR "[%s] : request_io_region failed\n", __func__); + goto err_mem_region; + } + +#if 0 + svcodec->memaddr = ioremap(svcodec->mem_start, svcodec->mem_size); + if (!svcodec->memaddr) { + printk(KERN_ERR "[%s] : ioremap failed\n", __func__); + goto err_io_region; + } +#endif + + svcodec->ioaddr = ioremap_nocache(svcodec->io_start, svcodec->io_size); + if (!svcodec->ioaddr) { + printk(KERN_ERR "[%s] : ioremap failed\n", __func__); + goto err_io_region; + } + if (register_chrdev(CODEC_MAJOR, DRIVER_NAME, &svcodec_fops)) { + printk(KERN_ERR "[%s] : register_chrdev failed\n", __func__); + goto err_io_unmap; + } + + return 0; err_io_unmap: - iounmap(svcodec->ioaddr); + iounmap(svcodec->ioaddr); +#if 0 err_mem_unmap: - iounmap(svcodec->memaddr); + iounmap(svcodec->memaddr); +#endif err_io_region: - release_mem_region(svcodec->io_start, svcodec->io_size); + release_mem_region(svcodec->io_start, svcodec->io_size); err_mem_region: - release_mem_region(svcodec->mem_start, svcodec->mem_size); + release_mem_region(svcodec->mem_start, svcodec->mem_size); err_out: - pci_disable_device(pci_dev); + pci_disable_device(pci_dev); err_rel: - return ret; + return ret; } static struct pci_driver driver = { - .name = DRIVER_NAME, - .id_table = svcodec_pci_table, - .probe = svcodec_probe, - .remove = svcodec_remove, + .name = DRIVER_NAME, + .id_table = svcodec_pci_table, + .probe = svcodec_probe, + .remove = svcodec_remove, }; static int __init svcodec_init (void) { - printk(KERN_INFO "svcodec device is initialized.\n"); - return pci_register_driver(&driver); + printk(KERN_INFO "marucodec device is initialized.\n"); + return pci_register_driver(&driver); } static void __exit svcodec_exit (void) { - pci_unregister_driver(&driver); + pci_unregister_driver(&driver); } module_init(svcodec_init); module_exit(svcodec_exit); diff --git a/drivers/maru/maru_fb.c b/drivers/maru/maru_fb.c index 781fe1596bea..31a024530ca7 100644 --- a/drivers/maru/maru_fb.c +++ b/drivers/maru/maru_fb.c @@ -309,7 +309,7 @@ static int my_atoi(const char *name) } extern char *saved_command_line; -#define DPI_DEF_VALUE 3200 +#define DPI_DEF_VALUE 3160 #define DPI_MIN_VALUE 1000 #define DPI_MAX_VALUE 4800 @@ -336,12 +336,12 @@ static void uvesafb_setup_var(struct fb_var_screeninfo *var, if (dpi < DPI_MIN_VALUE || dpi > DPI_MAX_VALUE) dpi = DPI_DEF_VALUE; } - - var->height = (var->yres * 254 / dpi); - var->width = (var->xres * 254 / dpi); - //printk(KERN_INFO "dpi value = %d\n", dpi); - //printk(KERN_INFO "var->yres = %d, var->xres = %d\n", var->yres, var->xres); - //printk(KERN_INFO "var->height = %d, var->width = %d\n", var->height, var->width); + /* round up */ + var->height = ((var->yres * 2540 / dpi) + 5) / 10; + var->width = ((var->xres * 2540 / dpi)+ 5) / 10; +// printk(KERN_INFO "dpi value = %d\n", dpi); +// printk(KERN_INFO "var->yres = %d, var->xres = %d\n", var->yres, var->xres); +// printk(KERN_INFO "var->height = %d, var->width = %d\n", var->height, var->width); var->xres_virtual = mode->x_res; var->yres_virtual = (par->ypan) ? diff --git a/drivers/maru/maru_power_supply.c b/drivers/maru/maru_power_supply.c index 54ab5b4ff759..b63d02a3f2bd 100644 --- a/drivers/maru/maru_power_supply.c +++ b/drivers/maru/maru_power_supply.c @@ -36,41 +36,55 @@ static int capacity = 100; static int charge_full = 1; static int charge_now = 0; +//#define DEBUG_MARU_POWER_SUPPLY + static ssize_t show_capacity(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif return snprintf(buf, PAGE_SIZE, "%d", capacity); } static ssize_t store_capacity(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif sscanf(buf, "%d", &capacity); return strnlen(buf, PAGE_SIZE); } static ssize_t show_charge_full(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif return snprintf(buf, PAGE_SIZE, "%d", charge_full); } static ssize_t store_charge_full(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif sscanf(buf, "%d", &charge_full); return strnlen(buf, PAGE_SIZE); } static ssize_t show_charge_now(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif return snprintf(buf, PAGE_SIZE, "%d", charge_now); } static ssize_t store_charge_now(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef DEBUG_MARU_POWER_SUPPLY printk("[%s] \n", __FUNCTION__); +#endif sscanf(buf, "%d", &charge_now); return strnlen(buf, PAGE_SIZE); } diff --git a/include/linux/input/sec-input-bridge.h b/include/linux/input/sec-input-bridge.h new file mode 100644 index 000000000000..cf0ef836cf43 --- /dev/null +++ b/include/linux/input/sec-input-bridge.h @@ -0,0 +1,31 @@ +#ifndef LINUX_INPUT_SEC_INPUT_BRIDGE_H +#define LINUX_INPUT_SEC_INPUT_BRIDGE_H + +#include + +enum mkey_check_option { + MKEY_CHECK_AUTO, + MKEY_CHECK_AWAYS +}; + +struct sec_input_bridge_mkey { + unsigned int type; + unsigned int code; + enum mkey_check_option option; +}; + +struct sec_input_bridge_platform_data { + void (*pre_event_func)(void *event_data); + void *event_data; + + const struct sec_input_bridge_mkey *mkey_map; + unsigned int num_mkey; + + unsigned char send_uevent; + enum kobject_action uevent_action; + const char *uevent_env_str; + const char *uevent_env_value; +}; + +#endif /* LINUX_INPUT_SEC_INPUT_BRIDGE_H */ + diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h old mode 100644 new mode 100755 index e588758f1ace..afb7f59e5108 --- a/include/linux/virtio_ids.h +++ b/include/linux/virtio_ids.h @@ -12,6 +12,7 @@ #define VIRTIO_ID_CONSOLE 3 /* virtio console */ #define VIRTIO_ID_RNG 4 /* virtio ring */ #define VIRTIO_ID_BALLOON 5 /* virtio balloon */ +#define VIRTIO_ID_GL 6 /* virtio usermem */ #define VIRTIO_ID_9P 9 /* 9p virtio console */ #define VIRTIO_ID_GPI 20 /* virtio general purpose interface */ diff --git a/kernel/power/main.c b/kernel/power/main.c index 347d2cc88cd0..db758dc397da 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -146,6 +146,8 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { +#if 0 // do not allow suspend in emulator + #ifdef CONFIG_SUSPEND suspend_state_t state = PM_SUSPEND_STANDBY; const char * const *s; @@ -174,6 +176,11 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, Exit: return error ? error : n; +#else + + return n; + +#endif // do not allow suspend in emulator } power_attr(state); diff --git a/kernel/sys.c b/kernel/sys.c index ce17760d9c51..7c9cfdcd84c7 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1120,11 +1120,23 @@ DECLARE_RWSEM(uts_sem); SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) { int errno = 0; +#ifdef CONFIG_MARU + struct new_utsname u; + down_read(&uts_sem); + memcpy(&u, utsname(), sizeof *name); + up_read(&uts_sem); + + strcat(u.machine, "_emulated"); + + if (copy_to_user(name, &u, sizeof *name)) + errno = -EFAULT; +#else down_read(&uts_sem); if (copy_to_user(name, utsname(), sizeof *name)) errno = -EFAULT; up_read(&uts_sem); +#endif return errno; } diff --git a/net/9p/client.c b/net/9p/client.c index 8af95b2dddd6..d37e2ee07631 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -191,6 +191,8 @@ static struct p9_req_t *p9_tag_alloc(struct p9_client *c, u16 tag) req->wq = NULL; return ERR_PTR(-ENOMEM); } + memset(req->tc, 0, sizeof(struct p9_fcall)); + memset(req->rc, 0, sizeof(struct p9_fcall)); req->tc->sdata = (char *) req->tc + sizeof(struct p9_fcall); req->tc->capacity = c->msize; req->rc->sdata = (char *) req->rc + sizeof(struct p9_fcall); @@ -663,6 +665,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) if (!clnt) return ERR_PTR(-ENOMEM); + memset(clnt, 0, sizeof(struct p9_client)); clnt->trans_mod = NULL; clnt->trans = NULL; spin_lock_init(&clnt->lock); diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index ea1e3daabefe..c7a02dfd9e41 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -101,6 +101,9 @@ static void p9_virtio_close(struct p9_client *client) { struct virtio_chan *chan = client->trans; + if (!chan) + return ; + mutex_lock(&virtio_9p_lock); chan->inuse = false; mutex_unlock(&virtio_9p_lock); diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 1711f921dfe1..1136c88f43f2 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Package: emulator-kernel -Version: 1.1.4 +Version: 1.1.15 OS: linux Build-host-os: linux Maintainer: Yeong-Kyoon, Lee @@ -7,7 +7,7 @@ Source: emulator-kernel Description: Tizen Emulator Kernel Package: emulator-kernel -Version: 1.1.4 +Version: 1.1.15 OS: windows Build-host-os: linux Maintainer: Yeong-Kyoon, Lee -- 2.34.1