diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/binder.c linux-2.6.32-rc6-staging/drivers/staging/android/binder.c --- linux-2.6.32-rc6-usb/drivers/staging/android/binder.c 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/android/binder.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,3767 +0,0 @@ -/* binder.c - * - * Android IPC Subsystem - * - * Copyright (C) 2007-2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "binder.h" - -static DEFINE_MUTEX(binder_lock); -static DEFINE_MUTEX(binder_deferred_lock); - -static HLIST_HEAD(binder_procs); -static HLIST_HEAD(binder_deferred_list); -static HLIST_HEAD(binder_dead_nodes); - -static struct proc_dir_entry *binder_proc_dir_entry_root; -static struct proc_dir_entry *binder_proc_dir_entry_proc; -static struct binder_node *binder_context_mgr_node; -static uid_t binder_context_mgr_uid = -1; -static int binder_last_id; - -static int binder_read_proc_proc(char *page, char **start, off_t off, - int count, int *eof, void *data); - -/* This is only defined in include/asm-arm/sizes.h */ -#ifndef SZ_1K -#define SZ_1K 0x400 -#endif - -#ifndef SZ_4M -#define SZ_4M 0x400000 -#endif - -#define FORBIDDEN_MMAP_FLAGS (VM_WRITE) - -#define BINDER_SMALL_BUF_SIZE (PAGE_SIZE * 64) - -enum { - BINDER_DEBUG_USER_ERROR = 1U << 0, - BINDER_DEBUG_FAILED_TRANSACTION = 1U << 1, - BINDER_DEBUG_DEAD_TRANSACTION = 1U << 2, - BINDER_DEBUG_OPEN_CLOSE = 1U << 3, - BINDER_DEBUG_DEAD_BINDER = 1U << 4, - BINDER_DEBUG_DEATH_NOTIFICATION = 1U << 5, - BINDER_DEBUG_READ_WRITE = 1U << 6, - BINDER_DEBUG_USER_REFS = 1U << 7, - BINDER_DEBUG_THREADS = 1U << 8, - BINDER_DEBUG_TRANSACTION = 1U << 9, - BINDER_DEBUG_TRANSACTION_COMPLETE = 1U << 10, - BINDER_DEBUG_FREE_BUFFER = 1U << 11, - BINDER_DEBUG_INTERNAL_REFS = 1U << 12, - BINDER_DEBUG_BUFFER_ALLOC = 1U << 13, - BINDER_DEBUG_PRIORITY_CAP = 1U << 14, - BINDER_DEBUG_BUFFER_ALLOC_ASYNC = 1U << 15, -}; -static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR | - BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; -module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO); - -static int binder_debug_no_lock; -module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO); - -static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); -static int binder_stop_on_user_error; - -static int binder_set_stop_on_user_error(const char *val, - struct kernel_param *kp) -{ - int ret; - ret = param_set_int(val, kp); - if (binder_stop_on_user_error < 2) - wake_up(&binder_user_error_wait); - return ret; -} -module_param_call(stop_on_user_error, binder_set_stop_on_user_error, - param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO); - -#define binder_debug(mask, x...) \ - do { \ - if (binder_debug_mask & mask) \ - printk(KERN_INFO x); \ - } while (0) - -#define binder_user_error(x...) \ - do { \ - if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \ - printk(KERN_INFO x); \ - if (binder_stop_on_user_error) \ - binder_stop_on_user_error = 2; \ - } while (0) - -enum binder_stat_types { - BINDER_STAT_PROC, - BINDER_STAT_THREAD, - BINDER_STAT_NODE, - BINDER_STAT_REF, - BINDER_STAT_DEATH, - BINDER_STAT_TRANSACTION, - BINDER_STAT_TRANSACTION_COMPLETE, - BINDER_STAT_COUNT -}; - -struct binder_stats { - int br[_IOC_NR(BR_FAILED_REPLY) + 1]; - int bc[_IOC_NR(BC_DEAD_BINDER_DONE) + 1]; - int obj_created[BINDER_STAT_COUNT]; - int obj_deleted[BINDER_STAT_COUNT]; -}; - -static struct binder_stats binder_stats; - -static inline void binder_stats_deleted(enum binder_stat_types type) -{ - binder_stats.obj_deleted[type]++; -} - -static inline void binder_stats_created(enum binder_stat_types type) -{ - binder_stats.obj_created[type]++; -} - -struct binder_transaction_log_entry { - int debug_id; - int call_type; - int from_proc; - int from_thread; - int target_handle; - int to_proc; - int to_thread; - int to_node; - int data_size; - int offsets_size; -}; -struct binder_transaction_log { - int next; - int full; - struct binder_transaction_log_entry entry[32]; -}; -static struct binder_transaction_log binder_transaction_log; -static struct binder_transaction_log binder_transaction_log_failed; - -static struct binder_transaction_log_entry *binder_transaction_log_add( - struct binder_transaction_log *log) -{ - struct binder_transaction_log_entry *e; - e = &log->entry[log->next]; - memset(e, 0, sizeof(*e)); - log->next++; - if (log->next == ARRAY_SIZE(log->entry)) { - log->next = 0; - log->full = 1; - } - return e; -} - -struct binder_work { - struct list_head entry; - enum { - BINDER_WORK_TRANSACTION = 1, - BINDER_WORK_TRANSACTION_COMPLETE, - BINDER_WORK_NODE, - BINDER_WORK_DEAD_BINDER, - BINDER_WORK_DEAD_BINDER_AND_CLEAR, - BINDER_WORK_CLEAR_DEATH_NOTIFICATION, - } type; -}; - -struct binder_node { - int debug_id; - struct binder_work work; - union { - struct rb_node rb_node; - struct hlist_node dead_node; - }; - struct binder_proc *proc; - struct hlist_head refs; - int internal_strong_refs; - int local_weak_refs; - int local_strong_refs; - void __user *ptr; - void __user *cookie; - unsigned has_strong_ref:1; - unsigned pending_strong_ref:1; - unsigned has_weak_ref:1; - unsigned pending_weak_ref:1; - unsigned has_async_transaction:1; - unsigned accept_fds:1; - unsigned min_priority:8; - struct list_head async_todo; -}; - -struct binder_ref_death { - struct binder_work work; - void __user *cookie; -}; - -struct binder_ref { - /* Lookups needed: */ - /* node + proc => ref (transaction) */ - /* desc + proc => ref (transaction, inc/dec ref) */ - /* node => refs + procs (proc exit) */ - int debug_id; - struct rb_node rb_node_desc; - struct rb_node rb_node_node; - struct hlist_node node_entry; - struct binder_proc *proc; - struct binder_node *node; - uint32_t desc; - int strong; - int weak; - struct binder_ref_death *death; -}; - -struct binder_buffer { - struct list_head entry; /* free and allocated entries by addesss */ - struct rb_node rb_node; /* free entry by size or allocated entry */ - /* by address */ - unsigned free:1; - unsigned allow_user_free:1; - unsigned async_transaction:1; - unsigned debug_id:29; - - struct binder_transaction *transaction; - - struct binder_node *target_node; - size_t data_size; - size_t offsets_size; - uint8_t data[0]; -}; - -enum binder_deferred_state { - BINDER_DEFERRED_PUT_FILES = 0x01, - BINDER_DEFERRED_FLUSH = 0x02, - BINDER_DEFERRED_RELEASE = 0x04, -}; - -struct binder_proc { - struct hlist_node proc_node; - struct rb_root threads; - struct rb_root nodes; - struct rb_root refs_by_desc; - struct rb_root refs_by_node; - int pid; - struct vm_area_struct *vma; - struct task_struct *tsk; - struct files_struct *files; - struct hlist_node deferred_work_node; - int deferred_work; - void *buffer; - ptrdiff_t user_buffer_offset; - - struct list_head buffers; - struct rb_root free_buffers; - struct rb_root allocated_buffers; - size_t free_async_space; - - struct page **pages; - size_t buffer_size; - uint32_t buffer_free; - struct list_head todo; - wait_queue_head_t wait; - struct binder_stats stats; - struct list_head delivered_death; - int max_threads; - int requested_threads; - int requested_threads_started; - int ready_threads; - long default_priority; -}; - -enum { - BINDER_LOOPER_STATE_REGISTERED = 0x01, - BINDER_LOOPER_STATE_ENTERED = 0x02, - BINDER_LOOPER_STATE_EXITED = 0x04, - BINDER_LOOPER_STATE_INVALID = 0x08, - BINDER_LOOPER_STATE_WAITING = 0x10, - BINDER_LOOPER_STATE_NEED_RETURN = 0x20 -}; - -struct binder_thread { - struct binder_proc *proc; - struct rb_node rb_node; - int pid; - int looper; - struct binder_transaction *transaction_stack; - struct list_head todo; - uint32_t return_error; /* Write failed, return error code in read buf */ - uint32_t return_error2; /* Write failed, return error code in read */ - /* buffer. Used when sending a reply to a dead process that */ - /* we are also waiting on */ - wait_queue_head_t wait; - struct binder_stats stats; -}; - -struct binder_transaction { - int debug_id; - struct binder_work work; - struct binder_thread *from; - struct binder_transaction *from_parent; - struct binder_proc *to_proc; - struct binder_thread *to_thread; - struct binder_transaction *to_parent; - unsigned need_reply:1; - /* unsigned is_dead:1; */ /* not used at the moment */ - - struct binder_buffer *buffer; - unsigned int code; - unsigned int flags; - long priority; - long saved_priority; - uid_t sender_euid; -}; - -static void -binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer); - -/* - * copied from get_unused_fd_flags - */ -int task_get_unused_fd_flags(struct binder_proc *proc, int flags) -{ - struct files_struct *files = proc->files; - int fd, error; - struct fdtable *fdt; - unsigned long rlim_cur; - unsigned long irqs; - - if (files == NULL) - return -ESRCH; - - error = -EMFILE; - spin_lock(&files->file_lock); - -repeat: - fdt = files_fdtable(files); - fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, - files->next_fd); - - /* - * N.B. For clone tasks sharing a files structure, this test - * will limit the total number of files that can be opened. - */ - rlim_cur = 0; - if (lock_task_sighand(proc->tsk, &irqs)) { - rlim_cur = proc->tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur; - unlock_task_sighand(proc->tsk, &irqs); - } - if (fd >= rlim_cur) - goto out; - - /* Do we need to expand the fd array or fd set? */ - error = expand_files(files, fd); - if (error < 0) - goto out; - - if (error) { - /* - * If we needed to expand the fs array we - * might have blocked - try again. - */ - error = -EMFILE; - goto repeat; - } - - FD_SET(fd, fdt->open_fds); - if (flags & O_CLOEXEC) - FD_SET(fd, fdt->close_on_exec); - else - FD_CLR(fd, fdt->close_on_exec); - files->next_fd = fd + 1; -#if 1 - /* Sanity check */ - if (fdt->fd[fd] != NULL) { - printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd); - fdt->fd[fd] = NULL; - } -#endif - error = fd; - -out: - spin_unlock(&files->file_lock); - return error; -} - -/* - * copied from fd_install - */ -static void task_fd_install( - struct binder_proc *proc, unsigned int fd, struct file *file) -{ - struct files_struct *files = proc->files; - struct fdtable *fdt; - - if (files == NULL) - return; - - spin_lock(&files->file_lock); - fdt = files_fdtable(files); - BUG_ON(fdt->fd[fd] != NULL); - rcu_assign_pointer(fdt->fd[fd], file); - spin_unlock(&files->file_lock); -} - -/* - * copied from __put_unused_fd in open.c - */ -static void __put_unused_fd(struct files_struct *files, unsigned int fd) -{ - struct fdtable *fdt = files_fdtable(files); - __FD_CLR(fd, fdt->open_fds); - if (fd < files->next_fd) - files->next_fd = fd; -} - -/* - * copied from sys_close - */ -static long task_close_fd(struct binder_proc *proc, unsigned int fd) -{ - struct file *filp; - struct files_struct *files = proc->files; - struct fdtable *fdt; - int retval; - - if (files == NULL) - return -ESRCH; - - spin_lock(&files->file_lock); - fdt = files_fdtable(files); - if (fd >= fdt->max_fds) - goto out_unlock; - filp = fdt->fd[fd]; - if (!filp) - goto out_unlock; - rcu_assign_pointer(fdt->fd[fd], NULL); - FD_CLR(fd, fdt->close_on_exec); - __put_unused_fd(files, fd); - spin_unlock(&files->file_lock); - retval = filp_close(filp, files); - - /* can't restart close syscall because file table entry was cleared */ - if (unlikely(retval == -ERESTARTSYS || - retval == -ERESTARTNOINTR || - retval == -ERESTARTNOHAND || - retval == -ERESTART_RESTARTBLOCK)) - retval = -EINTR; - - return retval; - -out_unlock: - spin_unlock(&files->file_lock); - return -EBADF; -} - -static void binder_set_nice(long nice) -{ - long min_nice; - if (can_nice(current, nice)) { - set_user_nice(current, nice); - return; - } - min_nice = 20 - current->signal->rlim[RLIMIT_NICE].rlim_cur; - binder_debug(BINDER_DEBUG_PRIORITY_CAP, - "binder: %d: nice value %ld not allowed use " - "%ld instead\n", current->pid, nice, min_nice); - set_user_nice(current, min_nice); - if (min_nice < 20) - return; - binder_user_error("binder: %d RLIMIT_NICE not set\n", current->pid); -} - -static size_t binder_buffer_size(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - if (list_is_last(&buffer->entry, &proc->buffers)) - return proc->buffer + proc->buffer_size - (void *)buffer->data; - else - return (size_t)list_entry(buffer->entry.next, - struct binder_buffer, entry) - (size_t)buffer->data; -} - -static void binder_insert_free_buffer(struct binder_proc *proc, - struct binder_buffer *new_buffer) -{ - struct rb_node **p = &proc->free_buffers.rb_node; - struct rb_node *parent = NULL; - struct binder_buffer *buffer; - size_t buffer_size; - size_t new_buffer_size; - - BUG_ON(!new_buffer->free); - - new_buffer_size = binder_buffer_size(proc, new_buffer); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: add free buffer, size %zd, " - "at %p\n", proc->pid, new_buffer_size, new_buffer); - - while (*p) { - parent = *p; - buffer = rb_entry(parent, struct binder_buffer, rb_node); - BUG_ON(!buffer->free); - - buffer_size = binder_buffer_size(proc, buffer); - - if (new_buffer_size < buffer_size) - p = &parent->rb_left; - else - p = &parent->rb_right; - } - rb_link_node(&new_buffer->rb_node, parent, p); - rb_insert_color(&new_buffer->rb_node, &proc->free_buffers); -} - -static void binder_insert_allocated_buffer(struct binder_proc *proc, - struct binder_buffer *new_buffer) -{ - struct rb_node **p = &proc->allocated_buffers.rb_node; - struct rb_node *parent = NULL; - struct binder_buffer *buffer; - - BUG_ON(new_buffer->free); - - while (*p) { - parent = *p; - buffer = rb_entry(parent, struct binder_buffer, rb_node); - BUG_ON(buffer->free); - - if (new_buffer < buffer) - p = &parent->rb_left; - else if (new_buffer > buffer) - p = &parent->rb_right; - else - BUG(); - } - rb_link_node(&new_buffer->rb_node, parent, p); - rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers); -} - -static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc, - void __user *user_ptr) -{ - struct rb_node *n = proc->allocated_buffers.rb_node; - struct binder_buffer *buffer; - struct binder_buffer *kern_ptr; - - kern_ptr = user_ptr - proc->user_buffer_offset - - offsetof(struct binder_buffer, data); - - while (n) { - buffer = rb_entry(n, struct binder_buffer, rb_node); - BUG_ON(buffer->free); - - if (kern_ptr < buffer) - n = n->rb_left; - else if (kern_ptr > buffer) - n = n->rb_right; - else - return buffer; - } - return NULL; -} - -static int binder_update_page_range(struct binder_proc *proc, int allocate, - void *start, void *end, - struct vm_area_struct *vma) -{ - void *page_addr; - unsigned long user_page_addr; - struct vm_struct tmp_area; - struct page **page; - struct mm_struct *mm; - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: %s pages %p-%p\n", proc->pid, - allocate ? "allocate" : "free", start, end); - - if (end <= start) - return 0; - - if (vma) - mm = NULL; - else - mm = get_task_mm(proc->tsk); - - if (mm) { - down_write(&mm->mmap_sem); - vma = proc->vma; - } - - if (allocate == 0) - goto free_range; - - if (vma == NULL) { - printk(KERN_ERR "binder: %d: binder_alloc_buf failed to " - "map pages in userspace, no vma\n", proc->pid); - goto err_no_vma; - } - - for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) { - int ret; - struct page **page_array_ptr; - page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; - - BUG_ON(*page); - *page = alloc_page(GFP_KERNEL | __GFP_ZERO); - if (*page == NULL) { - printk(KERN_ERR "binder: %d: binder_alloc_buf failed " - "for page at %p\n", proc->pid, page_addr); - goto err_alloc_page_failed; - } - tmp_area.addr = page_addr; - tmp_area.size = PAGE_SIZE + PAGE_SIZE /* guard page? */; - page_array_ptr = page; - ret = map_vm_area(&tmp_area, PAGE_KERNEL, &page_array_ptr); - if (ret) { - printk(KERN_ERR "binder: %d: binder_alloc_buf failed " - "to map page at %p in kernel\n", - proc->pid, page_addr); - goto err_map_kernel_failed; - } - user_page_addr = - (uintptr_t)page_addr + proc->user_buffer_offset; - ret = vm_insert_page(vma, user_page_addr, page[0]); - if (ret) { - printk(KERN_ERR "binder: %d: binder_alloc_buf failed " - "to map page at %lx in userspace\n", - proc->pid, user_page_addr); - goto err_vm_insert_page_failed; - } - /* vm_insert_page does not seem to increment the refcount */ - } - if (mm) { - up_write(&mm->mmap_sem); - mmput(mm); - } - return 0; - -free_range: - for (page_addr = end - PAGE_SIZE; page_addr >= start; - page_addr -= PAGE_SIZE) { - page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; - if (vma) - zap_page_range(vma, (uintptr_t)page_addr + - proc->user_buffer_offset, PAGE_SIZE, NULL); -err_vm_insert_page_failed: - unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE); -err_map_kernel_failed: - __free_page(*page); - *page = NULL; -err_alloc_page_failed: - ; - } -err_no_vma: - if (mm) { - up_write(&mm->mmap_sem); - mmput(mm); - } - return -ENOMEM; -} - -static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc, - size_t data_size, - size_t offsets_size, int is_async) -{ - struct rb_node *n = proc->free_buffers.rb_node; - struct binder_buffer *buffer; - size_t buffer_size; - struct rb_node *best_fit = NULL; - void *has_page_addr; - void *end_page_addr; - size_t size; - - if (proc->vma == NULL) { - printk(KERN_ERR "binder: %d: binder_alloc_buf, no vma\n", - proc->pid); - return NULL; - } - - size = ALIGN(data_size, sizeof(void *)) + - ALIGN(offsets_size, sizeof(void *)); - - if (size < data_size || size < offsets_size) { - binder_user_error("binder: %d: got transaction with invalid " - "size %zd-%zd\n", proc->pid, data_size, offsets_size); - return NULL; - } - - if (is_async && - proc->free_async_space < size + sizeof(struct binder_buffer)) { - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: binder_alloc_buf size %zd" - "failed, no async space left\n", proc->pid, size); - return NULL; - } - - while (n) { - buffer = rb_entry(n, struct binder_buffer, rb_node); - BUG_ON(!buffer->free); - buffer_size = binder_buffer_size(proc, buffer); - - if (size < buffer_size) { - best_fit = n; - n = n->rb_left; - } else if (size > buffer_size) - n = n->rb_right; - else { - best_fit = n; - break; - } - } - if (best_fit == NULL) { - printk(KERN_ERR "binder: %d: binder_alloc_buf size %zd failed, " - "no address space\n", proc->pid, size); - return NULL; - } - if (n == NULL) { - buffer = rb_entry(best_fit, struct binder_buffer, rb_node); - buffer_size = binder_buffer_size(proc, buffer); - } - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: binder_alloc_buf size %zd got buff" - "er %p size %zd\n", proc->pid, size, buffer, buffer_size); - - has_page_addr = - (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK); - if (n == NULL) { - if (size + sizeof(struct binder_buffer) + 4 >= buffer_size) - buffer_size = size; /* no room for other buffers */ - else - buffer_size = size + sizeof(struct binder_buffer); - } - end_page_addr = - (void *)PAGE_ALIGN((uintptr_t)buffer->data + buffer_size); - if (end_page_addr > has_page_addr) - end_page_addr = has_page_addr; - if (binder_update_page_range(proc, 1, - (void *)PAGE_ALIGN((uintptr_t)buffer->data), end_page_addr, NULL)) - return NULL; - - rb_erase(best_fit, &proc->free_buffers); - buffer->free = 0; - binder_insert_allocated_buffer(proc, buffer); - if (buffer_size != size) { - struct binder_buffer *new_buffer = (void *)buffer->data + size; - list_add(&new_buffer->entry, &buffer->entry); - new_buffer->free = 1; - binder_insert_free_buffer(proc, new_buffer); - } - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: binder_alloc_buf size %zd got " - "%p\n", proc->pid, size, buffer); - buffer->data_size = data_size; - buffer->offsets_size = offsets_size; - buffer->async_transaction = is_async; - if (is_async) { - proc->free_async_space -= size + sizeof(struct binder_buffer); - binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, - "binder: %d: binder_alloc_buf size %zd " - "async free %zd\n", proc->pid, size, - proc->free_async_space); - } - - return buffer; -} - -static void *buffer_start_page(struct binder_buffer *buffer) -{ - return (void *)((uintptr_t)buffer & PAGE_MASK); -} - -static void *buffer_end_page(struct binder_buffer *buffer) -{ - return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK); -} - -static void binder_delete_free_buffer(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - struct binder_buffer *prev, *next = NULL; - int free_page_end = 1; - int free_page_start = 1; - - BUG_ON(proc->buffers.next == &buffer->entry); - prev = list_entry(buffer->entry.prev, struct binder_buffer, entry); - BUG_ON(!prev->free); - if (buffer_end_page(prev) == buffer_start_page(buffer)) { - free_page_start = 0; - if (buffer_end_page(prev) == buffer_end_page(buffer)) - free_page_end = 0; - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: merge free, buffer %p " - "share page with %p\n", proc->pid, buffer, prev); - } - - if (!list_is_last(&buffer->entry, &proc->buffers)) { - next = list_entry(buffer->entry.next, - struct binder_buffer, entry); - if (buffer_start_page(next) == buffer_end_page(buffer)) { - free_page_end = 0; - if (buffer_start_page(next) == - buffer_start_page(buffer)) - free_page_start = 0; - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: merge free, buffer" - " %p share page with %p\n", proc->pid, - buffer, prev); - } - } - list_del(&buffer->entry); - if (free_page_start || free_page_end) { - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: merge free, buffer %p do " - "not share page%s%s with with %p or %p\n", - proc->pid, buffer, free_page_start ? "" : " end", - free_page_end ? "" : " start", prev, next); - binder_update_page_range(proc, 0, free_page_start ? - buffer_start_page(buffer) : buffer_end_page(buffer), - (free_page_end ? buffer_end_page(buffer) : - buffer_start_page(buffer)) + PAGE_SIZE, NULL); - } -} - -static void binder_free_buf(struct binder_proc *proc, - struct binder_buffer *buffer) -{ - size_t size, buffer_size; - - buffer_size = binder_buffer_size(proc, buffer); - - size = ALIGN(buffer->data_size, sizeof(void *)) + - ALIGN(buffer->offsets_size, sizeof(void *)); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder: %d: binder_free_buf %p size %zd buffer" - "_size %zd\n", proc->pid, buffer, size, buffer_size); - - BUG_ON(buffer->free); - BUG_ON(size > buffer_size); - BUG_ON(buffer->transaction != NULL); - BUG_ON((void *)buffer < proc->buffer); - BUG_ON((void *)buffer > proc->buffer + proc->buffer_size); - - if (buffer->async_transaction) { - proc->free_async_space += size + sizeof(struct binder_buffer); - - binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC, - "binder: %d: binder_free_buf size %zd " - "async free %zd\n", proc->pid, size, - proc->free_async_space); - } - - binder_update_page_range(proc, 0, - (void *)PAGE_ALIGN((uintptr_t)buffer->data), - (void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK), - NULL); - rb_erase(&buffer->rb_node, &proc->allocated_buffers); - buffer->free = 1; - if (!list_is_last(&buffer->entry, &proc->buffers)) { - struct binder_buffer *next = list_entry(buffer->entry.next, - struct binder_buffer, entry); - if (next->free) { - rb_erase(&next->rb_node, &proc->free_buffers); - binder_delete_free_buffer(proc, next); - } - } - if (proc->buffers.next != &buffer->entry) { - struct binder_buffer *prev = list_entry(buffer->entry.prev, - struct binder_buffer, entry); - if (prev->free) { - binder_delete_free_buffer(proc, buffer); - rb_erase(&prev->rb_node, &proc->free_buffers); - buffer = prev; - } - } - binder_insert_free_buffer(proc, buffer); -} - -static struct binder_node *binder_get_node(struct binder_proc *proc, - void __user *ptr) -{ - struct rb_node *n = proc->nodes.rb_node; - struct binder_node *node; - - while (n) { - node = rb_entry(n, struct binder_node, rb_node); - - if (ptr < node->ptr) - n = n->rb_left; - else if (ptr > node->ptr) - n = n->rb_right; - else - return node; - } - return NULL; -} - -static struct binder_node *binder_new_node(struct binder_proc *proc, - void __user *ptr, - void __user *cookie) -{ - struct rb_node **p = &proc->nodes.rb_node; - struct rb_node *parent = NULL; - struct binder_node *node; - - while (*p) { - parent = *p; - node = rb_entry(parent, struct binder_node, rb_node); - - if (ptr < node->ptr) - p = &(*p)->rb_left; - else if (ptr > node->ptr) - p = &(*p)->rb_right; - else - return NULL; - } - - node = kzalloc(sizeof(*node), GFP_KERNEL); - if (node == NULL) - return NULL; - binder_stats_created(BINDER_STAT_NODE); - rb_link_node(&node->rb_node, parent, p); - rb_insert_color(&node->rb_node, &proc->nodes); - node->debug_id = ++binder_last_id; - node->proc = proc; - node->ptr = ptr; - node->cookie = cookie; - node->work.type = BINDER_WORK_NODE; - INIT_LIST_HEAD(&node->work.entry); - INIT_LIST_HEAD(&node->async_todo); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d:%d node %d u%p c%p created\n", - proc->pid, current->pid, node->debug_id, - node->ptr, node->cookie); - return node; -} - -static int binder_inc_node(struct binder_node *node, int strong, int internal, - struct list_head *target_list) -{ - if (strong) { - if (internal) { - if (target_list == NULL && - node->internal_strong_refs == 0 && - !(node == binder_context_mgr_node && - node->has_strong_ref)) { - printk(KERN_ERR "binder: invalid inc strong " - "node for %d\n", node->debug_id); - return -EINVAL; - } - node->internal_strong_refs++; - } else - node->local_strong_refs++; - if (!node->has_strong_ref && target_list) { - list_del_init(&node->work.entry); - list_add_tail(&node->work.entry, target_list); - } - } else { - if (!internal) - node->local_weak_refs++; - if (!node->has_weak_ref && list_empty(&node->work.entry)) { - if (target_list == NULL) { - printk(KERN_ERR "binder: invalid inc weak node " - "for %d\n", node->debug_id); - return -EINVAL; - } - list_add_tail(&node->work.entry, target_list); - } - } - return 0; -} - -static int binder_dec_node(struct binder_node *node, int strong, int internal) -{ - if (strong) { - if (internal) - node->internal_strong_refs--; - else - node->local_strong_refs--; - if (node->local_strong_refs || node->internal_strong_refs) - return 0; - } else { - if (!internal) - node->local_weak_refs--; - if (node->local_weak_refs || !hlist_empty(&node->refs)) - return 0; - } - if (node->proc && (node->has_strong_ref || node->has_weak_ref)) { - if (list_empty(&node->work.entry)) { - list_add_tail(&node->work.entry, &node->proc->todo); - wake_up_interruptible(&node->proc->wait); - } - } else { - if (hlist_empty(&node->refs) && !node->local_strong_refs && - !node->local_weak_refs) { - list_del_init(&node->work.entry); - if (node->proc) { - rb_erase(&node->rb_node, &node->proc->nodes); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: refless node %d deleted\n", - node->debug_id); - } else { - hlist_del(&node->dead_node); - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: dead node %d deleted\n", - node->debug_id); - } - kfree(node); - binder_stats_deleted(BINDER_STAT_NODE); - } - } - - return 0; -} - - -static struct binder_ref *binder_get_ref(struct binder_proc *proc, - uint32_t desc) -{ - struct rb_node *n = proc->refs_by_desc.rb_node; - struct binder_ref *ref; - - while (n) { - ref = rb_entry(n, struct binder_ref, rb_node_desc); - - if (desc < ref->desc) - n = n->rb_left; - else if (desc > ref->desc) - n = n->rb_right; - else - return ref; - } - return NULL; -} - -static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc, - struct binder_node *node) -{ - struct rb_node *n; - struct rb_node **p = &proc->refs_by_node.rb_node; - struct rb_node *parent = NULL; - struct binder_ref *ref, *new_ref; - - while (*p) { - parent = *p; - ref = rb_entry(parent, struct binder_ref, rb_node_node); - - if (node < ref->node) - p = &(*p)->rb_left; - else if (node > ref->node) - p = &(*p)->rb_right; - else - return ref; - } - new_ref = kzalloc(sizeof(*ref), GFP_KERNEL); - if (new_ref == NULL) - return NULL; - binder_stats_created(BINDER_STAT_REF); - new_ref->debug_id = ++binder_last_id; - new_ref->proc = proc; - new_ref->node = node; - rb_link_node(&new_ref->rb_node_node, parent, p); - rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); - - new_ref->desc = (node == binder_context_mgr_node) ? 0 : 1; - for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { - ref = rb_entry(n, struct binder_ref, rb_node_desc); - if (ref->desc > new_ref->desc) - break; - new_ref->desc = ref->desc + 1; - } - - p = &proc->refs_by_desc.rb_node; - while (*p) { - parent = *p; - ref = rb_entry(parent, struct binder_ref, rb_node_desc); - - if (new_ref->desc < ref->desc) - p = &(*p)->rb_left; - else if (new_ref->desc > ref->desc) - p = &(*p)->rb_right; - else - BUG(); - } - rb_link_node(&new_ref->rb_node_desc, parent, p); - rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); - if (node) { - hlist_add_head(&new_ref->node_entry, &node->refs); - - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d new ref %d desc %d for " - "node %d\n", proc->pid, new_ref->debug_id, - new_ref->desc, node->debug_id); - } else { - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d new ref %d desc %d for " - "dead node\n", proc->pid, new_ref->debug_id, - new_ref->desc); - } - return new_ref; -} - -static void binder_delete_ref(struct binder_ref *ref) -{ - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d delete ref %d desc %d for " - "node %d\n", ref->proc->pid, ref->debug_id, - ref->desc, ref->node->debug_id); - - rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); - rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); - if (ref->strong) - binder_dec_node(ref->node, 1, 1); - hlist_del(&ref->node_entry); - binder_dec_node(ref->node, 0, 1); - if (ref->death) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder: %d delete ref %d desc %d " - "has death notification\n", ref->proc->pid, - ref->debug_id, ref->desc); - list_del(&ref->death->work.entry); - kfree(ref->death); - binder_stats_deleted(BINDER_STAT_DEATH); - } - kfree(ref); - binder_stats_deleted(BINDER_STAT_REF); -} - -static int binder_inc_ref(struct binder_ref *ref, int strong, - struct list_head *target_list) -{ - int ret; - if (strong) { - if (ref->strong == 0) { - ret = binder_inc_node(ref->node, 1, 1, target_list); - if (ret) - return ret; - } - ref->strong++; - } else { - if (ref->weak == 0) { - ret = binder_inc_node(ref->node, 0, 1, target_list); - if (ret) - return ret; - } - ref->weak++; - } - return 0; -} - - -static int binder_dec_ref(struct binder_ref *ref, int strong) -{ - if (strong) { - if (ref->strong == 0) { - binder_user_error("binder: %d invalid dec strong, " - "ref %d desc %d s %d w %d\n", - ref->proc->pid, ref->debug_id, - ref->desc, ref->strong, ref->weak); - return -EINVAL; - } - ref->strong--; - if (ref->strong == 0) { - int ret; - ret = binder_dec_node(ref->node, strong, 1); - if (ret) - return ret; - } - } else { - if (ref->weak == 0) { - binder_user_error("binder: %d invalid dec weak, " - "ref %d desc %d s %d w %d\n", - ref->proc->pid, ref->debug_id, - ref->desc, ref->strong, ref->weak); - return -EINVAL; - } - ref->weak--; - } - if (ref->strong == 0 && ref->weak == 0) - binder_delete_ref(ref); - return 0; -} - -static void binder_pop_transaction(struct binder_thread *target_thread, - struct binder_transaction *t) -{ - if (target_thread) { - BUG_ON(target_thread->transaction_stack != t); - BUG_ON(target_thread->transaction_stack->from != target_thread); - target_thread->transaction_stack = - target_thread->transaction_stack->from_parent; - t->from = NULL; - } - t->need_reply = 0; - if (t->buffer) - t->buffer->transaction = NULL; - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); -} - -static void binder_send_failed_reply(struct binder_transaction *t, - uint32_t error_code) -{ - struct binder_thread *target_thread; - BUG_ON(t->flags & TF_ONE_WAY); - while (1) { - target_thread = t->from; - if (target_thread) { - if (target_thread->return_error != BR_OK && - target_thread->return_error2 == BR_OK) { - target_thread->return_error2 = - target_thread->return_error; - target_thread->return_error = BR_OK; - } - if (target_thread->return_error == BR_OK) { - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "binder: send failed reply for " - "transaction %d to %d:%d\n", - t->debug_id, target_thread->proc->pid, - target_thread->pid); - - binder_pop_transaction(target_thread, t); - target_thread->return_error = error_code; - wake_up_interruptible(&target_thread->wait); - } else { - printk(KERN_ERR "binder: reply failed, target " - "thread, %d:%d, has error code %d " - "already\n", target_thread->proc->pid, - target_thread->pid, - target_thread->return_error); - } - return; - } else { - struct binder_transaction *next = t->from_parent; - - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "binder: send failed reply " - "for transaction %d, target dead\n", - t->debug_id); - - binder_pop_transaction(target_thread, t); - if (next == NULL) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder: reply failed," - " no target thread at root\n"); - return; - } - t = next; - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder: reply failed, no target " - "thread -- retry %d\n", t->debug_id); - } - } -} - -static void binder_transaction_buffer_release(struct binder_proc *proc, - struct binder_buffer *buffer, - size_t *failed_at) -{ - size_t *offp, *off_end; - int debug_id = buffer->debug_id; - - binder_debug(BINDER_DEBUG_TRANSACTION, - "binder: %d buffer release %d, size %zd-%zd, failed at %p\n", - proc->pid, buffer->debug_id, - buffer->data_size, buffer->offsets_size, failed_at); - - if (buffer->target_node) - binder_dec_node(buffer->target_node, 1, 0); - - offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *))); - if (failed_at) - off_end = failed_at; - else - off_end = (void *)offp + buffer->offsets_size; - for (; offp < off_end; offp++) { - struct flat_binder_object *fp; - if (*offp > buffer->data_size - sizeof(*fp) || - buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(void *))) { - printk(KERN_ERR "binder: transaction release %d bad" - "offset %zd, size %zd\n", debug_id, - *offp, buffer->data_size); - continue; - } - fp = (struct flat_binder_object *)(buffer->data + *offp); - switch (fp->type) { - case BINDER_TYPE_BINDER: - case BINDER_TYPE_WEAK_BINDER: { - struct binder_node *node = binder_get_node(proc, fp->binder); - if (node == NULL) { - printk(KERN_ERR "binder: transaction release %d" - " bad node %p\n", debug_id, fp->binder); - break; - } - binder_debug(BINDER_DEBUG_TRANSACTION, - " node %d u%p\n", - node->debug_id, node->ptr); - binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0); - } break; - case BINDER_TYPE_HANDLE: - case BINDER_TYPE_WEAK_HANDLE: { - struct binder_ref *ref = binder_get_ref(proc, fp->handle); - if (ref == NULL) { - printk(KERN_ERR "binder: transaction release %d" - " bad handle %ld\n", debug_id, - fp->handle); - break; - } - binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, ref->node->debug_id); - binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE); - } break; - - case BINDER_TYPE_FD: - binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %ld\n", fp->handle); - if (failed_at) - task_close_fd(proc, fp->handle); - break; - - default: - printk(KERN_ERR "binder: transaction release %d bad " - "object type %lx\n", debug_id, fp->type); - break; - } - } -} - -static void binder_transaction(struct binder_proc *proc, - struct binder_thread *thread, - struct binder_transaction_data *tr, int reply) -{ - struct binder_transaction *t; - struct binder_work *tcomplete; - size_t *offp, *off_end; - struct binder_proc *target_proc; - struct binder_thread *target_thread = NULL; - struct binder_node *target_node = NULL; - struct list_head *target_list; - wait_queue_head_t *target_wait; - struct binder_transaction *in_reply_to = NULL; - struct binder_transaction_log_entry *e; - uint32_t return_error; - - e = binder_transaction_log_add(&binder_transaction_log); - e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY); - e->from_proc = proc->pid; - e->from_thread = thread->pid; - e->target_handle = tr->target.handle; - e->data_size = tr->data_size; - e->offsets_size = tr->offsets_size; - - if (reply) { - in_reply_to = thread->transaction_stack; - if (in_reply_to == NULL) { - binder_user_error("binder: %d:%d got reply transaction " - "with no transaction stack\n", - proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_empty_call_stack; - } - binder_set_nice(in_reply_to->saved_priority); - if (in_reply_to->to_thread != thread) { - binder_user_error("binder: %d:%d got reply transaction " - "with bad transaction stack," - " transaction %d has target %d:%d\n", - proc->pid, thread->pid, in_reply_to->debug_id, - in_reply_to->to_proc ? - in_reply_to->to_proc->pid : 0, - in_reply_to->to_thread ? - in_reply_to->to_thread->pid : 0); - return_error = BR_FAILED_REPLY; - in_reply_to = NULL; - goto err_bad_call_stack; - } - thread->transaction_stack = in_reply_to->to_parent; - target_thread = in_reply_to->from; - if (target_thread == NULL) { - return_error = BR_DEAD_REPLY; - goto err_dead_binder; - } - if (target_thread->transaction_stack != in_reply_to) { - binder_user_error("binder: %d:%d got reply transaction " - "with bad target transaction stack %d, " - "expected %d\n", - proc->pid, thread->pid, - target_thread->transaction_stack ? - target_thread->transaction_stack->debug_id : 0, - in_reply_to->debug_id); - return_error = BR_FAILED_REPLY; - in_reply_to = NULL; - target_thread = NULL; - goto err_dead_binder; - } - target_proc = target_thread->proc; - } else { - if (tr->target.handle) { - struct binder_ref *ref; - ref = binder_get_ref(proc, tr->target.handle); - if (ref == NULL) { - binder_user_error("binder: %d:%d got " - "transaction to invalid handle\n", - proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_invalid_target_handle; - } - target_node = ref->node; - } else { - target_node = binder_context_mgr_node; - if (target_node == NULL) { - return_error = BR_DEAD_REPLY; - goto err_no_context_mgr_node; - } - } - e->to_node = target_node->debug_id; - target_proc = target_node->proc; - if (target_proc == NULL) { - return_error = BR_DEAD_REPLY; - goto err_dead_binder; - } - if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { - struct binder_transaction *tmp; - tmp = thread->transaction_stack; - if (tmp->to_thread != thread) { - binder_user_error("binder: %d:%d got new " - "transaction with bad transaction stack" - ", transaction %d has target %d:%d\n", - proc->pid, thread->pid, tmp->debug_id, - tmp->to_proc ? tmp->to_proc->pid : 0, - tmp->to_thread ? - tmp->to_thread->pid : 0); - return_error = BR_FAILED_REPLY; - goto err_bad_call_stack; - } - while (tmp) { - if (tmp->from && tmp->from->proc == target_proc) - target_thread = tmp->from; - tmp = tmp->from_parent; - } - } - } - if (target_thread) { - e->to_thread = target_thread->pid; - target_list = &target_thread->todo; - target_wait = &target_thread->wait; - } else { - target_list = &target_proc->todo; - target_wait = &target_proc->wait; - } - e->to_proc = target_proc->pid; - - /* TODO: reuse incoming transaction for reply */ - t = kzalloc(sizeof(*t), GFP_KERNEL); - if (t == NULL) { - return_error = BR_FAILED_REPLY; - goto err_alloc_t_failed; - } - binder_stats_created(BINDER_STAT_TRANSACTION); - - tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL); - if (tcomplete == NULL) { - return_error = BR_FAILED_REPLY; - goto err_alloc_tcomplete_failed; - } - binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE); - - t->debug_id = ++binder_last_id; - e->debug_id = t->debug_id; - - if (reply) - binder_debug(BINDER_DEBUG_TRANSACTION, - "binder: %d:%d BC_REPLY %d -> %d:%d, " - "data %p-%p size %zd-%zd\n", - proc->pid, thread->pid, t->debug_id, - target_proc->pid, target_thread->pid, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); - else - binder_debug(BINDER_DEBUG_TRANSACTION, - "binder: %d:%d BC_TRANSACTION %d -> " - "%d - node %d, data %p-%p size %zd-%zd\n", - proc->pid, thread->pid, t->debug_id, - target_proc->pid, target_node->debug_id, - tr->data.ptr.buffer, tr->data.ptr.offsets, - tr->data_size, tr->offsets_size); - - if (!reply && !(tr->flags & TF_ONE_WAY)) - t->from = thread; - else - t->from = NULL; - t->sender_euid = proc->tsk->cred->euid; - t->to_proc = target_proc; - t->to_thread = target_thread; - t->code = tr->code; - t->flags = tr->flags; - t->priority = task_nice(current); - t->buffer = binder_alloc_buf(target_proc, tr->data_size, - tr->offsets_size, !reply && (t->flags & TF_ONE_WAY)); - if (t->buffer == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_alloc_buf_failed; - } - t->buffer->allow_user_free = 0; - t->buffer->debug_id = t->debug_id; - t->buffer->transaction = t; - t->buffer->target_node = target_node; - if (target_node) - binder_inc_node(target_node, 1, 0, NULL); - - offp = (size_t *)(t->buffer->data + ALIGN(tr->data_size, sizeof(void *))); - - if (copy_from_user(t->buffer->data, tr->data.ptr.buffer, tr->data_size)) { - binder_user_error("binder: %d:%d got transaction with invalid " - "data ptr\n", proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_copy_data_failed; - } - if (copy_from_user(offp, tr->data.ptr.offsets, tr->offsets_size)) { - binder_user_error("binder: %d:%d got transaction with invalid " - "offsets ptr\n", proc->pid, thread->pid); - return_error = BR_FAILED_REPLY; - goto err_copy_data_failed; - } - if (!IS_ALIGNED(tr->offsets_size, sizeof(size_t))) { - binder_user_error("binder: %d:%d got transaction with " - "invalid offsets size, %zd\n", - proc->pid, thread->pid, tr->offsets_size); - return_error = BR_FAILED_REPLY; - goto err_bad_offset; - } - off_end = (void *)offp + tr->offsets_size; - for (; offp < off_end; offp++) { - struct flat_binder_object *fp; - if (*offp > t->buffer->data_size - sizeof(*fp) || - t->buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(void *))) { - binder_user_error("binder: %d:%d got transaction with " - "invalid offset, %zd\n", - proc->pid, thread->pid, *offp); - return_error = BR_FAILED_REPLY; - goto err_bad_offset; - } - fp = (struct flat_binder_object *)(t->buffer->data + *offp); - switch (fp->type) { - case BINDER_TYPE_BINDER: - case BINDER_TYPE_WEAK_BINDER: { - struct binder_ref *ref; - struct binder_node *node = binder_get_node(proc, fp->binder); - if (node == NULL) { - node = binder_new_node(proc, fp->binder, fp->cookie); - if (node == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_new_node_failed; - } - node->min_priority = fp->flags & FLAT_BINDER_FLAG_PRIORITY_MASK; - node->accept_fds = !!(fp->flags & FLAT_BINDER_FLAG_ACCEPTS_FDS); - } - if (fp->cookie != node->cookie) { - binder_user_error("binder: %d:%d sending u%p " - "node %d, cookie mismatch %p != %p\n", - proc->pid, thread->pid, - fp->binder, node->debug_id, - fp->cookie, node->cookie); - goto err_binder_get_ref_for_node_failed; - } - ref = binder_get_ref_for_node(target_proc, node); - if (ref == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_for_node_failed; - } - if (fp->type == BINDER_TYPE_BINDER) - fp->type = BINDER_TYPE_HANDLE; - else - fp->type = BINDER_TYPE_WEAK_HANDLE; - fp->handle = ref->desc; - binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, - &thread->todo); - - binder_debug(BINDER_DEBUG_TRANSACTION, - " node %d u%p -> ref %d desc %d\n", - node->debug_id, node->ptr, ref->debug_id, - ref->desc); - } break; - case BINDER_TYPE_HANDLE: - case BINDER_TYPE_WEAK_HANDLE: { - struct binder_ref *ref = binder_get_ref(proc, fp->handle); - if (ref == NULL) { - binder_user_error("binder: %d:%d got " - "transaction with invalid " - "handle, %ld\n", proc->pid, - thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_failed; - } - if (ref->node->proc == target_proc) { - if (fp->type == BINDER_TYPE_HANDLE) - fp->type = BINDER_TYPE_BINDER; - else - fp->type = BINDER_TYPE_WEAK_BINDER; - fp->binder = ref->node->ptr; - fp->cookie = ref->node->cookie; - binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL); - binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d -> node %d u%p\n", - ref->debug_id, ref->desc, ref->node->debug_id, - ref->node->ptr); - } else { - struct binder_ref *new_ref; - new_ref = binder_get_ref_for_node(target_proc, ref->node); - if (new_ref == NULL) { - return_error = BR_FAILED_REPLY; - goto err_binder_get_ref_for_node_failed; - } - fp->handle = new_ref->desc; - binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); - binder_debug(BINDER_DEBUG_TRANSACTION, - " ref %d desc %d -> ref %d desc %d (node %d)\n", - ref->debug_id, ref->desc, new_ref->debug_id, - new_ref->desc, ref->node->debug_id); - } - } break; - - case BINDER_TYPE_FD: { - int target_fd; - struct file *file; - - if (reply) { - if (!(in_reply_to->flags & TF_ACCEPT_FDS)) { - binder_user_error("binder: %d:%d got reply with fd, %ld, but target does not allow fds\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fd_not_allowed; - } - } else if (!target_node->accept_fds) { - binder_user_error("binder: %d:%d got transaction with fd, %ld, but target does not allow fds\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fd_not_allowed; - } - - file = fget(fp->handle); - if (file == NULL) { - binder_user_error("binder: %d:%d got transaction with invalid fd, %ld\n", - proc->pid, thread->pid, fp->handle); - return_error = BR_FAILED_REPLY; - goto err_fget_failed; - } - target_fd = task_get_unused_fd_flags(target_proc, O_CLOEXEC); - if (target_fd < 0) { - fput(file); - return_error = BR_FAILED_REPLY; - goto err_get_unused_fd_failed; - } - task_fd_install(target_proc, target_fd, file); - binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %ld -> %d\n", fp->handle, target_fd); - /* TODO: fput? */ - fp->handle = target_fd; - } break; - - default: - binder_user_error("binder: %d:%d got transactio" - "n with invalid object type, %lx\n", - proc->pid, thread->pid, fp->type); - return_error = BR_FAILED_REPLY; - goto err_bad_object_type; - } - } - if (reply) { - BUG_ON(t->buffer->async_transaction != 0); - binder_pop_transaction(target_thread, in_reply_to); - } else if (!(t->flags & TF_ONE_WAY)) { - BUG_ON(t->buffer->async_transaction != 0); - t->need_reply = 1; - t->from_parent = thread->transaction_stack; - thread->transaction_stack = t; - } else { - BUG_ON(target_node == NULL); - BUG_ON(t->buffer->async_transaction != 1); - if (target_node->has_async_transaction) { - target_list = &target_node->async_todo; - target_wait = NULL; - } else - target_node->has_async_transaction = 1; - } - t->work.type = BINDER_WORK_TRANSACTION; - list_add_tail(&t->work.entry, target_list); - tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE; - list_add_tail(&tcomplete->entry, &thread->todo); - if (target_wait) - wake_up_interruptible(target_wait); - return; - -err_get_unused_fd_failed: -err_fget_failed: -err_fd_not_allowed: -err_binder_get_ref_for_node_failed: -err_binder_get_ref_failed: -err_binder_new_node_failed: -err_bad_object_type: -err_bad_offset: -err_copy_data_failed: - binder_transaction_buffer_release(target_proc, t->buffer, offp); - t->buffer->transaction = NULL; - binder_free_buf(target_proc, t->buffer); -err_binder_alloc_buf_failed: - kfree(tcomplete); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); -err_alloc_tcomplete_failed: - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); -err_alloc_t_failed: -err_bad_call_stack: -err_empty_call_stack: -err_dead_binder: -err_invalid_target_handle: -err_no_context_mgr_node: - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "binder: %d:%d transaction failed %d, size %zd-%zd\n", - proc->pid, thread->pid, return_error, - tr->data_size, tr->offsets_size); - - { - struct binder_transaction_log_entry *fe; - fe = binder_transaction_log_add(&binder_transaction_log_failed); - *fe = *e; - } - - BUG_ON(thread->return_error != BR_OK); - if (in_reply_to) { - thread->return_error = BR_TRANSACTION_COMPLETE; - binder_send_failed_reply(in_reply_to, return_error); - } else - thread->return_error = return_error; -} - -int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread, - void __user *buffer, int size, signed long *consumed) -{ - uint32_t cmd; - void __user *ptr = buffer + *consumed; - void __user *end = buffer + size; - - while (ptr < end && thread->return_error == BR_OK) { - if (get_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) { - binder_stats.bc[_IOC_NR(cmd)]++; - proc->stats.bc[_IOC_NR(cmd)]++; - thread->stats.bc[_IOC_NR(cmd)]++; - } - switch (cmd) { - case BC_INCREFS: - case BC_ACQUIRE: - case BC_RELEASE: - case BC_DECREFS: { - uint32_t target; - struct binder_ref *ref; - const char *debug_string; - - if (get_user(target, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (target == 0 && binder_context_mgr_node && - (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) { - ref = binder_get_ref_for_node(proc, - binder_context_mgr_node); - if (ref->desc != target) { - binder_user_error("binder: %d:" - "%d tried to acquire " - "reference to desc 0, " - "got %d instead\n", - proc->pid, thread->pid, - ref->desc); - } - } else - ref = binder_get_ref(proc, target); - if (ref == NULL) { - binder_user_error("binder: %d:%d refcou" - "nt change on invalid ref %d\n", - proc->pid, thread->pid, target); - break; - } - switch (cmd) { - case BC_INCREFS: - debug_string = "IncRefs"; - binder_inc_ref(ref, 0, NULL); - break; - case BC_ACQUIRE: - debug_string = "Acquire"; - binder_inc_ref(ref, 1, NULL); - break; - case BC_RELEASE: - debug_string = "Release"; - binder_dec_ref(ref, 1); - break; - case BC_DECREFS: - default: - debug_string = "DecRefs"; - binder_dec_ref(ref, 0); - break; - } - binder_debug(BINDER_DEBUG_USER_REFS, - "binder: %d:%d %s ref %d desc %d s %d w %d for node %d\n", - proc->pid, thread->pid, debug_string, ref->debug_id, - ref->desc, ref->strong, ref->weak, ref->node->debug_id); - break; - } - case BC_INCREFS_DONE: - case BC_ACQUIRE_DONE: { - void __user *node_ptr; - void *cookie; - struct binder_node *node; - - if (get_user(node_ptr, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - if (get_user(cookie, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - node = binder_get_node(proc, node_ptr); - if (node == NULL) { - binder_user_error("binder: %d:%d " - "%s u%p no match\n", - proc->pid, thread->pid, - cmd == BC_INCREFS_DONE ? - "BC_INCREFS_DONE" : - "BC_ACQUIRE_DONE", - node_ptr); - break; - } - if (cookie != node->cookie) { - binder_user_error("binder: %d:%d %s u%p node %d" - " cookie mismatch %p != %p\n", - proc->pid, thread->pid, - cmd == BC_INCREFS_DONE ? - "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", - node_ptr, node->debug_id, - cookie, node->cookie); - break; - } - if (cmd == BC_ACQUIRE_DONE) { - if (node->pending_strong_ref == 0) { - binder_user_error("binder: %d:%d " - "BC_ACQUIRE_DONE node %d has " - "no pending acquire request\n", - proc->pid, thread->pid, - node->debug_id); - break; - } - node->pending_strong_ref = 0; - } else { - if (node->pending_weak_ref == 0) { - binder_user_error("binder: %d:%d " - "BC_INCREFS_DONE node %d has " - "no pending increfs request\n", - proc->pid, thread->pid, - node->debug_id); - break; - } - node->pending_weak_ref = 0; - } - binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0); - binder_debug(BINDER_DEBUG_USER_REFS, - "binder: %d:%d %s node %d ls %d lw %d\n", - proc->pid, thread->pid, - cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", - node->debug_id, node->local_strong_refs, node->local_weak_refs); - break; - } - case BC_ATTEMPT_ACQUIRE: - printk(KERN_ERR "binder: BC_ATTEMPT_ACQUIRE not supported\n"); - return -EINVAL; - case BC_ACQUIRE_RESULT: - printk(KERN_ERR "binder: BC_ACQUIRE_RESULT not supported\n"); - return -EINVAL; - - case BC_FREE_BUFFER: { - void __user *data_ptr; - struct binder_buffer *buffer; - - if (get_user(data_ptr, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - - buffer = binder_buffer_lookup(proc, data_ptr); - if (buffer == NULL) { - binder_user_error("binder: %d:%d " - "BC_FREE_BUFFER u%p no match\n", - proc->pid, thread->pid, data_ptr); - break; - } - if (!buffer->allow_user_free) { - binder_user_error("binder: %d:%d " - "BC_FREE_BUFFER u%p matched " - "unreturned buffer\n", - proc->pid, thread->pid, data_ptr); - break; - } - binder_debug(BINDER_DEBUG_FREE_BUFFER, - "binder: %d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n", - proc->pid, thread->pid, data_ptr, buffer->debug_id, - buffer->transaction ? "active" : "finished"); - - if (buffer->transaction) { - buffer->transaction->buffer = NULL; - buffer->transaction = NULL; - } - if (buffer->async_transaction && buffer->target_node) { - BUG_ON(!buffer->target_node->has_async_transaction); - if (list_empty(&buffer->target_node->async_todo)) - buffer->target_node->has_async_transaction = 0; - else - list_move_tail(buffer->target_node->async_todo.next, &thread->todo); - } - binder_transaction_buffer_release(proc, buffer, NULL); - binder_free_buf(proc, buffer); - break; - } - - case BC_TRANSACTION: - case BC_REPLY: { - struct binder_transaction_data tr; - - if (copy_from_user(&tr, ptr, sizeof(tr))) - return -EFAULT; - ptr += sizeof(tr); - binder_transaction(proc, thread, &tr, cmd == BC_REPLY); - break; - } - - case BC_REGISTER_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "binder: %d:%d BC_REGISTER_LOOPER\n", - proc->pid, thread->pid); - if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("binder: %d:%d ERROR:" - " BC_REGISTER_LOOPER called " - "after BC_ENTER_LOOPER\n", - proc->pid, thread->pid); - } else if (proc->requested_threads == 0) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("binder: %d:%d ERROR:" - " BC_REGISTER_LOOPER called " - "without request\n", - proc->pid, thread->pid); - } else { - proc->requested_threads--; - proc->requested_threads_started++; - } - thread->looper |= BINDER_LOOPER_STATE_REGISTERED; - break; - case BC_ENTER_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "binder: %d:%d BC_ENTER_LOOPER\n", - proc->pid, thread->pid); - if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { - thread->looper |= BINDER_LOOPER_STATE_INVALID; - binder_user_error("binder: %d:%d ERROR:" - " BC_ENTER_LOOPER called after " - "BC_REGISTER_LOOPER\n", - proc->pid, thread->pid); - } - thread->looper |= BINDER_LOOPER_STATE_ENTERED; - break; - case BC_EXIT_LOOPER: - binder_debug(BINDER_DEBUG_THREADS, - "binder: %d:%d BC_EXIT_LOOPER\n", - proc->pid, thread->pid); - thread->looper |= BINDER_LOOPER_STATE_EXITED; - break; - - case BC_REQUEST_DEATH_NOTIFICATION: - case BC_CLEAR_DEATH_NOTIFICATION: { - uint32_t target; - void __user *cookie; - struct binder_ref *ref; - struct binder_ref_death *death; - - if (get_user(target, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (get_user(cookie, (void __user * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - ref = binder_get_ref(proc, target); - if (ref == NULL) { - binder_user_error("binder: %d:%d %s " - "invalid ref %d\n", - proc->pid, thread->pid, - cmd == BC_REQUEST_DEATH_NOTIFICATION ? - "BC_REQUEST_DEATH_NOTIFICATION" : - "BC_CLEAR_DEATH_NOTIFICATION", - target); - break; - } - - binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "binder: %d:%d %s %p ref %d desc %d s %d w %d for node %d\n", - proc->pid, thread->pid, - cmd == BC_REQUEST_DEATH_NOTIFICATION ? - "BC_REQUEST_DEATH_NOTIFICATION" : - "BC_CLEAR_DEATH_NOTIFICATION", - cookie, ref->debug_id, ref->desc, - ref->strong, ref->weak, ref->node->debug_id); - - if (cmd == BC_REQUEST_DEATH_NOTIFICATION) { - if (ref->death) { - binder_user_error("binder: %d:%" - "d BC_REQUEST_DEATH_NOTI" - "FICATION death notific" - "ation already set\n", - proc->pid, thread->pid); - break; - } - death = kzalloc(sizeof(*death), GFP_KERNEL); - if (death == NULL) { - thread->return_error = BR_ERROR; - binder_debug(BINDER_DEBUG_FAILED_TRANSACTION, - "binder: %d:%d " - "BC_REQUEST_DEATH_NOTIFICATION failed\n", - proc->pid, thread->pid); - break; - } - binder_stats_created(BINDER_STAT_DEATH); - INIT_LIST_HEAD(&death->work.entry); - death->cookie = cookie; - ref->death = death; - if (ref->node->proc == NULL) { - ref->death->work.type = BINDER_WORK_DEAD_BINDER; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&ref->death->work.entry, &thread->todo); - } else { - list_add_tail(&ref->death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } - } else { - if (ref->death == NULL) { - binder_user_error("binder: %d:%" - "d BC_CLEAR_DEATH_NOTIFI" - "CATION death notificat" - "ion not active\n", - proc->pid, thread->pid); - break; - } - death = ref->death; - if (death->cookie != cookie) { - binder_user_error("binder: %d:%" - "d BC_CLEAR_DEATH_NOTIFI" - "CATION death notificat" - "ion cookie mismatch " - "%p != %p\n", - proc->pid, thread->pid, - death->cookie, cookie); - break; - } - ref->death = NULL; - if (list_empty(&death->work.entry)) { - death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&death->work.entry, &thread->todo); - } else { - list_add_tail(&death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } else { - BUG_ON(death->work.type != BINDER_WORK_DEAD_BINDER); - death->work.type = BINDER_WORK_DEAD_BINDER_AND_CLEAR; - } - } - } break; - case BC_DEAD_BINDER_DONE: { - struct binder_work *w; - void __user *cookie; - struct binder_ref_death *death = NULL; - if (get_user(cookie, (void __user * __user *)ptr)) - return -EFAULT; - - ptr += sizeof(void *); - list_for_each_entry(w, &proc->delivered_death, entry) { - struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work); - if (tmp_death->cookie == cookie) { - death = tmp_death; - break; - } - } - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder: %d:%d BC_DEAD_BINDER_DONE %p found %p\n", - proc->pid, thread->pid, cookie, death); - if (death == NULL) { - binder_user_error("binder: %d:%d BC_DEAD" - "_BINDER_DONE %p not found\n", - proc->pid, thread->pid, cookie); - break; - } - - list_del_init(&death->work.entry); - if (death->work.type == BINDER_WORK_DEAD_BINDER_AND_CLEAR) { - death->work.type = BINDER_WORK_CLEAR_DEATH_NOTIFICATION; - if (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | BINDER_LOOPER_STATE_ENTERED)) { - list_add_tail(&death->work.entry, &thread->todo); - } else { - list_add_tail(&death->work.entry, &proc->todo); - wake_up_interruptible(&proc->wait); - } - } - } break; - - default: - printk(KERN_ERR "binder: %d:%d unknown command %d\n", - proc->pid, thread->pid, cmd); - return -EINVAL; - } - *consumed = ptr - buffer; - } - return 0; -} - -void binder_stat_br(struct binder_proc *proc, struct binder_thread *thread, - uint32_t cmd) -{ - if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) { - binder_stats.br[_IOC_NR(cmd)]++; - proc->stats.br[_IOC_NR(cmd)]++; - thread->stats.br[_IOC_NR(cmd)]++; - } -} - -static int binder_has_proc_work(struct binder_proc *proc, - struct binder_thread *thread) -{ - return !list_empty(&proc->todo) || - (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); -} - -static int binder_has_thread_work(struct binder_thread *thread) -{ - return !list_empty(&thread->todo) || thread->return_error != BR_OK || - (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); -} - -static int binder_thread_read(struct binder_proc *proc, - struct binder_thread *thread, - void __user *buffer, int size, - signed long *consumed, int non_block) -{ - void __user *ptr = buffer + *consumed; - void __user *end = buffer + size; - - int ret = 0; - int wait_for_proc_work; - - if (*consumed == 0) { - if (put_user(BR_NOOP, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - } - -retry: - wait_for_proc_work = thread->transaction_stack == NULL && - list_empty(&thread->todo); - - if (thread->return_error != BR_OK && ptr < end) { - if (thread->return_error2 != BR_OK) { - if (put_user(thread->return_error2, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (ptr == end) - goto done; - thread->return_error2 = BR_OK; - } - if (put_user(thread->return_error, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - thread->return_error = BR_OK; - goto done; - } - - - thread->looper |= BINDER_LOOPER_STATE_WAITING; - if (wait_for_proc_work) - proc->ready_threads++; - mutex_unlock(&binder_lock); - if (wait_for_proc_work) { - if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | - BINDER_LOOPER_STATE_ENTERED))) { - binder_user_error("binder: %d:%d ERROR: Thread waiting " - "for process work before calling BC_REGISTER_" - "LOOPER or BC_ENTER_LOOPER (state %x)\n", - proc->pid, thread->pid, thread->looper); - wait_event_interruptible(binder_user_error_wait, - binder_stop_on_user_error < 2); - } - binder_set_nice(proc->default_priority); - if (non_block) { - if (!binder_has_proc_work(proc, thread)) - ret = -EAGAIN; - } else - ret = wait_event_interruptible_exclusive(proc->wait, binder_has_proc_work(proc, thread)); - } else { - if (non_block) { - if (!binder_has_thread_work(thread)) - ret = -EAGAIN; - } else - ret = wait_event_interruptible(thread->wait, binder_has_thread_work(thread)); - } - mutex_lock(&binder_lock); - if (wait_for_proc_work) - proc->ready_threads--; - thread->looper &= ~BINDER_LOOPER_STATE_WAITING; - - if (ret) - return ret; - - while (1) { - uint32_t cmd; - struct binder_transaction_data tr; - struct binder_work *w; - struct binder_transaction *t = NULL; - - if (!list_empty(&thread->todo)) - w = list_first_entry(&thread->todo, struct binder_work, entry); - else if (!list_empty(&proc->todo) && wait_for_proc_work) - w = list_first_entry(&proc->todo, struct binder_work, entry); - else { - if (ptr - buffer == 4 && !(thread->looper & BINDER_LOOPER_STATE_NEED_RETURN)) /* no data added */ - goto retry; - break; - } - - if (end - ptr < sizeof(tr) + 4) - break; - - switch (w->type) { - case BINDER_WORK_TRANSACTION: { - t = container_of(w, struct binder_transaction, work); - } break; - case BINDER_WORK_TRANSACTION_COMPLETE: { - cmd = BR_TRANSACTION_COMPLETE; - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE, - "binder: %d:%d BR_TRANSACTION_COMPLETE\n", - proc->pid, thread->pid); - - list_del(&w->entry); - kfree(w); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); - } break; - case BINDER_WORK_NODE: { - struct binder_node *node = container_of(w, struct binder_node, work); - uint32_t cmd = BR_NOOP; - const char *cmd_name; - int strong = node->internal_strong_refs || node->local_strong_refs; - int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong; - if (weak && !node->has_weak_ref) { - cmd = BR_INCREFS; - cmd_name = "BR_INCREFS"; - node->has_weak_ref = 1; - node->pending_weak_ref = 1; - node->local_weak_refs++; - } else if (strong && !node->has_strong_ref) { - cmd = BR_ACQUIRE; - cmd_name = "BR_ACQUIRE"; - node->has_strong_ref = 1; - node->pending_strong_ref = 1; - node->local_strong_refs++; - } else if (!strong && node->has_strong_ref) { - cmd = BR_RELEASE; - cmd_name = "BR_RELEASE"; - node->has_strong_ref = 0; - } else if (!weak && node->has_weak_ref) { - cmd = BR_DECREFS; - cmd_name = "BR_DECREFS"; - node->has_weak_ref = 0; - } - if (cmd != BR_NOOP) { - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (put_user(node->ptr, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - if (put_user(node->cookie, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_USER_REFS, - "binder: %d:%d %s %d u%p c%p\n", - proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie); - } else { - list_del_init(&w->entry); - if (!weak && !strong) { - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d:%d node %d u%p c%p deleted\n", - proc->pid, thread->pid, node->debug_id, - node->ptr, node->cookie); - rb_erase(&node->rb_node, &proc->nodes); - kfree(node); - binder_stats_deleted(BINDER_STAT_NODE); - } else { - binder_debug(BINDER_DEBUG_INTERNAL_REFS, - "binder: %d:%d node %d u%p c%p state unchanged\n", - proc->pid, thread->pid, node->debug_id, node->ptr, - node->cookie); - } - } - } break; - case BINDER_WORK_DEAD_BINDER: - case BINDER_WORK_DEAD_BINDER_AND_CLEAR: - case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { - struct binder_ref_death *death; - uint32_t cmd; - - death = container_of(w, struct binder_ref_death, work); - if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) - cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE; - else - cmd = BR_DEAD_BINDER; - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (put_user(death->cookie, (void * __user *)ptr)) - return -EFAULT; - ptr += sizeof(void *); - binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION, - "binder: %d:%d %s %p\n", - proc->pid, thread->pid, - cmd == BR_DEAD_BINDER ? - "BR_DEAD_BINDER" : - "BR_CLEAR_DEATH_NOTIFICATION_DONE", - death->cookie); - - if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) { - list_del(&w->entry); - kfree(death); - binder_stats_deleted(BINDER_STAT_DEATH); - } else - list_move(&w->entry, &proc->delivered_death); - if (cmd == BR_DEAD_BINDER) - goto done; /* DEAD_BINDER notifications can cause transactions */ - } break; - } - - if (!t) - continue; - - BUG_ON(t->buffer == NULL); - if (t->buffer->target_node) { - struct binder_node *target_node = t->buffer->target_node; - tr.target.ptr = target_node->ptr; - tr.cookie = target_node->cookie; - t->saved_priority = task_nice(current); - if (t->priority < target_node->min_priority && - !(t->flags & TF_ONE_WAY)) - binder_set_nice(t->priority); - else if (!(t->flags & TF_ONE_WAY) || - t->saved_priority > target_node->min_priority) - binder_set_nice(target_node->min_priority); - cmd = BR_TRANSACTION; - } else { - tr.target.ptr = NULL; - tr.cookie = NULL; - cmd = BR_REPLY; - } - tr.code = t->code; - tr.flags = t->flags; - tr.sender_euid = t->sender_euid; - - if (t->from) { - struct task_struct *sender = t->from->proc->tsk; - tr.sender_pid = task_tgid_nr_ns(sender, - current->nsproxy->pid_ns); - } else { - tr.sender_pid = 0; - } - - tr.data_size = t->buffer->data_size; - tr.offsets_size = t->buffer->offsets_size; - tr.data.ptr.buffer = (void *)t->buffer->data + - proc->user_buffer_offset; - tr.data.ptr.offsets = tr.data.ptr.buffer + - ALIGN(t->buffer->data_size, - sizeof(void *)); - - if (put_user(cmd, (uint32_t __user *)ptr)) - return -EFAULT; - ptr += sizeof(uint32_t); - if (copy_to_user(ptr, &tr, sizeof(tr))) - return -EFAULT; - ptr += sizeof(tr); - - binder_stat_br(proc, thread, cmd); - binder_debug(BINDER_DEBUG_TRANSACTION, - "binder: %d:%d %s %d %d:%d, cmd %d" - "size %zd-%zd ptr %p-%p\n", - proc->pid, thread->pid, - (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : - "BR_REPLY", - t->debug_id, t->from ? t->from->proc->pid : 0, - t->from ? t->from->pid : 0, cmd, - t->buffer->data_size, t->buffer->offsets_size, - tr.data.ptr.buffer, tr.data.ptr.offsets); - - list_del(&t->work.entry); - t->buffer->allow_user_free = 1; - if (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) { - t->to_parent = thread->transaction_stack; - t->to_thread = thread; - thread->transaction_stack = t; - } else { - t->buffer->transaction = NULL; - kfree(t); - binder_stats_deleted(BINDER_STAT_TRANSACTION); - } - break; - } - -done: - - *consumed = ptr - buffer; - if (proc->requested_threads + proc->ready_threads == 0 && - proc->requested_threads_started < proc->max_threads && - (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | - BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */ - /*spawn a new thread if we leave this out */) { - proc->requested_threads++; - binder_debug(BINDER_DEBUG_THREADS, - "binder: %d:%d BR_SPAWN_LOOPER\n", - proc->pid, thread->pid); - if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer)) - return -EFAULT; - } - return 0; -} - -static void binder_release_work(struct list_head *list) -{ - struct binder_work *w; - while (!list_empty(list)) { - w = list_first_entry(list, struct binder_work, entry); - list_del_init(&w->entry); - switch (w->type) { - case BINDER_WORK_TRANSACTION: { - struct binder_transaction *t; - - t = container_of(w, struct binder_transaction, work); - if (t->buffer->target_node && !(t->flags & TF_ONE_WAY)) - binder_send_failed_reply(t, BR_DEAD_REPLY); - } break; - case BINDER_WORK_TRANSACTION_COMPLETE: { - kfree(w); - binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); - } break; - default: - break; - } - } - -} - -static struct binder_thread *binder_get_thread(struct binder_proc *proc) -{ - struct binder_thread *thread = NULL; - struct rb_node *parent = NULL; - struct rb_node **p = &proc->threads.rb_node; - - while (*p) { - parent = *p; - thread = rb_entry(parent, struct binder_thread, rb_node); - - if (current->pid < thread->pid) - p = &(*p)->rb_left; - else if (current->pid > thread->pid) - p = &(*p)->rb_right; - else - break; - } - if (*p == NULL) { - thread = kzalloc(sizeof(*thread), GFP_KERNEL); - if (thread == NULL) - return NULL; - binder_stats_created(BINDER_STAT_THREAD); - thread->proc = proc; - thread->pid = current->pid; - init_waitqueue_head(&thread->wait); - INIT_LIST_HEAD(&thread->todo); - rb_link_node(&thread->rb_node, parent, p); - rb_insert_color(&thread->rb_node, &proc->threads); - thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; - thread->return_error = BR_OK; - thread->return_error2 = BR_OK; - } - return thread; -} - -static int binder_free_thread(struct binder_proc *proc, - struct binder_thread *thread) -{ - struct binder_transaction *t; - struct binder_transaction *send_reply = NULL; - int active_transactions = 0; - - rb_erase(&thread->rb_node, &proc->threads); - t = thread->transaction_stack; - if (t && t->to_thread == thread) - send_reply = t; - while (t) { - active_transactions++; - binder_debug(BINDER_DEBUG_DEAD_TRANSACTION, - "binder: release %d:%d transaction %d " - "%s, still active\n", proc->pid, thread->pid, - t->debug_id, - (t->to_thread == thread) ? "in" : "out"); - - if (t->to_thread == thread) { - t->to_proc = NULL; - t->to_thread = NULL; - if (t->buffer) { - t->buffer->transaction = NULL; - t->buffer = NULL; - } - t = t->to_parent; - } else if (t->from == thread) { - t->from = NULL; - t = t->from_parent; - } else - BUG(); - } - if (send_reply) - binder_send_failed_reply(send_reply, BR_DEAD_REPLY); - binder_release_work(&thread->todo); - kfree(thread); - binder_stats_deleted(BINDER_STAT_THREAD); - return active_transactions; -} - -static unsigned int binder_poll(struct file *filp, - struct poll_table_struct *wait) -{ - struct binder_proc *proc = filp->private_data; - struct binder_thread *thread = NULL; - int wait_for_proc_work; - - mutex_lock(&binder_lock); - thread = binder_get_thread(proc); - - wait_for_proc_work = thread->transaction_stack == NULL && - list_empty(&thread->todo) && thread->return_error == BR_OK; - mutex_unlock(&binder_lock); - - if (wait_for_proc_work) { - if (binder_has_proc_work(proc, thread)) - return POLLIN; - poll_wait(filp, &proc->wait, wait); - if (binder_has_proc_work(proc, thread)) - return POLLIN; - } else { - if (binder_has_thread_work(thread)) - return POLLIN; - poll_wait(filp, &thread->wait, wait); - if (binder_has_thread_work(thread)) - return POLLIN; - } - return 0; -} - -static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int ret; - struct binder_proc *proc = filp->private_data; - struct binder_thread *thread; - unsigned int size = _IOC_SIZE(cmd); - void __user *ubuf = (void __user *)arg; - - /*printk(KERN_INFO "binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/ - - ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); - if (ret) - return ret; - - mutex_lock(&binder_lock); - thread = binder_get_thread(proc); - if (thread == NULL) { - ret = -ENOMEM; - goto err; - } - - switch (cmd) { - case BINDER_WRITE_READ: { - struct binder_write_read bwr; - if (size != sizeof(struct binder_write_read)) { - ret = -EINVAL; - goto err; - } - if (copy_from_user(&bwr, ubuf, sizeof(bwr))) { - ret = -EFAULT; - goto err; - } - binder_debug(BINDER_DEBUG_READ_WRITE, - "binder: %d:%d write %ld at %08lx, read %ld at %08lx\n", - proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, - bwr.read_size, bwr.read_buffer); - - if (bwr.write_size > 0) { - ret = binder_thread_write(proc, thread, (void __user *)bwr.write_buffer, bwr.write_size, &bwr.write_consumed); - if (ret < 0) { - bwr.read_consumed = 0; - if (copy_to_user(ubuf, &bwr, sizeof(bwr))) - ret = -EFAULT; - goto err; - } - } - if (bwr.read_size > 0) { - ret = binder_thread_read(proc, thread, (void __user *)bwr.read_buffer, bwr.read_size, &bwr.read_consumed, filp->f_flags & O_NONBLOCK); - if (!list_empty(&proc->todo)) - wake_up_interruptible(&proc->wait); - if (ret < 0) { - if (copy_to_user(ubuf, &bwr, sizeof(bwr))) - ret = -EFAULT; - goto err; - } - } - binder_debug(BINDER_DEBUG_READ_WRITE, - "binder: %d:%d wrote %ld of %ld, read return %ld of %ld\n", - proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, - bwr.read_consumed, bwr.read_size); - if (copy_to_user(ubuf, &bwr, sizeof(bwr))) { - ret = -EFAULT; - goto err; - } - break; - } - case BINDER_SET_MAX_THREADS: - if (copy_from_user(&proc->max_threads, ubuf, sizeof(proc->max_threads))) { - ret = -EINVAL; - goto err; - } - break; - case BINDER_SET_CONTEXT_MGR: - if (binder_context_mgr_node != NULL) { - printk(KERN_ERR "binder: BINDER_SET_CONTEXT_MGR already set\n"); - ret = -EBUSY; - goto err; - } - if (binder_context_mgr_uid != -1) { - if (binder_context_mgr_uid != current->cred->euid) { - printk(KERN_ERR "binder: BINDER_SET_" - "CONTEXT_MGR bad uid %d != %d\n", - current->cred->euid, - binder_context_mgr_uid); - ret = -EPERM; - goto err; - } - } else - binder_context_mgr_uid = current->cred->euid; - binder_context_mgr_node = binder_new_node(proc, NULL, NULL); - if (binder_context_mgr_node == NULL) { - ret = -ENOMEM; - goto err; - } - binder_context_mgr_node->local_weak_refs++; - binder_context_mgr_node->local_strong_refs++; - binder_context_mgr_node->has_strong_ref = 1; - binder_context_mgr_node->has_weak_ref = 1; - break; - case BINDER_THREAD_EXIT: - binder_debug(BINDER_DEBUG_THREADS, "binder: %d:%d exit\n", - proc->pid, thread->pid); - binder_free_thread(proc, thread); - thread = NULL; - break; - case BINDER_VERSION: - if (size != sizeof(struct binder_version)) { - ret = -EINVAL; - goto err; - } - if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) { - ret = -EINVAL; - goto err; - } - break; - default: - ret = -EINVAL; - goto err; - } - ret = 0; -err: - if (thread) - thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN; - mutex_unlock(&binder_lock); - wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); - if (ret && ret != -ERESTARTSYS) - printk(KERN_INFO "binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); - return ret; -} - -static void binder_vma_open(struct vm_area_struct *vma) -{ - struct binder_proc *proc = vma->vm_private_data; - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); - dump_stack(); -} - -static void binder_vma_close(struct vm_area_struct *vma) -{ - struct binder_proc *proc = vma->vm_private_data; - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); - proc->vma = NULL; - binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES); -} - -static struct vm_operations_struct binder_vm_ops = { - .open = binder_vma_open, - .close = binder_vma_close, -}; - -static int binder_mmap(struct file *filp, struct vm_area_struct *vma) -{ - int ret; - struct vm_struct *area; - struct binder_proc *proc = filp->private_data; - const char *failure_string; - struct binder_buffer *buffer; - - if ((vma->vm_end - vma->vm_start) > SZ_4M) - vma->vm_end = vma->vm_start + SZ_4M; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n", - proc->pid, vma->vm_start, vma->vm_end, - (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, - (unsigned long)pgprot_val(vma->vm_page_prot)); - - if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) { - ret = -EPERM; - failure_string = "bad vm_flags"; - goto err_bad_arg; - } - vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE; - - if (proc->buffer) { - ret = -EBUSY; - failure_string = "already mapped"; - goto err_already_mapped; - } - - area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP); - if (area == NULL) { - ret = -ENOMEM; - failure_string = "get_vm_area"; - goto err_get_vm_area_failed; - } - proc->buffer = area->addr; - proc->user_buffer_offset = vma->vm_start - (uintptr_t)proc->buffer; - -#ifdef CONFIG_CPU_CACHE_VIPT - if (cache_is_vipt_aliasing()) { - while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) { - printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer); - vma->vm_start += PAGE_SIZE; - } - } -#endif - proc->pages = kzalloc(sizeof(proc->pages[0]) * ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL); - if (proc->pages == NULL) { - ret = -ENOMEM; - failure_string = "alloc page array"; - goto err_alloc_pages_failed; - } - proc->buffer_size = vma->vm_end - vma->vm_start; - - vma->vm_ops = &binder_vm_ops; - vma->vm_private_data = proc; - - if (binder_update_page_range(proc, 1, proc->buffer, proc->buffer + PAGE_SIZE, vma)) { - ret = -ENOMEM; - failure_string = "alloc small buf"; - goto err_alloc_small_buf_failed; - } - buffer = proc->buffer; - INIT_LIST_HEAD(&proc->buffers); - list_add(&buffer->entry, &proc->buffers); - buffer->free = 1; - binder_insert_free_buffer(proc, buffer); - proc->free_async_space = proc->buffer_size / 2; - barrier(); - proc->files = get_files_struct(current); - proc->vma = vma; - - /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n", - proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/ - return 0; - -err_alloc_small_buf_failed: - kfree(proc->pages); - proc->pages = NULL; -err_alloc_pages_failed: - vfree(proc->buffer); - proc->buffer = NULL; -err_get_vm_area_failed: -err_already_mapped: -err_bad_arg: - printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n", - proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); - return ret; -} - -static int binder_open(struct inode *nodp, struct file *filp) -{ - struct binder_proc *proc; - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n", - current->group_leader->pid, current->pid); - - proc = kzalloc(sizeof(*proc), GFP_KERNEL); - if (proc == NULL) - return -ENOMEM; - get_task_struct(current); - proc->tsk = current; - INIT_LIST_HEAD(&proc->todo); - init_waitqueue_head(&proc->wait); - proc->default_priority = task_nice(current); - mutex_lock(&binder_lock); - binder_stats_created(BINDER_STAT_PROC); - hlist_add_head(&proc->proc_node, &binder_procs); - proc->pid = current->group_leader->pid; - INIT_LIST_HEAD(&proc->delivered_death); - filp->private_data = proc; - mutex_unlock(&binder_lock); - - if (binder_proc_dir_entry_proc) { - char strbuf[11]; - snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); - remove_proc_entry(strbuf, binder_proc_dir_entry_proc); - create_proc_read_entry(strbuf, S_IRUGO, - binder_proc_dir_entry_proc, - binder_read_proc_proc, proc); - } - - return 0; -} - -static int binder_flush(struct file *filp, fl_owner_t id) -{ - struct binder_proc *proc = filp->private_data; - - binder_defer_work(proc, BINDER_DEFERRED_FLUSH); - - return 0; -} - -static void binder_deferred_flush(struct binder_proc *proc) -{ - struct rb_node *n; - int wake_count = 0; - for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { - struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); - thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; - if (thread->looper & BINDER_LOOPER_STATE_WAITING) { - wake_up_interruptible(&thread->wait); - wake_count++; - } - } - wake_up_interruptible_all(&proc->wait); - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder_flush: %d woke %d threads\n", proc->pid, - wake_count); -} - -static int binder_release(struct inode *nodp, struct file *filp) -{ - struct binder_proc *proc = filp->private_data; - if (binder_proc_dir_entry_proc) { - char strbuf[11]; - snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); - remove_proc_entry(strbuf, binder_proc_dir_entry_proc); - } - - binder_defer_work(proc, BINDER_DEFERRED_RELEASE); - - return 0; -} - -static void binder_deferred_release(struct binder_proc *proc) -{ - struct hlist_node *pos; - struct binder_transaction *t; - struct rb_node *n; - int threads, nodes, incoming_refs, outgoing_refs, buffers, active_transactions, page_count; - - BUG_ON(proc->vma); - BUG_ON(proc->files); - - hlist_del(&proc->proc_node); - if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) { - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder_release: %d context_mgr_node gone\n", - proc->pid); - binder_context_mgr_node = NULL; - } - - threads = 0; - active_transactions = 0; - while ((n = rb_first(&proc->threads))) { - struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); - threads++; - active_transactions += binder_free_thread(proc, thread); - } - nodes = 0; - incoming_refs = 0; - while ((n = rb_first(&proc->nodes))) { - struct binder_node *node = rb_entry(n, struct binder_node, rb_node); - - nodes++; - rb_erase(&node->rb_node, &proc->nodes); - list_del_init(&node->work.entry); - if (hlist_empty(&node->refs)) { - kfree(node); - binder_stats_deleted(BINDER_STAT_NODE); - } else { - struct binder_ref *ref; - int death = 0; - - node->proc = NULL; - node->local_strong_refs = 0; - node->local_weak_refs = 0; - hlist_add_head(&node->dead_node, &binder_dead_nodes); - - hlist_for_each_entry(ref, pos, &node->refs, node_entry) { - incoming_refs++; - if (ref->death) { - death++; - if (list_empty(&ref->death->work.entry)) { - ref->death->work.type = BINDER_WORK_DEAD_BINDER; - list_add_tail(&ref->death->work.entry, &ref->proc->todo); - wake_up_interruptible(&ref->proc->wait); - } else - BUG(); - } - } - binder_debug(BINDER_DEBUG_DEAD_BINDER, - "binder: node %d now dead, " - "refs %d, death %d\n", node->debug_id, - incoming_refs, death); - } - } - outgoing_refs = 0; - while ((n = rb_first(&proc->refs_by_desc))) { - struct binder_ref *ref = rb_entry(n, struct binder_ref, - rb_node_desc); - outgoing_refs++; - binder_delete_ref(ref); - } - binder_release_work(&proc->todo); - buffers = 0; - - while ((n = rb_first(&proc->allocated_buffers))) { - struct binder_buffer *buffer = rb_entry(n, struct binder_buffer, - rb_node); - t = buffer->transaction; - if (t) { - t->buffer = NULL; - buffer->transaction = NULL; - printk(KERN_ERR "binder: release proc %d, " - "transaction %d, not freed\n", - proc->pid, t->debug_id); - /*BUG();*/ - } - binder_free_buf(proc, buffer); - buffers++; - } - - binder_stats_deleted(BINDER_STAT_PROC); - - page_count = 0; - if (proc->pages) { - int i; - for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) { - if (proc->pages[i]) { - binder_debug(BINDER_DEBUG_BUFFER_ALLOC, - "binder_release: %d: " - "page %d at %p not freed\n", - proc->pid, i, - proc->buffer + i * PAGE_SIZE); - __free_page(proc->pages[i]); - page_count++; - } - } - kfree(proc->pages); - vfree(proc->buffer); - } - - put_task_struct(proc->tsk); - - binder_debug(BINDER_DEBUG_OPEN_CLOSE, - "binder_release: %d threads %d, nodes %d (ref %d), " - "refs %d, active transactions %d, buffers %d, " - "pages %d\n", - proc->pid, threads, nodes, incoming_refs, outgoing_refs, - active_transactions, buffers, page_count); - - kfree(proc); -} - -static void binder_deferred_func(struct work_struct *work) -{ - struct binder_proc *proc; - struct files_struct *files; - - int defer; - do { - mutex_lock(&binder_lock); - mutex_lock(&binder_deferred_lock); - if (!hlist_empty(&binder_deferred_list)) { - proc = hlist_entry(binder_deferred_list.first, - struct binder_proc, deferred_work_node); - hlist_del_init(&proc->deferred_work_node); - defer = proc->deferred_work; - proc->deferred_work = 0; - } else { - proc = NULL; - defer = 0; - } - mutex_unlock(&binder_deferred_lock); - - files = NULL; - if (defer & BINDER_DEFERRED_PUT_FILES) { - files = proc->files; - if (files) - proc->files = NULL; - } - - if (defer & BINDER_DEFERRED_FLUSH) - binder_deferred_flush(proc); - - if (defer & BINDER_DEFERRED_RELEASE) - binder_deferred_release(proc); /* frees proc */ - - mutex_unlock(&binder_lock); - if (files) - put_files_struct(files); - } while (proc); -} -static DECLARE_WORK(binder_deferred_work, binder_deferred_func); - -static void -binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) -{ - mutex_lock(&binder_deferred_lock); - proc->deferred_work |= defer; - if (hlist_unhashed(&proc->deferred_work_node)) { - hlist_add_head(&proc->deferred_work_node, - &binder_deferred_list); - schedule_work(&binder_deferred_work); - } - mutex_unlock(&binder_deferred_lock); -} - -static char *print_binder_transaction(char *buf, char *end, const char *prefix, - struct binder_transaction *t) -{ - buf += snprintf(buf, end - buf, - "%s %d: %p from %d:%d to %d:%d code %x " - "flags %x pri %ld r%d", - prefix, t->debug_id, t, - t->from ? t->from->proc->pid : 0, - t->from ? t->from->pid : 0, - t->to_proc ? t->to_proc->pid : 0, - t->to_thread ? t->to_thread->pid : 0, - t->code, t->flags, t->priority, t->need_reply); - if (buf >= end) - return buf; - if (t->buffer == NULL) { - buf += snprintf(buf, end - buf, " buffer free\n"); - return buf; - } - if (t->buffer->target_node) { - buf += snprintf(buf, end - buf, " node %d", - t->buffer->target_node->debug_id); - if (buf >= end) - return buf; - } - buf += snprintf(buf, end - buf, " size %zd:%zd data %p\n", - t->buffer->data_size, t->buffer->offsets_size, - t->buffer->data); - return buf; -} - -static char *print_binder_buffer(char *buf, char *end, const char *prefix, - struct binder_buffer *buffer) -{ - buf += snprintf(buf, end - buf, "%s %d: %p size %zd:%zd %s\n", - prefix, buffer->debug_id, buffer->data, - buffer->data_size, buffer->offsets_size, - buffer->transaction ? "active" : "delivered"); - return buf; -} - -static char *print_binder_work(char *buf, char *end, const char *prefix, - const char *transaction_prefix, - struct binder_work *w) -{ - struct binder_node *node; - struct binder_transaction *t; - - switch (w->type) { - case BINDER_WORK_TRANSACTION: - t = container_of(w, struct binder_transaction, work); - buf = print_binder_transaction(buf, end, transaction_prefix, t); - break; - case BINDER_WORK_TRANSACTION_COMPLETE: - buf += snprintf(buf, end - buf, - "%stransaction complete\n", prefix); - break; - case BINDER_WORK_NODE: - node = container_of(w, struct binder_node, work); - buf += snprintf(buf, end - buf, "%snode work %d: u%p c%p\n", - prefix, node->debug_id, node->ptr, - node->cookie); - break; - case BINDER_WORK_DEAD_BINDER: - buf += snprintf(buf, end - buf, "%shas dead binder\n", prefix); - break; - case BINDER_WORK_DEAD_BINDER_AND_CLEAR: - buf += snprintf(buf, end - buf, - "%shas cleared dead binder\n", prefix); - break; - case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: - buf += snprintf(buf, end - buf, - "%shas cleared death notification\n", prefix); - break; - default: - buf += snprintf(buf, end - buf, "%sunknown work: type %d\n", - prefix, w->type); - break; - } - return buf; -} - -static char *print_binder_thread(char *buf, char *end, - struct binder_thread *thread, - int print_always) -{ - struct binder_transaction *t; - struct binder_work *w; - char *start_buf = buf; - char *header_buf; - - buf += snprintf(buf, end - buf, " thread %d: l %02x\n", - thread->pid, thread->looper); - header_buf = buf; - t = thread->transaction_stack; - while (t) { - if (buf >= end) - break; - if (t->from == thread) { - buf = print_binder_transaction(buf, end, - " outgoing transaction", t); - t = t->from_parent; - } else if (t->to_thread == thread) { - buf = print_binder_transaction(buf, end, - " incoming transaction", t); - t = t->to_parent; - } else { - buf = print_binder_transaction(buf, end, - " bad transaction", t); - t = NULL; - } - } - list_for_each_entry(w, &thread->todo, entry) { - if (buf >= end) - break; - buf = print_binder_work(buf, end, " ", - " pending transaction", w); - } - if (!print_always && buf == header_buf) - buf = start_buf; - return buf; -} - -static char *print_binder_node(char *buf, char *end, struct binder_node *node) -{ - struct binder_ref *ref; - struct hlist_node *pos; - struct binder_work *w; - int count; - - count = 0; - hlist_for_each_entry(ref, pos, &node->refs, node_entry) - count++; - - buf += snprintf(buf, end - buf, - " node %d: u%p c%p hs %d hw %d ls %d lw %d " - "is %d iw %d", - node->debug_id, node->ptr, node->cookie, - node->has_strong_ref, node->has_weak_ref, - node->local_strong_refs, node->local_weak_refs, - node->internal_strong_refs, count); - if (buf >= end) - return buf; - if (count) { - buf += snprintf(buf, end - buf, " proc"); - if (buf >= end) - return buf; - hlist_for_each_entry(ref, pos, &node->refs, node_entry) { - buf += snprintf(buf, end - buf, " %d", ref->proc->pid); - if (buf >= end) - return buf; - } - } - buf += snprintf(buf, end - buf, "\n"); - list_for_each_entry(w, &node->async_todo, entry) { - if (buf >= end) - break; - buf = print_binder_work(buf, end, " ", - " pending async transaction", w); - } - return buf; -} - -static char *print_binder_ref(char *buf, char *end, struct binder_ref *ref) -{ - buf += snprintf(buf, end - buf, - " ref %d: desc %d %snode %d s %d w %d d %p\n", - ref->debug_id, ref->desc, - ref->node->proc ? "" : "dead ", ref->node->debug_id, - ref->strong, ref->weak, ref->death); - return buf; -} - -static char *print_binder_proc(char *buf, char *end, - struct binder_proc *proc, int print_all) -{ - struct binder_work *w; - struct rb_node *n; - char *start_buf = buf; - char *header_buf; - - buf += snprintf(buf, end - buf, "proc %d\n", proc->pid); - header_buf = buf; - - for (n = rb_first(&proc->threads); - n != NULL && buf < end; - n = rb_next(n)) - buf = print_binder_thread(buf, end, - rb_entry(n, struct binder_thread, - rb_node), print_all); - for (n = rb_first(&proc->nodes); - n != NULL && buf < end; - n = rb_next(n)) { - struct binder_node *node = rb_entry(n, struct binder_node, - rb_node); - if (print_all || node->has_async_transaction) - buf = print_binder_node(buf, end, node); - } - if (print_all) { - for (n = rb_first(&proc->refs_by_desc); - n != NULL && buf < end; - n = rb_next(n)) - buf = print_binder_ref(buf, end, - rb_entry(n, struct binder_ref, - rb_node_desc)); - } - for (n = rb_first(&proc->allocated_buffers); - n != NULL && buf < end; - n = rb_next(n)) - buf = print_binder_buffer(buf, end, " buffer", - rb_entry(n, struct binder_buffer, - rb_node)); - list_for_each_entry(w, &proc->todo, entry) { - if (buf >= end) - break; - buf = print_binder_work(buf, end, " ", - " pending transaction", w); - } - list_for_each_entry(w, &proc->delivered_death, entry) { - if (buf >= end) - break; - buf += snprintf(buf, end - buf, - " has delivered dead binder\n"); - break; - } - if (!print_all && buf == header_buf) - buf = start_buf; - return buf; -} - -static const char *binder_return_strings[] = { - "BR_ERROR", - "BR_OK", - "BR_TRANSACTION", - "BR_REPLY", - "BR_ACQUIRE_RESULT", - "BR_DEAD_REPLY", - "BR_TRANSACTION_COMPLETE", - "BR_INCREFS", - "BR_ACQUIRE", - "BR_RELEASE", - "BR_DECREFS", - "BR_ATTEMPT_ACQUIRE", - "BR_NOOP", - "BR_SPAWN_LOOPER", - "BR_FINISHED", - "BR_DEAD_BINDER", - "BR_CLEAR_DEATH_NOTIFICATION_DONE", - "BR_FAILED_REPLY" -}; - -static const char *binder_command_strings[] = { - "BC_TRANSACTION", - "BC_REPLY", - "BC_ACQUIRE_RESULT", - "BC_FREE_BUFFER", - "BC_INCREFS", - "BC_ACQUIRE", - "BC_RELEASE", - "BC_DECREFS", - "BC_INCREFS_DONE", - "BC_ACQUIRE_DONE", - "BC_ATTEMPT_ACQUIRE", - "BC_REGISTER_LOOPER", - "BC_ENTER_LOOPER", - "BC_EXIT_LOOPER", - "BC_REQUEST_DEATH_NOTIFICATION", - "BC_CLEAR_DEATH_NOTIFICATION", - "BC_DEAD_BINDER_DONE" -}; - -static const char *binder_objstat_strings[] = { - "proc", - "thread", - "node", - "ref", - "death", - "transaction", - "transaction_complete" -}; - -static char *print_binder_stats(char *buf, char *end, const char *prefix, - struct binder_stats *stats) -{ - int i; - - BUILD_BUG_ON(ARRAY_SIZE(stats->bc) != - ARRAY_SIZE(binder_command_strings)); - for (i = 0; i < ARRAY_SIZE(stats->bc); i++) { - if (stats->bc[i]) - buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix, - binder_command_strings[i], - stats->bc[i]); - if (buf >= end) - return buf; - } - - BUILD_BUG_ON(ARRAY_SIZE(stats->br) != - ARRAY_SIZE(binder_return_strings)); - for (i = 0; i < ARRAY_SIZE(stats->br); i++) { - if (stats->br[i]) - buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix, - binder_return_strings[i], stats->br[i]); - if (buf >= end) - return buf; - } - - BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != - ARRAY_SIZE(binder_objstat_strings)); - BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != - ARRAY_SIZE(stats->obj_deleted)); - for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) { - if (stats->obj_created[i] || stats->obj_deleted[i]) - buf += snprintf(buf, end - buf, - "%s%s: active %d total %d\n", prefix, - binder_objstat_strings[i], - stats->obj_created[i] - - stats->obj_deleted[i], - stats->obj_created[i]); - if (buf >= end) - return buf; - } - return buf; -} - -static char *print_binder_proc_stats(char *buf, char *end, - struct binder_proc *proc) -{ - struct binder_work *w; - struct rb_node *n; - int count, strong, weak; - - buf += snprintf(buf, end - buf, "proc %d\n", proc->pid); - if (buf >= end) - return buf; - count = 0; - for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) - count++; - buf += snprintf(buf, end - buf, " threads: %d\n", count); - if (buf >= end) - return buf; - buf += snprintf(buf, end - buf, " requested threads: %d+%d/%d\n" - " ready threads %d\n" - " free async space %zd\n", proc->requested_threads, - proc->requested_threads_started, proc->max_threads, - proc->ready_threads, proc->free_async_space); - if (buf >= end) - return buf; - count = 0; - for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) - count++; - buf += snprintf(buf, end - buf, " nodes: %d\n", count); - if (buf >= end) - return buf; - count = 0; - strong = 0; - weak = 0; - for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { - struct binder_ref *ref = rb_entry(n, struct binder_ref, - rb_node_desc); - count++; - strong += ref->strong; - weak += ref->weak; - } - buf += snprintf(buf, end - buf, " refs: %d s %d w %d\n", - count, strong, weak); - if (buf >= end) - return buf; - - count = 0; - for (n = rb_first(&proc->allocated_buffers); n != NULL; n = rb_next(n)) - count++; - buf += snprintf(buf, end - buf, " buffers: %d\n", count); - if (buf >= end) - return buf; - - count = 0; - list_for_each_entry(w, &proc->todo, entry) { - switch (w->type) { - case BINDER_WORK_TRANSACTION: - count++; - break; - default: - break; - } - } - buf += snprintf(buf, end - buf, " pending transactions: %d\n", count); - if (buf >= end) - return buf; - - buf = print_binder_stats(buf, end, " ", &proc->stats); - - return buf; -} - - -static int binder_read_proc_state(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct binder_proc *proc; - struct hlist_node *pos; - struct binder_node *node; - int len = 0; - char *buf = page; - char *end = page + PAGE_SIZE; - int do_lock = !binder_debug_no_lock; - - if (off) - return 0; - - if (do_lock) - mutex_lock(&binder_lock); - - buf += snprintf(buf, end - buf, "binder state:\n"); - - if (!hlist_empty(&binder_dead_nodes)) - buf += snprintf(buf, end - buf, "dead nodes:\n"); - hlist_for_each_entry(node, pos, &binder_dead_nodes, dead_node) { - if (buf >= end) - break; - buf = print_binder_node(buf, end, node); - } - - hlist_for_each_entry(proc, pos, &binder_procs, proc_node) { - if (buf >= end) - break; - buf = print_binder_proc(buf, end, proc, 1); - } - if (do_lock) - mutex_unlock(&binder_lock); - if (buf > page + PAGE_SIZE) - buf = page + PAGE_SIZE; - - *start = page + off; - - len = buf - page; - if (len > off) - len -= off; - else - len = 0; - - return len < count ? len : count; -} - -static int binder_read_proc_stats(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct binder_proc *proc; - struct hlist_node *pos; - int len = 0; - char *p = page; - int do_lock = !binder_debug_no_lock; - - if (off) - return 0; - - if (do_lock) - mutex_lock(&binder_lock); - - p += snprintf(p, PAGE_SIZE, "binder stats:\n"); - - p = print_binder_stats(p, page + PAGE_SIZE, "", &binder_stats); - - hlist_for_each_entry(proc, pos, &binder_procs, proc_node) { - if (p >= page + PAGE_SIZE) - break; - p = print_binder_proc_stats(p, page + PAGE_SIZE, proc); - } - if (do_lock) - mutex_unlock(&binder_lock); - if (p > page + PAGE_SIZE) - p = page + PAGE_SIZE; - - *start = page + off; - - len = p - page; - if (len > off) - len -= off; - else - len = 0; - - return len < count ? len : count; -} - -static int binder_read_proc_transactions(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct binder_proc *proc; - struct hlist_node *pos; - int len = 0; - char *buf = page; - char *end = page + PAGE_SIZE; - int do_lock = !binder_debug_no_lock; - - if (off) - return 0; - - if (do_lock) - mutex_lock(&binder_lock); - - buf += snprintf(buf, end - buf, "binder transactions:\n"); - hlist_for_each_entry(proc, pos, &binder_procs, proc_node) { - if (buf >= end) - break; - buf = print_binder_proc(buf, end, proc, 0); - } - if (do_lock) - mutex_unlock(&binder_lock); - if (buf > page + PAGE_SIZE) - buf = page + PAGE_SIZE; - - *start = page + off; - - len = buf - page; - if (len > off) - len -= off; - else - len = 0; - - return len < count ? len : count; -} - -static int binder_read_proc_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct binder_proc *proc = data; - int len = 0; - char *p = page; - int do_lock = !binder_debug_no_lock; - - if (off) - return 0; - - if (do_lock) - mutex_lock(&binder_lock); - p += snprintf(p, PAGE_SIZE, "binder proc state:\n"); - p = print_binder_proc(p, page + PAGE_SIZE, proc, 1); - if (do_lock) - mutex_unlock(&binder_lock); - - if (p > page + PAGE_SIZE) - p = page + PAGE_SIZE; - *start = page + off; - - len = p - page; - if (len > off) - len -= off; - else - len = 0; - - return len < count ? len : count; -} - -static char *print_binder_transaction_log_entry(char *buf, char *end, - struct binder_transaction_log_entry *e) -{ - buf += snprintf(buf, end - buf, - "%d: %s from %d:%d to %d:%d node %d handle %d " - "size %d:%d\n", - e->debug_id, (e->call_type == 2) ? "reply" : - ((e->call_type == 1) ? "async" : "call "), e->from_proc, - e->from_thread, e->to_proc, e->to_thread, e->to_node, - e->target_handle, e->data_size, e->offsets_size); - return buf; -} - -static int binder_read_proc_transaction_log( - char *page, char **start, off_t off, int count, int *eof, void *data) -{ - struct binder_transaction_log *log = data; - int len = 0; - int i; - char *buf = page; - char *end = page + PAGE_SIZE; - - if (off) - return 0; - - if (log->full) { - for (i = log->next; i < ARRAY_SIZE(log->entry); i++) { - if (buf >= end) - break; - buf = print_binder_transaction_log_entry(buf, end, - &log->entry[i]); - } - } - for (i = 0; i < log->next; i++) { - if (buf >= end) - break; - buf = print_binder_transaction_log_entry(buf, end, - &log->entry[i]); - } - - *start = page + off; - - len = buf - page; - if (len > off) - len -= off; - else - len = 0; - - return len < count ? len : count; -} - -static const struct file_operations binder_fops = { - .owner = THIS_MODULE, - .poll = binder_poll, - .unlocked_ioctl = binder_ioctl, - .mmap = binder_mmap, - .open = binder_open, - .flush = binder_flush, - .release = binder_release, -}; - -static struct miscdevice binder_miscdev = { - .minor = MISC_DYNAMIC_MINOR, - .name = "binder", - .fops = &binder_fops -}; - -static int __init binder_init(void) -{ - int ret; - - binder_proc_dir_entry_root = proc_mkdir("binder", NULL); - if (binder_proc_dir_entry_root) - binder_proc_dir_entry_proc = proc_mkdir("proc", - binder_proc_dir_entry_root); - ret = misc_register(&binder_miscdev); - if (binder_proc_dir_entry_root) { - create_proc_read_entry("state", - S_IRUGO, - binder_proc_dir_entry_root, - binder_read_proc_state, - NULL); - create_proc_read_entry("stats", - S_IRUGO, - binder_proc_dir_entry_root, - binder_read_proc_stats, - NULL); - create_proc_read_entry("transactions", - S_IRUGO, - binder_proc_dir_entry_root, - binder_read_proc_transactions, - NULL); - create_proc_read_entry("transaction_log", - S_IRUGO, - binder_proc_dir_entry_root, - binder_read_proc_transaction_log, - &binder_transaction_log); - create_proc_read_entry("failed_transaction_log", - S_IRUGO, - binder_proc_dir_entry_root, - binder_read_proc_transaction_log, - &binder_transaction_log_failed); - } - return ret; -} - -device_initcall(binder_init); - -MODULE_LICENSE("GPL v2"); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/binder.h linux-2.6.32-rc6-staging/drivers/staging/android/binder.h --- linux-2.6.32-rc6-usb/drivers/staging/android/binder.h 2009-03-23 16:12:14.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/binder.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2008 Google, Inc. - * - * Based on, but no longer compatible with, the original - * OpenBinder.org binder driver interface, which is: - * - * Copyright (c) 2005 Palmsource, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#ifndef _LINUX_BINDER_H -#define _LINUX_BINDER_H - -#include - -#define B_PACK_CHARS(c1, c2, c3, c4) \ - ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) -#define B_TYPE_LARGE 0x85 - -enum { - BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), - BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), -}; - -enum { - FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, - FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, -}; - -/* - * This is the flattened representation of a Binder object for transfer - * between processes. The 'offsets' supplied as part of a binder transaction - * contains offsets into the data where these structures occur. The Binder - * driver takes care of re-writing the structure type and data as it moves - * between processes. - */ -struct flat_binder_object { - /* 8 bytes for large_flat_header. */ - unsigned long type; - unsigned long flags; - - /* 8 bytes of data. */ - union { - void *binder; /* local object */ - signed long handle; /* remote object */ - }; - - /* extra data associated with local object */ - void *cookie; -}; - -/* - * On 64-bit platforms where user code may run in 32-bits the driver must - * translate the buffer (and local binder) addresses apropriately. - */ - -struct binder_write_read { - signed long write_size; /* bytes to write */ - signed long write_consumed; /* bytes consumed by driver */ - unsigned long write_buffer; - signed long read_size; /* bytes to read */ - signed long read_consumed; /* bytes consumed by driver */ - unsigned long read_buffer; -}; - -/* Use with BINDER_VERSION, driver fills in fields. */ -struct binder_version { - /* driver protocol version -- increment with incompatible change */ - signed long protocol_version; -}; - -/* This is the current protocol version. */ -#define BINDER_CURRENT_PROTOCOL_VERSION 7 - -#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) -#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, int64_t) -#define BINDER_SET_MAX_THREADS _IOW('b', 5, size_t) -#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, int) -#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, int) -#define BINDER_THREAD_EXIT _IOW('b', 8, int) -#define BINDER_VERSION _IOWR('b', 9, struct binder_version) - -/* - * NOTE: Two special error codes you should check for when calling - * in to the driver are: - * - * EINTR -- The operation has been interupted. This should be - * handled by retrying the ioctl() until a different error code - * is returned. - * - * ECONNREFUSED -- The driver is no longer accepting operations - * from your process. That is, the process is being destroyed. - * You should handle this by exiting from your process. Note - * that once this error code is returned, all further calls to - * the driver from any thread will return this same code. - */ - -enum transaction_flags { - TF_ONE_WAY = 0x01, /* this is a one-way call: async, no return */ - TF_ROOT_OBJECT = 0x04, /* contents are the component's root object */ - TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ - TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ -}; - -struct binder_transaction_data { - /* The first two are only used for bcTRANSACTION and brTRANSACTION, - * identifying the target and contents of the transaction. - */ - union { - size_t handle; /* target descriptor of command transaction */ - void *ptr; /* target descriptor of return transaction */ - } target; - void *cookie; /* target object cookie */ - unsigned int code; /* transaction command */ - - /* General information about the transaction. */ - unsigned int flags; - pid_t sender_pid; - uid_t sender_euid; - size_t data_size; /* number of bytes of data */ - size_t offsets_size; /* number of bytes of offsets */ - - /* If this transaction is inline, the data immediately - * follows here; otherwise, it ends with a pointer to - * the data buffer. - */ - union { - struct { - /* transaction data */ - const void *buffer; - /* offsets from buffer to flat_binder_object structs */ - const void *offsets; - } ptr; - uint8_t buf[8]; - } data; -}; - -struct binder_ptr_cookie { - void *ptr; - void *cookie; -}; - -struct binder_pri_desc { - int priority; - int desc; -}; - -struct binder_pri_ptr_cookie { - int priority; - void *ptr; - void *cookie; -}; - -enum BinderDriverReturnProtocol { - BR_ERROR = _IOR('r', 0, int), - /* - * int: error code - */ - - BR_OK = _IO('r', 1), - /* No parameters! */ - - BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), - BR_REPLY = _IOR('r', 3, struct binder_transaction_data), - /* - * binder_transaction_data: the received command. - */ - - BR_ACQUIRE_RESULT = _IOR('r', 4, int), - /* - * not currently supported - * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. - * Else the remote object has acquired a primary reference. - */ - - BR_DEAD_REPLY = _IO('r', 5), - /* - * The target of the last transaction (either a bcTRANSACTION or - * a bcATTEMPT_ACQUIRE) is no longer with us. No parameters. - */ - - BR_TRANSACTION_COMPLETE = _IO('r', 6), - /* - * No parameters... always refers to the last transaction requested - * (including replies). Note that this will be sent even for - * asynchronous transactions. - */ - - BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), - BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), - BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), - BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie for binder - */ - - BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), - /* - * not currently supported - * int: priority - * void *: ptr to binder - * void *: cookie for binder - */ - - BR_NOOP = _IO('r', 12), - /* - * No parameters. Do nothing and examine the next command. It exists - * primarily so that we can replace it with a BR_SPAWN_LOOPER command. - */ - - BR_SPAWN_LOOPER = _IO('r', 13), - /* - * No parameters. The driver has determined that a process has no - * threads waiting to service incomming transactions. When a process - * receives this command, it must spawn a new service thread and - * register it via bcENTER_LOOPER. - */ - - BR_FINISHED = _IO('r', 14), - /* - * not currently supported - * stop threadpool thread - */ - - BR_DEAD_BINDER = _IOR('r', 15, void *), - /* - * void *: cookie - */ - BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, void *), - /* - * void *: cookie - */ - - BR_FAILED_REPLY = _IO('r', 17), - /* - * The the last transaction (either a bcTRANSACTION or - * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory). No parameters. - */ -}; - -enum BinderDriverCommandProtocol { - BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), - BC_REPLY = _IOW('c', 1, struct binder_transaction_data), - /* - * binder_transaction_data: the sent command. - */ - - BC_ACQUIRE_RESULT = _IOW('c', 2, int), - /* - * not currently supported - * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. - * Else you have acquired a primary reference on the object. - */ - - BC_FREE_BUFFER = _IOW('c', 3, int), - /* - * void *: ptr to transaction data received on a read - */ - - BC_INCREFS = _IOW('c', 4, int), - BC_ACQUIRE = _IOW('c', 5, int), - BC_RELEASE = _IOW('c', 6, int), - BC_DECREFS = _IOW('c', 7, int), - /* - * int: descriptor - */ - - BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), - BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie for binder - */ - - BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), - /* - * not currently supported - * int: priority - * int: descriptor - */ - - BC_REGISTER_LOOPER = _IO('c', 11), - /* - * No parameters. - * Register a spawned looper thread with the device. - */ - - BC_ENTER_LOOPER = _IO('c', 12), - BC_EXIT_LOOPER = _IO('c', 13), - /* - * No parameters. - * These two commands are sent as an application-level thread - * enters and exits the binder loop, respectively. They are - * used so the binder can have an accurate count of the number - * of looping threads it has available. - */ - - BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie - */ - - BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_ptr_cookie), - /* - * void *: ptr to binder - * void *: cookie - */ - - BC_DEAD_BINDER_DONE = _IOW('c', 16, void *), - /* - * void *: cookie - */ -}; - -#endif /* _LINUX_BINDER_H */ - diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/Kconfig linux-2.6.32-rc6-staging/drivers/staging/android/Kconfig --- linux-2.6.32-rc6-usb/drivers/staging/android/Kconfig 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/android/Kconfig 1969-12-31 16:00:00.000000000 -0800 @@ -1,96 +0,0 @@ -menu "Android" - -config ANDROID - bool "Android Drivers" - depends on BROKEN - default N - ---help--- - Enable support for various drivers needed on the Android platform - -if ANDROID - -config ANDROID_BINDER_IPC - bool "Android Binder IPC Driver" - default n - -config ANDROID_LOGGER - tristate "Android log driver" - default n - -config ANDROID_RAM_CONSOLE - bool "Android RAM buffer console" - default n - -config ANDROID_RAM_CONSOLE_ENABLE_VERBOSE - bool "Enable verbose console messages on Android RAM console" - default y - depends on ANDROID_RAM_CONSOLE - -menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION - bool "Android RAM Console Enable error correction" - default n - depends on ANDROID_RAM_CONSOLE - depends on !ANDROID_RAM_CONSOLE_EARLY_INIT - select REED_SOLOMON - select REED_SOLOMON_ENC8 - select REED_SOLOMON_DEC8 - -if ANDROID_RAM_CONSOLE_ERROR_CORRECTION - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_DATA_SIZE - int "Android RAM Console Data data size" - default 128 - help - Must be a power of 2. - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_ECC_SIZE - int "Android RAM Console ECC size" - default 16 - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE - int "Android RAM Console Symbol size" - default 8 - -config ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL - hex "Android RAM Console Polynomial" - default 0x19 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 4) - default 0x29 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 5) - default 0x61 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 6) - default 0x89 if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 7) - default 0x11d if (ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE = 8) - -endif # ANDROID_RAM_CONSOLE_ERROR_CORRECTION - -config ANDROID_RAM_CONSOLE_EARLY_INIT - bool "Start Android RAM console early" - default n - depends on ANDROID_RAM_CONSOLE - -config ANDROID_RAM_CONSOLE_EARLY_ADDR - hex "Android RAM console virtual address" - default 0 - depends on ANDROID_RAM_CONSOLE_EARLY_INIT - -config ANDROID_RAM_CONSOLE_EARLY_SIZE - hex "Android RAM console buffer size" - default 0 - depends on ANDROID_RAM_CONSOLE_EARLY_INIT - -config ANDROID_TIMED_OUTPUT - bool "Timed output class driver" - default y - -config ANDROID_TIMED_GPIO - tristate "Android timed gpio driver" - depends on GENERIC_GPIO && ANDROID_TIMED_OUTPUT - default n - -config ANDROID_LOW_MEMORY_KILLER - bool "Android Low Memory Killer" - default N - ---help--- - Register processes to be killed when memory is low - -endif # if ANDROID - -endmenu diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/logger.c linux-2.6.32-rc6-staging/drivers/staging/android/logger.c --- linux-2.6.32-rc6-usb/drivers/staging/android/logger.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/logger.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,607 +0,0 @@ -/* - * drivers/misc/logger.c - * - * A Logging Subsystem - * - * Copyright (C) 2007-2008 Google, Inc. - * - * Robert Love - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include "logger.h" - -#include - -/* - * struct logger_log - represents a specific log, such as 'main' or 'radio' - * - * This structure lives from module insertion until module removal, so it does - * not need additional reference counting. The structure is protected by the - * mutex 'mutex'. - */ -struct logger_log { - unsigned char *buffer;/* the ring buffer itself */ - struct miscdevice misc; /* misc device representing the log */ - wait_queue_head_t wq; /* wait queue for readers */ - struct list_head readers; /* this log's readers */ - struct mutex mutex; /* mutex protecting buffer */ - size_t w_off; /* current write head offset */ - size_t head; /* new readers start here */ - size_t size; /* size of the log */ -}; - -/* - * struct logger_reader - a logging device open for reading - * - * This object lives from open to release, so we don't need additional - * reference counting. The structure is protected by log->mutex. - */ -struct logger_reader { - struct logger_log *log; /* associated log */ - struct list_head list; /* entry in logger_log's list */ - size_t r_off; /* current read head offset */ -}; - -/* logger_offset - returns index 'n' into the log via (optimized) modulus */ -#define logger_offset(n) ((n) & (log->size - 1)) - -/* - * file_get_log - Given a file structure, return the associated log - * - * This isn't aesthetic. We have several goals: - * - * 1) Need to quickly obtain the associated log during an I/O operation - * 2) Readers need to maintain state (logger_reader) - * 3) Writers need to be very fast (open() should be a near no-op) - * - * In the reader case, we can trivially go file->logger_reader->logger_log. - * For a writer, we don't want to maintain a logger_reader, so we just go - * file->logger_log. Thus what file->private_data points at depends on whether - * or not the file was opened for reading. This function hides that dirtiness. - */ -static inline struct logger_log *file_get_log(struct file *file) -{ - if (file->f_mode & FMODE_READ) { - struct logger_reader *reader = file->private_data; - return reader->log; - } else - return file->private_data; -} - -/* - * get_entry_len - Grabs the length of the payload of the next entry starting - * from 'off'. - * - * Caller needs to hold log->mutex. - */ -static __u32 get_entry_len(struct logger_log *log, size_t off) -{ - __u16 val; - - switch (log->size - off) { - case 1: - memcpy(&val, log->buffer + off, 1); - memcpy(((char *) &val) + 1, log->buffer, 1); - break; - default: - memcpy(&val, log->buffer + off, 2); - } - - return sizeof(struct logger_entry) + val; -} - -/* - * do_read_log_to_user - reads exactly 'count' bytes from 'log' into the - * user-space buffer 'buf'. Returns 'count' on success. - * - * Caller must hold log->mutex. - */ -static ssize_t do_read_log_to_user(struct logger_log *log, - struct logger_reader *reader, - char __user *buf, - size_t count) -{ - size_t len; - - /* - * We read from the log in two disjoint operations. First, we read from - * the current read head offset up to 'count' bytes or to the end of - * the log, whichever comes first. - */ - len = min(count, log->size - reader->r_off); - if (copy_to_user(buf, log->buffer + reader->r_off, len)) - return -EFAULT; - - /* - * Second, we read any remaining bytes, starting back at the head of - * the log. - */ - if (count != len) - if (copy_to_user(buf + len, log->buffer, count - len)) - return -EFAULT; - - reader->r_off = logger_offset(reader->r_off + count); - - return count; -} - -/* - * logger_read - our log's read() method - * - * Behavior: - * - * - O_NONBLOCK works - * - If there are no log entries to read, blocks until log is written to - * - Atomically reads exactly one log entry - * - * Optimal read size is LOGGER_ENTRY_MAX_LEN. Will set errno to EINVAL if read - * buffer is insufficient to hold next entry. - */ -static ssize_t logger_read(struct file *file, char __user *buf, - size_t count, loff_t *pos) -{ - struct logger_reader *reader = file->private_data; - struct logger_log *log = reader->log; - ssize_t ret; - DEFINE_WAIT(wait); - -start: - while (1) { - prepare_to_wait(&log->wq, &wait, TASK_INTERRUPTIBLE); - - mutex_lock(&log->mutex); - ret = (log->w_off == reader->r_off); - mutex_unlock(&log->mutex); - if (!ret) - break; - - if (file->f_flags & O_NONBLOCK) { - ret = -EAGAIN; - break; - } - - if (signal_pending(current)) { - ret = -EINTR; - break; - } - - schedule(); - } - - finish_wait(&log->wq, &wait); - if (ret) - return ret; - - mutex_lock(&log->mutex); - - /* is there still something to read or did we race? */ - if (unlikely(log->w_off == reader->r_off)) { - mutex_unlock(&log->mutex); - goto start; - } - - /* get the size of the next entry */ - ret = get_entry_len(log, reader->r_off); - if (count < ret) { - ret = -EINVAL; - goto out; - } - - /* get exactly one entry from the log */ - ret = do_read_log_to_user(log, reader, buf, ret); - -out: - mutex_unlock(&log->mutex); - - return ret; -} - -/* - * get_next_entry - return the offset of the first valid entry at least 'len' - * bytes after 'off'. - * - * Caller must hold log->mutex. - */ -static size_t get_next_entry(struct logger_log *log, size_t off, size_t len) -{ - size_t count = 0; - - do { - size_t nr = get_entry_len(log, off); - off = logger_offset(off + nr); - count += nr; - } while (count < len); - - return off; -} - -/* - * clock_interval - is a < c < b in mod-space? Put another way, does the line - * from a to b cross c? - */ -static inline int clock_interval(size_t a, size_t b, size_t c) -{ - if (b < a) { - if (a < c || b >= c) - return 1; - } else { - if (a < c && b >= c) - return 1; - } - - return 0; -} - -/* - * fix_up_readers - walk the list of all readers and "fix up" any who were - * lapped by the writer; also do the same for the default "start head". - * We do this by "pulling forward" the readers and start head to the first - * entry after the new write head. - * - * The caller needs to hold log->mutex. - */ -static void fix_up_readers(struct logger_log *log, size_t len) -{ - size_t old = log->w_off; - size_t new = logger_offset(old + len); - struct logger_reader *reader; - - if (clock_interval(old, new, log->head)) - log->head = get_next_entry(log, log->head, len); - - list_for_each_entry(reader, &log->readers, list) - if (clock_interval(old, new, reader->r_off)) - reader->r_off = get_next_entry(log, reader->r_off, len); -} - -/* - * do_write_log - writes 'len' bytes from 'buf' to 'log' - * - * The caller needs to hold log->mutex. - */ -static void do_write_log(struct logger_log *log, const void *buf, size_t count) -{ - size_t len; - - len = min(count, log->size - log->w_off); - memcpy(log->buffer + log->w_off, buf, len); - - if (count != len) - memcpy(log->buffer, buf + len, count - len); - - log->w_off = logger_offset(log->w_off + count); - -} - -/* - * do_write_log_user - writes 'len' bytes from the user-space buffer 'buf' to - * the log 'log' - * - * The caller needs to hold log->mutex. - * - * Returns 'count' on success, negative error code on failure. - */ -static ssize_t do_write_log_from_user(struct logger_log *log, - const void __user *buf, size_t count) -{ - size_t len; - - len = min(count, log->size - log->w_off); - if (len && copy_from_user(log->buffer + log->w_off, buf, len)) - return -EFAULT; - - if (count != len) - if (copy_from_user(log->buffer, buf + len, count - len)) - return -EFAULT; - - log->w_off = logger_offset(log->w_off + count); - - return count; -} - -/* - * logger_aio_write - our write method, implementing support for write(), - * writev(), and aio_write(). Writes are our fast path, and we try to optimize - * them above all else. - */ -ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov, - unsigned long nr_segs, loff_t ppos) -{ - struct logger_log *log = file_get_log(iocb->ki_filp); - size_t orig = log->w_off; - struct logger_entry header; - struct timespec now; - ssize_t ret = 0; - - now = current_kernel_time(); - - header.pid = current->tgid; - header.tid = current->pid; - header.sec = now.tv_sec; - header.nsec = now.tv_nsec; - header.len = min_t(size_t, iocb->ki_left, LOGGER_ENTRY_MAX_PAYLOAD); - - /* null writes succeed, return zero */ - if (unlikely(!header.len)) - return 0; - - mutex_lock(&log->mutex); - - /* - * Fix up any readers, pulling them forward to the first readable - * entry after (what will be) the new write offset. We do this now - * because if we partially fail, we can end up with clobbered log - * entries that encroach on readable buffer. - */ - fix_up_readers(log, sizeof(struct logger_entry) + header.len); - - do_write_log(log, &header, sizeof(struct logger_entry)); - - while (nr_segs-- > 0) { - size_t len; - ssize_t nr; - - /* figure out how much of this vector we can keep */ - len = min_t(size_t, iov->iov_len, header.len - ret); - - /* write out this segment's payload */ - nr = do_write_log_from_user(log, iov->iov_base, len); - if (unlikely(nr < 0)) { - log->w_off = orig; - mutex_unlock(&log->mutex); - return nr; - } - - iov++; - ret += nr; - } - - mutex_unlock(&log->mutex); - - /* wake up any blocked readers */ - wake_up_interruptible(&log->wq); - - return ret; -} - -static struct logger_log *get_log_from_minor(int); - -/* - * logger_open - the log's open() file operation - * - * Note how near a no-op this is in the write-only case. Keep it that way! - */ -static int logger_open(struct inode *inode, struct file *file) -{ - struct logger_log *log; - int ret; - - ret = nonseekable_open(inode, file); - if (ret) - return ret; - - log = get_log_from_minor(MINOR(inode->i_rdev)); - if (!log) - return -ENODEV; - - if (file->f_mode & FMODE_READ) { - struct logger_reader *reader; - - reader = kmalloc(sizeof(struct logger_reader), GFP_KERNEL); - if (!reader) - return -ENOMEM; - - reader->log = log; - INIT_LIST_HEAD(&reader->list); - - mutex_lock(&log->mutex); - reader->r_off = log->head; - list_add_tail(&reader->list, &log->readers); - mutex_unlock(&log->mutex); - - file->private_data = reader; - } else - file->private_data = log; - - return 0; -} - -/* - * logger_release - the log's release file operation - * - * Note this is a total no-op in the write-only case. Keep it that way! - */ -static int logger_release(struct inode *ignored, struct file *file) -{ - if (file->f_mode & FMODE_READ) { - struct logger_reader *reader = file->private_data; - list_del(&reader->list); - kfree(reader); - } - - return 0; -} - -/* - * logger_poll - the log's poll file operation, for poll/select/epoll - * - * Note we always return POLLOUT, because you can always write() to the log. - * Note also that, strictly speaking, a return value of POLLIN does not - * guarantee that the log is readable without blocking, as there is a small - * chance that the writer can lap the reader in the interim between poll() - * returning and the read() request. - */ -static unsigned int logger_poll(struct file *file, poll_table *wait) -{ - struct logger_reader *reader; - struct logger_log *log; - unsigned int ret = POLLOUT | POLLWRNORM; - - if (!(file->f_mode & FMODE_READ)) - return ret; - - reader = file->private_data; - log = reader->log; - - poll_wait(file, &log->wq, wait); - - mutex_lock(&log->mutex); - if (log->w_off != reader->r_off) - ret |= POLLIN | POLLRDNORM; - mutex_unlock(&log->mutex); - - return ret; -} - -static long logger_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct logger_log *log = file_get_log(file); - struct logger_reader *reader; - long ret = -ENOTTY; - - mutex_lock(&log->mutex); - - switch (cmd) { - case LOGGER_GET_LOG_BUF_SIZE: - ret = log->size; - break; - case LOGGER_GET_LOG_LEN: - if (!(file->f_mode & FMODE_READ)) { - ret = -EBADF; - break; - } - reader = file->private_data; - if (log->w_off >= reader->r_off) - ret = log->w_off - reader->r_off; - else - ret = (log->size - reader->r_off) + log->w_off; - break; - case LOGGER_GET_NEXT_ENTRY_LEN: - if (!(file->f_mode & FMODE_READ)) { - ret = -EBADF; - break; - } - reader = file->private_data; - if (log->w_off != reader->r_off) - ret = get_entry_len(log, reader->r_off); - else - ret = 0; - break; - case LOGGER_FLUSH_LOG: - if (!(file->f_mode & FMODE_WRITE)) { - ret = -EBADF; - break; - } - list_for_each_entry(reader, &log->readers, list) - reader->r_off = log->w_off; - log->head = log->w_off; - ret = 0; - break; - } - - mutex_unlock(&log->mutex); - - return ret; -} - -static const struct file_operations logger_fops = { - .owner = THIS_MODULE, - .read = logger_read, - .aio_write = logger_aio_write, - .poll = logger_poll, - .unlocked_ioctl = logger_ioctl, - .compat_ioctl = logger_ioctl, - .open = logger_open, - .release = logger_release, -}; - -/* - * Defines a log structure with name 'NAME' and a size of 'SIZE' bytes, which - * must be a power of two, greater than LOGGER_ENTRY_MAX_LEN, and less than - * LONG_MAX minus LOGGER_ENTRY_MAX_LEN. - */ -#define DEFINE_LOGGER_DEVICE(VAR, NAME, SIZE) \ -static unsigned char _buf_ ## VAR[SIZE]; \ -static struct logger_log VAR = { \ - .buffer = _buf_ ## VAR, \ - .misc = { \ - .minor = MISC_DYNAMIC_MINOR, \ - .name = NAME, \ - .fops = &logger_fops, \ - .parent = NULL, \ - }, \ - .wq = __WAIT_QUEUE_HEAD_INITIALIZER(VAR .wq), \ - .readers = LIST_HEAD_INIT(VAR .readers), \ - .mutex = __MUTEX_INITIALIZER(VAR .mutex), \ - .w_off = 0, \ - .head = 0, \ - .size = SIZE, \ -}; - -DEFINE_LOGGER_DEVICE(log_main, LOGGER_LOG_MAIN, 64*1024) -DEFINE_LOGGER_DEVICE(log_events, LOGGER_LOG_EVENTS, 256*1024) -DEFINE_LOGGER_DEVICE(log_radio, LOGGER_LOG_RADIO, 64*1024) - -static struct logger_log *get_log_from_minor(int minor) -{ - if (log_main.misc.minor == minor) - return &log_main; - if (log_events.misc.minor == minor) - return &log_events; - if (log_radio.misc.minor == minor) - return &log_radio; - return NULL; -} - -static int __init init_log(struct logger_log *log) -{ - int ret; - - ret = misc_register(&log->misc); - if (unlikely(ret)) { - printk(KERN_ERR "logger: failed to register misc " - "device for log '%s'!\n", log->misc.name); - return ret; - } - - printk(KERN_INFO "logger: created %luK log '%s'\n", - (unsigned long) log->size >> 10, log->misc.name); - - return 0; -} - -static int __init logger_init(void) -{ - int ret; - - ret = init_log(&log_main); - if (unlikely(ret)) - goto out; - - ret = init_log(&log_events); - if (unlikely(ret)) - goto out; - - ret = init_log(&log_radio); - if (unlikely(ret)) - goto out; - -out: - return ret; -} -device_initcall(logger_init); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/logger.h linux-2.6.32-rc6-staging/drivers/staging/android/logger.h --- linux-2.6.32-rc6-usb/drivers/staging/android/logger.h 2009-03-23 16:12:14.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/logger.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,48 +0,0 @@ -/* include/linux/logger.h - * - * Copyright (C) 2007-2008 Google, Inc. - * Author: Robert Love - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#ifndef _LINUX_LOGGER_H -#define _LINUX_LOGGER_H - -#include -#include - -struct logger_entry { - __u16 len; /* length of the payload */ - __u16 __pad; /* no matter what, we get 2 bytes of padding */ - __s32 pid; /* generating process's pid */ - __s32 tid; /* generating process's tid */ - __s32 sec; /* seconds since Epoch */ - __s32 nsec; /* nanoseconds */ - char msg[0]; /* the entry's payload */ -}; - -#define LOGGER_LOG_RADIO "log_radio" /* radio-related messages */ -#define LOGGER_LOG_EVENTS "log_events" /* system/hardware events */ -#define LOGGER_LOG_MAIN "log_main" /* everything else */ - -#define LOGGER_ENTRY_MAX_LEN (4*1024) -#define LOGGER_ENTRY_MAX_PAYLOAD \ - (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry)) - -#define __LOGGERIO 0xAE - -#define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */ -#define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */ -#define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */ -#define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */ - -#endif /* _LINUX_LOGGER_H */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/lowmemorykiller.c linux-2.6.32-rc6-staging/drivers/staging/android/lowmemorykiller.c --- linux-2.6.32-rc6-usb/drivers/staging/android/lowmemorykiller.c 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/android/lowmemorykiller.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,173 +0,0 @@ -/* drivers/misc/lowmemorykiller.c - * - * The lowmemorykiller driver lets user-space specify a set of memory thresholds - * where processes with a range of oom_adj values will get killed. Specify the - * minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the - * number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both - * files take a comma separated list of numbers in ascending order. - * - * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and - * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes - * with a oom_adj value of 8 or higher when the free memory drops below 4096 pages - * and kill processes with a oom_adj value of 0 or higher when the free memory - * drops below 1024 pages. - * - * The driver considers memory used for caches to be free, but if a large - * percentage of the cached memory is locked this can be very inaccurate - * and processes may not get killed until the normal oom killer is triggered. - * - * Copyright (C) 2007-2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include - -static uint32_t lowmem_debug_level = 2; -static int lowmem_adj[6] = { - 0, - 1, - 6, - 12, -}; -static int lowmem_adj_size = 4; -static size_t lowmem_minfree[6] = { - 3 * 512, /* 6MB */ - 2 * 1024, /* 8MB */ - 4 * 1024, /* 16MB */ - 16 * 1024, /* 64MB */ -}; -static int lowmem_minfree_size = 4; - -#define lowmem_print(level, x...) \ - do { \ - if (lowmem_debug_level >= (level)) \ - printk(x); \ - } while (0) - -static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask) -{ - struct task_struct *p; - struct task_struct *selected = NULL; - int rem = 0; - int tasksize; - int i; - int min_adj = OOM_ADJUST_MAX + 1; - int selected_tasksize = 0; - int selected_oom_adj; - int array_size = ARRAY_SIZE(lowmem_adj); - int other_free = global_page_state(NR_FREE_PAGES); - int other_file = global_page_state(NR_FILE_PAGES); - - if (lowmem_adj_size < array_size) - array_size = lowmem_adj_size; - if (lowmem_minfree_size < array_size) - array_size = lowmem_minfree_size; - for (i = 0; i < array_size; i++) { - if (other_free < lowmem_minfree[i] && - other_file < lowmem_minfree[i]) { - min_adj = lowmem_adj[i]; - break; - } - } - if (nr_to_scan > 0) - lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n", - nr_to_scan, gfp_mask, other_free, other_file, - min_adj); - rem = global_page_state(NR_ACTIVE_ANON) + - global_page_state(NR_ACTIVE_FILE) + - global_page_state(NR_INACTIVE_ANON) + - global_page_state(NR_INACTIVE_FILE); - if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) { - lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", - nr_to_scan, gfp_mask, rem); - return rem; - } - selected_oom_adj = min_adj; - - read_lock(&tasklist_lock); - for_each_process(p) { - struct mm_struct *mm; - int oom_adj; - - task_lock(p); - mm = p->mm; - if (!mm) { - task_unlock(p); - continue; - } - oom_adj = mm->oom_adj; - if (oom_adj < min_adj) { - task_unlock(p); - continue; - } - tasksize = get_mm_rss(mm); - task_unlock(p); - if (tasksize <= 0) - continue; - if (selected) { - if (oom_adj < selected_oom_adj) - continue; - if (oom_adj == selected_oom_adj && - tasksize <= selected_tasksize) - continue; - } - selected = p; - selected_tasksize = tasksize; - selected_oom_adj = oom_adj; - lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n", - p->pid, p->comm, oom_adj, tasksize); - } - if (selected) { - lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n", - selected->pid, selected->comm, - selected_oom_adj, selected_tasksize); - force_sig(SIGKILL, selected); - rem -= selected_tasksize; - } - lowmem_print(4, "lowmem_shrink %d, %x, return %d\n", - nr_to_scan, gfp_mask, rem); - read_unlock(&tasklist_lock); - return rem; -} - -static struct shrinker lowmem_shrinker = { - .shrink = lowmem_shrink, - .seeks = DEFAULT_SEEKS * 16 -}; - -static int __init lowmem_init(void) -{ - register_shrinker(&lowmem_shrinker); - return 0; -} - -static void __exit lowmem_exit(void) -{ - unregister_shrinker(&lowmem_shrinker); -} - -module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR); -module_param_array_named(adj, lowmem_adj, int, &lowmem_adj_size, - S_IRUGO | S_IWUSR); -module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size, - S_IRUGO | S_IWUSR); -module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR); - -module_init(lowmem_init); -module_exit(lowmem_exit); - -MODULE_LICENSE("GPL"); - diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/Makefile linux-2.6.32-rc6-staging/drivers/staging/android/Makefile --- linux-2.6.32-rc6-usb/drivers/staging/android/Makefile 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/Makefile 1969-12-31 16:00:00.000000000 -0800 @@ -1,6 +0,0 @@ -obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o -obj-$(CONFIG_ANDROID_LOGGER) += logger.o -obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o -obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o -obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o -obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/ram_console.c linux-2.6.32-rc6-staging/drivers/staging/android/ram_console.c --- linux-2.6.32-rc6-usb/drivers/staging/android/ram_console.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/ram_console.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,410 +0,0 @@ -/* drivers/android/ram_console.c - * - * Copyright (C) 2007-2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION -#include -#endif - -struct ram_console_buffer { - uint32_t sig; - uint32_t start; - uint32_t size; - uint8_t data[0]; -}; - -#define RAM_CONSOLE_SIG (0x43474244) /* DBGC */ - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -static char __initdata - ram_console_old_log_init_buffer[CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE]; -#endif -static char *ram_console_old_log; -static size_t ram_console_old_log_size; - -static struct ram_console_buffer *ram_console_buffer; -static size_t ram_console_buffer_size; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION -static char *ram_console_par_buffer; -static struct rs_control *ram_console_rs_decoder; -static int ram_console_corrected_bytes; -static int ram_console_bad_blocks; -#define ECC_BLOCK_SIZE CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_DATA_SIZE -#define ECC_SIZE CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_ECC_SIZE -#define ECC_SYMSIZE CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE -#define ECC_POLY CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL -#endif - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION -static void ram_console_encode_rs8(uint8_t *data, size_t len, uint8_t *ecc) -{ - int i; - uint16_t par[ECC_SIZE]; - /* Initialize the parity buffer */ - memset(par, 0, sizeof(par)); - encode_rs8(ram_console_rs_decoder, data, len, par, 0); - for (i = 0; i < ECC_SIZE; i++) - ecc[i] = par[i]; -} - -static int ram_console_decode_rs8(void *data, size_t len, uint8_t *ecc) -{ - int i; - uint16_t par[ECC_SIZE]; - for (i = 0; i < ECC_SIZE; i++) - par[i] = ecc[i]; - return decode_rs8(ram_console_rs_decoder, data, par, len, - NULL, 0, NULL, 0, NULL); -} -#endif - -static void ram_console_update(const char *s, unsigned int count) -{ - struct ram_console_buffer *buffer = ram_console_buffer; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - uint8_t *buffer_end = buffer->data + ram_console_buffer_size; - uint8_t *block; - uint8_t *par; - int size = ECC_BLOCK_SIZE; -#endif - memcpy(buffer->data + buffer->start, s, count); -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - block = buffer->data + (buffer->start & ~(ECC_BLOCK_SIZE - 1)); - par = ram_console_par_buffer + - (buffer->start / ECC_BLOCK_SIZE) * ECC_SIZE; - do { - if (block + ECC_BLOCK_SIZE > buffer_end) - size = buffer_end - block; - ram_console_encode_rs8(block, size, par); - block += ECC_BLOCK_SIZE; - par += ECC_SIZE; - } while (block < buffer->data + buffer->start + count); -#endif -} - -static void ram_console_update_header(void) -{ -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - struct ram_console_buffer *buffer = ram_console_buffer; - uint8_t *par; - par = ram_console_par_buffer + - DIV_ROUND_UP(ram_console_buffer_size, ECC_BLOCK_SIZE) * ECC_SIZE; - ram_console_encode_rs8((uint8_t *)buffer, sizeof(*buffer), par); -#endif -} - -static void -ram_console_write(struct console *console, const char *s, unsigned int count) -{ - int rem; - struct ram_console_buffer *buffer = ram_console_buffer; - - if (count > ram_console_buffer_size) { - s += count - ram_console_buffer_size; - count = ram_console_buffer_size; - } - rem = ram_console_buffer_size - buffer->start; - if (rem < count) { - ram_console_update(s, rem); - s += rem; - count -= rem; - buffer->start = 0; - buffer->size = ram_console_buffer_size; - } - ram_console_update(s, count); - - buffer->start += count; - if (buffer->size < ram_console_buffer_size) - buffer->size += count; - ram_console_update_header(); -} - -static struct console ram_console = { - .name = "ram", - .write = ram_console_write, - .flags = CON_PRINTBUFFER | CON_ENABLED, - .index = -1, -}; - -static void __init -ram_console_save_old(struct ram_console_buffer *buffer, char *dest) -{ - size_t old_log_size = buffer->size; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - uint8_t *block; - uint8_t *par; - char strbuf[80]; - int strbuf_len; - - block = buffer->data; - par = ram_console_par_buffer; - while (block < buffer->data + buffer->size) { - int numerr; - int size = ECC_BLOCK_SIZE; - if (block + size > buffer->data + ram_console_buffer_size) - size = buffer->data + ram_console_buffer_size - block; - numerr = ram_console_decode_rs8(block, size, par); - if (numerr > 0) { -#if 0 - printk(KERN_INFO "ram_console: error in block %p, %d\n", - block, numerr); -#endif - ram_console_corrected_bytes += numerr; - } else if (numerr < 0) { -#if 0 - printk(KERN_INFO "ram_console: uncorrectable error in " - "block %p\n", block); -#endif - ram_console_bad_blocks++; - } - block += ECC_BLOCK_SIZE; - par += ECC_SIZE; - } - if (ram_console_corrected_bytes || ram_console_bad_blocks) - strbuf_len = snprintf(strbuf, sizeof(strbuf), - "\n%d Corrected bytes, %d unrecoverable blocks\n", - ram_console_corrected_bytes, ram_console_bad_blocks); - else - strbuf_len = snprintf(strbuf, sizeof(strbuf), - "\nNo errors detected\n"); - if (strbuf_len >= sizeof(strbuf)) - strbuf_len = sizeof(strbuf) - 1; - old_log_size += strbuf_len; -#endif - - if (dest == NULL) { - dest = kmalloc(old_log_size, GFP_KERNEL); - if (dest == NULL) { - printk(KERN_ERR - "ram_console: failed to allocate buffer\n"); - return; - } - } - - ram_console_old_log = dest; - ram_console_old_log_size = old_log_size; - memcpy(ram_console_old_log, - &buffer->data[buffer->start], buffer->size - buffer->start); - memcpy(ram_console_old_log + buffer->size - buffer->start, - &buffer->data[0], buffer->start); -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - memcpy(ram_console_old_log + old_log_size - strbuf_len, - strbuf, strbuf_len); -#endif -} - -static int __init ram_console_init(struct ram_console_buffer *buffer, - size_t buffer_size, char *old_buf) -{ -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - int numerr; - uint8_t *par; -#endif - ram_console_buffer = buffer; - ram_console_buffer_size = - buffer_size - sizeof(struct ram_console_buffer); - - if (ram_console_buffer_size > buffer_size) { - pr_err("ram_console: buffer %p, invalid size %zu, " - "datasize %zu\n", buffer, buffer_size, - ram_console_buffer_size); - return 0; - } - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size, - ECC_BLOCK_SIZE) + 1) * ECC_SIZE; - - if (ram_console_buffer_size > buffer_size) { - pr_err("ram_console: buffer %p, invalid size %zu, " - "non-ecc datasize %zu\n", - buffer, buffer_size, ram_console_buffer_size); - return 0; - } - - ram_console_par_buffer = buffer->data + ram_console_buffer_size; - - - /* first consecutive root is 0 - * primitive element to generate roots = 1 - */ - ram_console_rs_decoder = init_rs(ECC_SYMSIZE, ECC_POLY, 0, 1, ECC_SIZE); - if (ram_console_rs_decoder == NULL) { - printk(KERN_INFO "ram_console: init_rs failed\n"); - return 0; - } - - ram_console_corrected_bytes = 0; - ram_console_bad_blocks = 0; - - par = ram_console_par_buffer + - DIV_ROUND_UP(ram_console_buffer_size, ECC_BLOCK_SIZE) * ECC_SIZE; - - numerr = ram_console_decode_rs8(buffer, sizeof(*buffer), par); - if (numerr > 0) { - printk(KERN_INFO "ram_console: error in header, %d\n", numerr); - ram_console_corrected_bytes += numerr; - } else if (numerr < 0) { - printk(KERN_INFO - "ram_console: uncorrectable error in header\n"); - ram_console_bad_blocks++; - } -#endif - - if (buffer->sig == RAM_CONSOLE_SIG) { - if (buffer->size > ram_console_buffer_size - || buffer->start > buffer->size) - printk(KERN_INFO "ram_console: found existing invalid " - "buffer, size %d, start %d\n", - buffer->size, buffer->start); - else { - printk(KERN_INFO "ram_console: found existing buffer, " - "size %d, start %d\n", - buffer->size, buffer->start); - ram_console_save_old(buffer, old_buf); - } - } else { - printk(KERN_INFO "ram_console: no valid data in buffer " - "(sig = 0x%08x)\n", buffer->sig); - } - - buffer->sig = RAM_CONSOLE_SIG; - buffer->start = 0; - buffer->size = 0; - - register_console(&ram_console); -#ifdef CONFIG_ANDROID_RAM_CONSOLE_ENABLE_VERBOSE - console_verbose(); -#endif - return 0; -} - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -static int __init ram_console_early_init(void) -{ - return ram_console_init((struct ram_console_buffer *) - CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR, - CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE, - ram_console_old_log_init_buffer); -} -#else -static int ram_console_driver_probe(struct platform_device *pdev) -{ - struct resource *res = pdev->resource; - size_t start; - size_t buffer_size; - void *buffer; - - if (res == NULL || pdev->num_resources != 1 || - !(res->flags & IORESOURCE_MEM)) { - printk(KERN_ERR "ram_console: invalid resource, %p %d flags " - "%lx\n", res, pdev->num_resources, res ? res->flags : 0); - return -ENXIO; - } - buffer_size = res->end - res->start + 1; - start = res->start; - printk(KERN_INFO "ram_console: got buffer at %zx, size %zx\n", - start, buffer_size); - buffer = ioremap(res->start, buffer_size); - if (buffer == NULL) { - printk(KERN_ERR "ram_console: failed to map memory\n"); - return -ENOMEM; - } - - return ram_console_init(buffer, buffer_size, NULL/* allocate */); -} - -static struct platform_driver ram_console_driver = { - .probe = ram_console_driver_probe, - .driver = { - .name = "ram_console", - }, -}; - -static int __init ram_console_module_init(void) -{ - int err; - err = platform_driver_register(&ram_console_driver); - return err; -} -#endif - -static ssize_t ram_console_read_old(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - loff_t pos = *offset; - ssize_t count; - - if (pos >= ram_console_old_log_size) - return 0; - - count = min(len, (size_t)(ram_console_old_log_size - pos)); - if (copy_to_user(buf, ram_console_old_log + pos, count)) - return -EFAULT; - - *offset += count; - return count; -} - -static const struct file_operations ram_console_file_ops = { - .owner = THIS_MODULE, - .read = ram_console_read_old, -}; - -static int __init ram_console_late_init(void) -{ - struct proc_dir_entry *entry; - - if (ram_console_old_log == NULL) - return 0; -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT - ram_console_old_log = kmalloc(ram_console_old_log_size, GFP_KERNEL); - if (ram_console_old_log == NULL) { - printk(KERN_ERR - "ram_console: failed to allocate buffer for old log\n"); - ram_console_old_log_size = 0; - return 0; - } - memcpy(ram_console_old_log, - ram_console_old_log_init_buffer, ram_console_old_log_size); -#endif - entry = create_proc_entry("last_kmsg", S_IFREG | S_IRUGO, NULL); - if (!entry) { - printk(KERN_ERR "ram_console: failed to create proc entry\n"); - kfree(ram_console_old_log); - ram_console_old_log = NULL; - return 0; - } - - entry->proc_fops = &ram_console_file_ops; - entry->size = ram_console_old_log_size; - return 0; -} - -#ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT -console_initcall(ram_console_early_init); -#else -module_init(ram_console_module_init); -#endif -late_initcall(ram_console_late_init); - diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/timed_gpio.c linux-2.6.32-rc6-staging/drivers/staging/android/timed_gpio.c --- linux-2.6.32-rc6-usb/drivers/staging/android/timed_gpio.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/timed_gpio.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,166 +0,0 @@ -/* drivers/misc/timed_gpio.c - * - * Copyright (C) 2008 Google, Inc. - * Author: Mike Lockwood - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include - -#include "timed_output.h" -#include "timed_gpio.h" - - -struct timed_gpio_data { - struct timed_output_dev dev; - struct hrtimer timer; - spinlock_t lock; - unsigned gpio; - int max_timeout; - u8 active_low; -}; - -static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer) -{ - struct timed_gpio_data *data = - container_of(timer, struct timed_gpio_data, timer); - - gpio_direction_output(data->gpio, data->active_low ? 1 : 0); - return HRTIMER_NORESTART; -} - -static int gpio_get_time(struct timed_output_dev *dev) -{ - struct timed_gpio_data *data = - container_of(dev, struct timed_gpio_data, dev); - - if (hrtimer_active(&data->timer)) { - ktime_t r = hrtimer_get_remaining(&data->timer); - struct timeval t = ktime_to_timeval(r); - return t.tv_sec * 1000 + t.tv_usec / 1000; - } else - return 0; -} - -static void gpio_enable(struct timed_output_dev *dev, int value) -{ - struct timed_gpio_data *data = - container_of(dev, struct timed_gpio_data, dev); - unsigned long flags; - - spin_lock_irqsave(&data->lock, flags); - - /* cancel previous timer and set GPIO according to value */ - hrtimer_cancel(&data->timer); - gpio_direction_output(data->gpio, data->active_low ? !value : !!value); - - if (value > 0) { - if (value > data->max_timeout) - value = data->max_timeout; - - hrtimer_start(&data->timer, - ktime_set(value / 1000, (value % 1000) * 1000000), - HRTIMER_MODE_REL); - } - - spin_unlock_irqrestore(&data->lock, flags); -} - -static int timed_gpio_probe(struct platform_device *pdev) -{ - struct timed_gpio_platform_data *pdata = pdev->dev.platform_data; - struct timed_gpio *cur_gpio; - struct timed_gpio_data *gpio_data, *gpio_dat; - int i, j, ret = 0; - - if (!pdata) - return -EBUSY; - - gpio_data = kzalloc(sizeof(struct timed_gpio_data) * pdata->num_gpios, - GFP_KERNEL); - if (!gpio_data) - return -ENOMEM; - - for (i = 0; i < pdata->num_gpios; i++) { - cur_gpio = &pdata->gpios[i]; - gpio_dat = &gpio_data[i]; - - hrtimer_init(&gpio_dat->timer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL); - gpio_dat->timer.function = gpio_timer_func; - spin_lock_init(&gpio_dat->lock); - - gpio_dat->dev.name = cur_gpio->name; - gpio_dat->dev.get_time = gpio_get_time; - gpio_dat->dev.enable = gpio_enable; - ret = timed_output_dev_register(&gpio_dat->dev); - if (ret < 0) { - for (j = 0; j < i; j++) - timed_output_dev_unregister(&gpio_data[i].dev); - kfree(gpio_data); - return ret; - } - - gpio_dat->gpio = cur_gpio->gpio; - gpio_dat->max_timeout = cur_gpio->max_timeout; - gpio_dat->active_low = cur_gpio->active_low; - gpio_direction_output(gpio_dat->gpio, gpio_dat->active_low); - } - - platform_set_drvdata(pdev, gpio_data); - - return 0; -} - -static int timed_gpio_remove(struct platform_device *pdev) -{ - struct timed_gpio_platform_data *pdata = pdev->dev.platform_data; - struct timed_gpio_data *gpio_data = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < pdata->num_gpios; i++) - timed_output_dev_unregister(&gpio_data[i].dev); - - kfree(gpio_data); - - return 0; -} - -static struct platform_driver timed_gpio_driver = { - .probe = timed_gpio_probe, - .remove = timed_gpio_remove, - .driver = { - .name = TIMED_GPIO_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init timed_gpio_init(void) -{ - return platform_driver_register(&timed_gpio_driver); -} - -static void __exit timed_gpio_exit(void) -{ - platform_driver_unregister(&timed_gpio_driver); -} - -module_init(timed_gpio_init); -module_exit(timed_gpio_exit); - -MODULE_AUTHOR("Mike Lockwood "); -MODULE_DESCRIPTION("timed gpio driver"); -MODULE_LICENSE("GPL"); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/timed_gpio.h linux-2.6.32-rc6-staging/drivers/staging/android/timed_gpio.h --- linux-2.6.32-rc6-usb/drivers/staging/android/timed_gpio.h 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/timed_gpio.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,33 +0,0 @@ -/* include/linux/timed_gpio.h - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * -*/ - -#ifndef _LINUX_TIMED_GPIO_H -#define _LINUX_TIMED_GPIO_H - -#define TIMED_GPIO_NAME "timed-gpio" - -struct timed_gpio { - const char *name; - unsigned gpio; - int max_timeout; - u8 active_low; -}; - -struct timed_gpio_platform_data { - int num_gpios; - struct timed_gpio *gpios; -}; - -#endif diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/timed_output.c linux-2.6.32-rc6-staging/drivers/staging/android/timed_output.c --- linux-2.6.32-rc6-usb/drivers/staging/android/timed_output.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/timed_output.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,121 +0,0 @@ -/* drivers/misc/timed_output.c - * - * Copyright (C) 2009 Google, Inc. - * Author: Mike Lockwood - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include - -#include "timed_output.h" - -static struct class *timed_output_class; -static atomic_t device_count; - -static ssize_t enable_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct timed_output_dev *tdev = dev_get_drvdata(dev); - int remaining = tdev->get_time(tdev); - - return sprintf(buf, "%d\n", remaining); -} - -static ssize_t enable_store( - struct device *dev, struct device_attribute *attr, - const char *buf, size_t size) -{ - struct timed_output_dev *tdev = dev_get_drvdata(dev); - int value; - - sscanf(buf, "%d", &value); - tdev->enable(tdev, value); - - return size; -} - -static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); - -static int create_timed_output_class(void) -{ - if (!timed_output_class) { - timed_output_class = class_create(THIS_MODULE, "timed_output"); - if (IS_ERR(timed_output_class)) - return PTR_ERR(timed_output_class); - atomic_set(&device_count, 0); - } - - return 0; -} - -int timed_output_dev_register(struct timed_output_dev *tdev) -{ - int ret; - - if (!tdev || !tdev->name || !tdev->enable || !tdev->get_time) - return -EINVAL; - - ret = create_timed_output_class(); - if (ret < 0) - return ret; - - tdev->index = atomic_inc_return(&device_count); - tdev->dev = device_create(timed_output_class, NULL, - MKDEV(0, tdev->index), NULL, tdev->name); - if (IS_ERR(tdev->dev)) - return PTR_ERR(tdev->dev); - - ret = device_create_file(tdev->dev, &dev_attr_enable); - if (ret < 0) - goto err_create_file; - - dev_set_drvdata(tdev->dev, tdev); - tdev->state = 0; - return 0; - -err_create_file: - device_destroy(timed_output_class, MKDEV(0, tdev->index)); - printk(KERN_ERR "timed_output: Failed to register driver %s\n", - tdev->name); - - return ret; -} -EXPORT_SYMBOL_GPL(timed_output_dev_register); - -void timed_output_dev_unregister(struct timed_output_dev *tdev) -{ - device_remove_file(tdev->dev, &dev_attr_enable); - device_destroy(timed_output_class, MKDEV(0, tdev->index)); - dev_set_drvdata(tdev->dev, NULL); -} -EXPORT_SYMBOL_GPL(timed_output_dev_unregister); - -static int __init timed_output_init(void) -{ - return create_timed_output_class(); -} - -static void __exit timed_output_exit(void) -{ - class_destroy(timed_output_class); -} - -module_init(timed_output_init); -module_exit(timed_output_exit); - -MODULE_AUTHOR("Mike Lockwood "); -MODULE_DESCRIPTION("timed output class driver"); -MODULE_LICENSE("GPL"); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/timed_output.h linux-2.6.32-rc6-staging/drivers/staging/android/timed_output.h --- linux-2.6.32-rc6-usb/drivers/staging/android/timed_output.h 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/timed_output.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,37 +0,0 @@ -/* include/linux/timed_output.h - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * -*/ - -#ifndef _LINUX_TIMED_OUTPUT_H -#define _LINUX_TIMED_OUTPUT_H - -struct timed_output_dev { - const char *name; - - /* enable the output and set the timer */ - void (*enable)(struct timed_output_dev *sdev, int timeout); - - /* returns the current number of milliseconds remaining on the timer */ - int (*get_time)(struct timed_output_dev *sdev); - - /* private data */ - struct device *dev; - int index; - int state; -}; - -extern int timed_output_dev_register(struct timed_output_dev *dev); -extern void timed_output_dev_unregister(struct timed_output_dev *dev); - -#endif diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/android/TODO linux-2.6.32-rc6-staging/drivers/staging/android/TODO --- linux-2.6.32-rc6-usb/drivers/staging/android/TODO 2009-03-23 16:12:14.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/android/TODO 1969-12-31 16:00:00.000000000 -0800 @@ -1,10 +0,0 @@ -TODO: - - checkpatch.pl cleanups - - sparse fixes - - rename files to be not so "generic" - - make sure things build as modules properly - - add proper arch dependancies as needed - - audit userspace interfaces to make sure they are sane - -Please send patches to Greg Kroah-Hartman and Cc: -Brian Swetland diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/arlan/TODO linux-2.6.32-rc6-staging/drivers/staging/arlan/TODO --- linux-2.6.32-rc6-usb/drivers/staging/arlan/TODO 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/arlan/TODO 2009-11-06 20:57:54.000000000 -0800 @@ -0,0 +1,7 @@ +TODO: + - step up and maintain this driver to ensure that it continues + to work. Having the hardware for this is pretty much a + requirement. If this does not happen, the will be removed in + the 2.6.35 kernel release. + +Please send patches to Greg Kroah-Hartman . diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/b3dfg/b3dfg.c linux-2.6.32-rc6-staging/drivers/staging/b3dfg/b3dfg.c --- linux-2.6.32-rc6-usb/drivers/staging/b3dfg/b3dfg.c 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/b3dfg/b3dfg.c 2009-11-06 20:57:47.000000000 -0800 @@ -468,7 +468,6 @@ static int enable_transmission(struct b3dfg_dev *fgdev) { - u16 command; unsigned long flags; struct device *dev = &fgdev->pdev->dev; @@ -480,17 +479,6 @@ return -EINVAL; } - /* - * Check we're a bus master. - * TODO: I think we can remove this having added the pci_set_master call - */ - pci_read_config_word(fgdev->pdev, PCI_COMMAND, &command); - if (!(command & PCI_COMMAND_MASTER)) { - dev_err(dev, "not a bus master, force-enabling\n"); - pci_write_config_word(fgdev->pdev, PCI_COMMAND, - command | PCI_COMMAND_MASTER); - } - spin_lock_irqsave(&fgdev->buffer_lock, flags); /* Handle racing enable_transmission calls. */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_compat32.c linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_compat32.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_compat32.c 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_compat32.c 2009-11-06 20:57:47.000000000 -0800 @@ -27,16 +27,12 @@ #define __NO_VERSION__ #include "comedi.h" #include -#include +#include #include "comedi_compat32.h" #ifdef CONFIG_COMPAT -#ifndef HAVE_COMPAT_IOCTL -#include /* for (un)register_ioctl32_conversion */ -#endif - #define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct) #define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct) /* N.B. COMEDI32_CMD and COMEDI_CMD ought to use _IOWR, not _IOR. @@ -101,22 +97,9 @@ if (!file->f_op) return -ENOTTY; -#ifdef HAVE_UNLOCKED_IOCTL - if (file->f_op->unlocked_ioctl) { - int rc = (int)(*file->f_op->unlocked_ioctl) (file, cmd, arg); - if (rc == -ENOIOCTLCMD) - rc = -ENOTTY; - return rc; - } -#endif - if (file->f_op->ioctl) { - int rc; - lock_kernel(); - rc = (*file->f_op->ioctl) (file->f_dentry->d_inode, - file, cmd, arg); - unlock_kernel(); - return rc; - } + if (file->f_op->unlocked_ioctl) + return file->f_op->unlocked_ioctl(file, cmd, arg); + return -ENOTTY; } @@ -186,8 +169,8 @@ } /* Copy 32-bit cmd structure to native cmd structure. */ -static int get_compat_cmd(struct comedi_cmd __user * cmd, - struct comedi32_cmd_struct __user * cmd32) +static int get_compat_cmd(struct comedi_cmd __user *cmd, + struct comedi32_cmd_struct __user *cmd32) { int err; union { @@ -237,8 +220,8 @@ } /* Copy native cmd structure to 32-bit cmd structure. */ -static int put_compat_cmd(struct comedi32_cmd_struct __user * cmd32, - struct comedi_cmd __user * cmd) +static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, + struct comedi_cmd __user *cmd) { int err; unsigned int temp; @@ -328,8 +311,8 @@ } /* Copy 32-bit insn structure to native insn structure. */ -static int get_compat_insn(struct comedi_insn __user * insn, - struct comedi32_insn_struct __user * insn32) +static int get_compat_insn(struct comedi_insn __user *insn, + struct comedi32_insn_struct __user *insn32) { int err; union { @@ -372,9 +355,9 @@ insnlist32 = compat_ptr(arg); /* Get 32-bit insnlist structure. */ - if (!access_ok(VERIFY_READ, insnlist32, sizeof(*insnlist32))) { + if (!access_ok(VERIFY_READ, insnlist32, sizeof(*insnlist32))) return -EFAULT; - } + err = 0; err |= __get_user(n_insns, &insnlist32->n_insns); err |= __get_user(uptr, &insnlist32->insns); @@ -387,9 +370,9 @@ insn[n_insns])); /* Set native insnlist structure. */ - if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) { + if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) return -EFAULT; - } + err |= __put_user(n_insns, &s->insnlist.n_insns); err |= __put_user(&s->insn[0], &s->insnlist.insns); if (err) @@ -472,8 +455,6 @@ return rc; } -#ifdef HAVE_COMPAT_IOCTL /* defined in 2.6.11 onwards */ - /* compat_ioctl file operation. */ /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */ long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -481,106 +462,4 @@ return raw_ioctl(file, cmd, arg); } -#else /* HAVE_COMPAT_IOCTL */ - -/* - * Brain-dead ioctl compatibility for 2.6.10 and earlier. - * - * It's brain-dead because cmd numbers need to be unique system-wide! - * The comedi driver could end up attempting to execute ioctls for non-Comedi - * devices because it registered the system-wide cmd code first. Similarly, - * another driver could end up attempting to execute ioctls for a Comedi - * device because it registered the cmd code first. Chaos ensues. - */ - -/* Handler for all 32-bit ioctl codes registered by this driver. */ -static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, - struct file *file) -{ - int rc; - - /* Make sure we are dealing with a Comedi device. */ - if (imajor(file->f_dentry->d_inode) != COMEDI_MAJOR) - return -ENOTTY; - - rc = raw_ioctl(file, cmd, arg); - /* Do not return -ENOIOCTLCMD. */ - if (rc == -ENOIOCTLCMD) - rc = -ENOTTY; - - return rc; -} - -struct ioctl32_map { - unsigned int cmd; - int (*handler) (unsigned int, unsigned int, unsigned long, - struct file *); - int registered; -}; - -static struct ioctl32_map comedi_ioctl32_map[] = { - {COMEDI_DEVCONFIG, mapped_ioctl, 0}, - {COMEDI_DEVINFO, mapped_ioctl, 0}, - {COMEDI_SUBDINFO, mapped_ioctl, 0}, - {COMEDI_BUFCONFIG, mapped_ioctl, 0}, - {COMEDI_BUFINFO, mapped_ioctl, 0}, - {COMEDI_LOCK, mapped_ioctl, 0}, - {COMEDI_UNLOCK, mapped_ioctl, 0}, - {COMEDI_CANCEL, mapped_ioctl, 0}, - {COMEDI_POLL, mapped_ioctl, 0}, - {COMEDI32_CHANINFO, mapped_ioctl, 0}, - {COMEDI32_RANGEINFO, mapped_ioctl, 0}, - {COMEDI32_CMD, mapped_ioctl, 0}, - {COMEDI32_CMDTEST, mapped_ioctl, 0}, - {COMEDI32_INSNLIST, mapped_ioctl, 0}, - {COMEDI32_INSN, mapped_ioctl, 0}, -}; - -#define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map) - -/* Register system-wide 32-bit ioctl handlers. */ -void comedi_register_ioctl32(void) -{ - int n, rc; - - for (n = 0; n < NUM_IOCTL32_MAPS; n++) { - rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd, - comedi_ioctl32_map[n].handler); - if (rc) { - printk(KERN_WARNING - "comedi: failed to register 32-bit " - "compatible ioctl handler for 0x%X - " - "expect bad things to happen!\n", - comedi_ioctl32_map[n].cmd); - } - comedi_ioctl32_map[n].registered = !rc; - } -} - -/* Unregister system-wide 32-bit ioctl translations. */ -void comedi_unregister_ioctl32(void) -{ - int n, rc; - - for (n = 0; n < NUM_IOCTL32_MAPS; n++) { - if (comedi_ioctl32_map[n].registered) { - rc = unregister_ioctl32_conversion(comedi_ioctl32_map - [n].cmd, - comedi_ioctl32_map - [n].handler); - if (rc) { - printk(KERN_ERR - "comedi: failed to unregister 32-bit " - "compatible ioctl handler for 0x%X - " - "expect kernel Oops!\n", - comedi_ioctl32_map[n].cmd); - } else { - comedi_ioctl32_map[n].registered = 0; - } - } - } -} - -#endif /* HAVE_COMPAT_IOCTL */ - #endif /* CONFIG_COMPAT */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_compat32.h linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_compat32.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_compat32.h 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_compat32.h 2009-11-06 20:57:47.000000000 -0800 @@ -28,30 +28,16 @@ #define _COMEDI_COMPAT32_H #include -#include /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */ +#include #ifdef CONFIG_COMPAT -#ifdef HAVE_COMPAT_IOCTL - extern long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -#define comedi_register_ioctl32() do {} while (0) -#define comedi_unregister_ioctl32() do {} while (0) - -#else /* HAVE_COMPAT_IOCTL */ - -#define comedi_compat_ioctl 0 /* NULL */ -extern void comedi_register_ioctl32(void); -extern void comedi_unregister_ioctl32(void); - -#endif /* HAVE_COMPAT_IOCTL */ #else /* CONFIG_COMPAT */ #define comedi_compat_ioctl 0 /* NULL */ -#define comedi_register_ioctl32() do {} while (0) -#define comedi_unregister_ioctl32() do {} while (0) #endif /* CONFIG_COMPAT */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/comedidev.h linux-2.6.32-rc6-staging/drivers/staging/comedi/comedidev.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/comedidev.h 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/comedidev.h 2009-11-06 20:57:47.000000000 -0800 @@ -49,7 +49,8 @@ } while (0) #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) -#define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, COMEDI_MINORVERSION, COMEDI_MICROVERSION) +#define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \ + COMEDI_MINORVERSION, COMEDI_MICROVERSION) #define COMEDI_RELEASE VERSION #define COMEDI_INITCLEANUP_NOMODULE(x) \ @@ -58,12 +59,12 @@ static void __exit x ## _cleanup_module(void) \ {comedi_driver_unregister(&(x)); } \ module_init(x ## _init_module); \ - module_exit(x ## _cleanup_module); \ + module_exit(x ## _cleanup_module); #define COMEDI_MODULE_MACROS \ MODULE_AUTHOR("Comedi http://www.comedi.org"); \ MODULE_DESCRIPTION("Comedi low-level driver"); \ - MODULE_LICENSE("GPL"); \ + MODULE_LICENSE("GPL"); #define COMEDI_INITCLEANUP(x) \ COMEDI_MODULE_MACROS \ @@ -75,7 +76,8 @@ { \ return comedi_pci_auto_config(dev, comedi_driver.driver_name); \ } \ - static void __devexit comedi_driver ## _pci_remove(struct pci_dev *dev) \ + static void __devexit comedi_driver ## _pci_remove(\ + struct pci_dev *dev) \ { \ comedi_pci_auto_unconfig(dev); \ } \ @@ -91,7 +93,8 @@ retval = comedi_driver_register(&comedi_driver); \ if (retval < 0) \ return retval; \ - comedi_driver ## _pci_driver.name = (char *)comedi_driver.driver_name; \ + comedi_driver ## _pci_driver.name = \ + (char *)comedi_driver.driver_name; \ return pci_register_driver(&comedi_driver ## _pci_driver); \ } \ static void __exit comedi_driver ## _cleanup_module(void) \ @@ -170,14 +173,15 @@ struct comedi_cmd *); int (*poll) (struct comedi_device *, struct comedi_subdevice *); int (*cancel) (struct comedi_device *, struct comedi_subdevice *); - /* int (*do_lock)(struct comedi_device *,struct comedi_subdevice *); */ - /* int (*do_unlock)(struct comedi_device *,struct comedi_subdevice *); */ + /* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */ + /* int (*do_unlock)(struct comedi_device *, \ + struct comedi_subdevice *); */ /* called when the buffer changes */ - int (*buf_change) (struct comedi_device * dev, - struct comedi_subdevice * s, unsigned long new_size); + int (*buf_change) (struct comedi_device *dev, + struct comedi_subdevice *s, unsigned long new_size); - void (*munge) (struct comedi_device * dev, struct comedi_subdevice * s, + void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, unsigned int start_chan_index); enum dma_data_direction async_dma_dir; @@ -198,16 +202,22 @@ void *prealloc_buf; /* pre-allocated buffer */ unsigned int prealloc_bufsz; /* buffer size, in bytes */ - struct comedi_buf_page *buf_page_list; /* virtual and dma address of each page */ + /* virtual and dma address of each page */ + struct comedi_buf_page *buf_page_list; unsigned n_buf_pages; /* num elements in buf_page_list */ unsigned int max_bufsize; /* maximum buffer size, bytes */ - unsigned int mmap_count; /* current number of mmaps of prealloc_buf */ + /* current number of mmaps of prealloc_buf */ + unsigned int mmap_count; - unsigned int buf_write_count; /* byte count for writer (write completed) */ - unsigned int buf_write_alloc_count; /* byte count for writer (allocated for writing) */ - unsigned int buf_read_count; /* byte count for reader (read completed) */ - unsigned int buf_read_alloc_count; /* byte count for reader (allocated for reading) */ + /* byte count for writer (write completed) */ + unsigned int buf_write_count; + /* byte count for writer (allocated for writing) */ + unsigned int buf_write_alloc_count; + /* byte count for reader (read completed) */ + unsigned int buf_read_count; + /* byte count for reader (allocated for reading) */ + unsigned int buf_read_alloc_count; unsigned int buf_write_ptr; /* buffer marker for writer */ unsigned int buf_read_ptr; /* buffer marker for reader */ @@ -233,7 +243,7 @@ int (*cb_func) (unsigned int flags, void *); void *cb_arg; - int (*inttrig) (struct comedi_device * dev, struct comedi_subdevice * s, + int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s, unsigned int x); }; @@ -283,8 +293,8 @@ struct fasync_struct *async_queue; - void (*open) (struct comedi_device * dev); - void (*close) (struct comedi_device * dev); + void (*open) (struct comedi_device *dev); + void (*close) (struct comedi_device *dev); }; struct comedi_device_file_info { @@ -318,9 +328,8 @@ struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor); -static inline struct comedi_subdevice *comedi_get_read_subdevice(const struct - comedi_device_file_info - *info) +static inline struct comedi_subdevice *comedi_get_read_subdevice( + const struct comedi_device_file_info *info) { if (info->read_subdevice) return info->read_subdevice; @@ -329,9 +338,8 @@ return info->device->read_subdev; } -static inline struct comedi_subdevice *comedi_get_write_subdevice(const struct - comedi_device_file_info - *info) +static inline struct comedi_subdevice *comedi_get_write_subdevice( + const struct comedi_device_file_info *info) { if (info->write_subdevice) return info->write_subdevice; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_fops.c linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_fops.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi_fops.c 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi_fops.c 2009-11-06 20:57:47.000000000 -0800 @@ -110,13 +110,8 @@ static struct device_attribute dev_attr_max_write_buffer_kb; static struct device_attribute dev_attr_write_buffer_kb; -#ifdef HAVE_UNLOCKED_IOCTL static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -#else -static int comedi_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -#endif { const unsigned minor = iminor(file->f_dentry->d_inode); struct comedi_device_file_info *dev_file_info = @@ -1867,14 +1862,8 @@ const struct file_operations comedi_fops = { .owner = THIS_MODULE, -#ifdef HAVE_UNLOCKED_IOCTL .unlocked_ioctl = comedi_unlocked_ioctl, -#else - .ioctl = comedi_ioctl, -#endif -#ifdef HAVE_COMPAT_IOCTL .compat_ioctl = comedi_compat_ioctl, -#endif .open = comedi_open, .release = comedi_close, .read = comedi_read, @@ -1959,8 +1948,6 @@ } } - comedi_register_ioctl32(); - return 0; } @@ -1977,8 +1964,6 @@ unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); comedi_proc_cleanup(); - - comedi_unregister_ioctl32(); } module_init(comedi_init); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi.h linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/comedi.h 2009-11-04 15:20:32.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/comedi.h 2009-11-06 20:57:47.000000000 -0800 @@ -24,10 +24,6 @@ #ifndef _COMEDI_H #define _COMEDI_H -#ifdef __cplusplus -extern "C" { -#endif - #define COMEDI_MAJORVERSION 0 #define COMEDI_MINORVERSION 7 #define COMEDI_MICROVERSION 76 @@ -871,8 +867,4 @@ AMPLC_DIO_GAT_RESERVED7 }; -#ifdef __cplusplus -} -#endif - #endif /* _COMEDI_H */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/8253.h linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/8253.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/8253.h 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/8253.h 2009-11-06 20:57:47.000000000 -0800 @@ -206,7 +206,8 @@ } *nanosec = div1 * div2 * i8253_osc_base; - *d1 = div1 & 0xffff; /* masking is done since counter maps zero to 0x10000 */ + /* masking is done since counter maps zero to 0x10000 */ + *d1 = div1 & 0xffff; *d2 = div2 & 0xffff; return; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/8255.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/8255.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/8255.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/8255.c 2009-11-06 20:57:47.000000000 -0800 @@ -132,6 +132,7 @@ comedi_event(dev, s); } +EXPORT_SYMBOL(subdev_8255_interrupt); static int subdev_8255_cb(int dir, int port, int data, unsigned long arg) { @@ -179,15 +180,14 @@ unsigned int bits; mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) { + if (mask & 0x0000ff) bits = 0x0000ff; - } else if (mask & 0x00ff00) { + else if (mask & 0x00ff00) bits = 0x00ff00; - } else if (mask & 0x0f0000) { + else if (mask & 0x0f0000) bits = 0x0f0000; - } else { + else bits = 0xf00000; - } switch (data[0]) { case INSN_CONFIG_DIO_INPUT: @@ -333,11 +333,10 @@ return -ENOMEM; CALLBACK_ARG = arg; - if (cb == NULL) { + if (cb == NULL) CALLBACK_FUNC = subdev_8255_cb; - } else { + else CALLBACK_FUNC = cb; - } s->insn_bits = subdev_8255_insn; s->insn_config = subdev_8255_insn_config; @@ -347,6 +346,7 @@ return 0; } +EXPORT_SYMBOL(subdev_8255_init); int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), @@ -366,6 +366,7 @@ return 0; } +EXPORT_SYMBOL(subdev_8255_init_irq); void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -378,6 +379,7 @@ kfree(s->private); } } +EXPORT_SYMBOL(subdev_8255_cleanup); /* @@ -448,8 +450,3 @@ return 0; } - -EXPORT_SYMBOL(subdev_8255_init); -EXPORT_SYMBOL(subdev_8255_init_irq); -EXPORT_SYMBOL(subdev_8255_cleanup); -EXPORT_SYMBOL(subdev_8255_interrupt); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/acl7225b.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/acl7225b.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/acl7225b.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/acl7225b.c 2009-11-06 20:57:47.000000000 -0800 @@ -94,10 +94,11 @@ iobase = it->options[0]; iorange = this_board->io_range; - printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor, + printk(KERN_INFO "comedi%d: acl7225b: board=%s 0x%04x\n", dev->minor, this_board->name, iobase); if (!request_region(iobase, iorange, "acl7225b")) { - printk("I/O port conflict\n"); + printk(KERN_ERR "comedi%d: request_region failed - I/O port conflict\n", + dev->minor); return -EIO; } dev->board_name = this_board->name; @@ -137,14 +138,12 @@ s->range_table = &range_digital; s->private = (void *)ACL7225_DI_LO; - printk("\n"); - return 0; } static int acl7225b_detach(struct comedi_device *dev) { - printk("comedi%d: acl7225b: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: acl7225b: remove\n", dev->minor); if (dev->iobase) release_region(dev->iobase, this_board->io_range); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c 2009-11-06 20:57:47.000000000 -0800 @@ -1386,8 +1386,7 @@ /* Test the timout parameter */ /*****************************/ - if ((ui_TimeOut >= 0) - && (ui_TimeOut <= 65535UL)) { + if (ui_TimeOut <= 65535UL) { for (;;) { /*******************/ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c 2009-11-06 20:57:47.000000000 -0800 @@ -150,7 +150,7 @@ unsigned int ui_TmpValue = 0; unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); - if (ui_Channel >= 0 && ui_Channel <= 31) { + if (ui_Channel <= 31) { ui_TmpValue = (unsigned int) inl(devpriv->iobase + APCI1032_DIGITAL_IP); /* * since only 1 channel reqd to bring it to last bit it is rotated 8 diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c 2009-11-06 20:57:47.000000000 -0800 @@ -968,7 +968,7 @@ switch (data[0]) { case 0: - if (ui_Channel >= 0 && ui_Channel <= 15) { + if (ui_Channel <= 15) { ui_TmpValue = (unsigned int) inw(devpriv->i_IobaseAddon + APCI1500_DIGITAL_IP); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c 2009-11-06 20:57:47.000000000 -0800 @@ -79,7 +79,7 @@ unsigned int ui_TmpValue = 0; unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); - if (ui_Channel >= 0 && ui_Channel <= 7) { + if (ui_Channel <= 7) { ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI1516_DIGITAL_IP); /* since only 1 channel reqd to bring it to last bit it is rotated */ /* 8 +(chan - 1) times then ANDed with 1 for last bit. */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 2009-11-06 20:57:47.000000000 -0800 @@ -154,7 +154,7 @@ unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); - if (ui_Channel >= 0 && ui_Channel <= 31) { + if (ui_Channel <= 31) { ui_TmpValue = (unsigned int) inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_IP); /* diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c 2009-11-06 20:57:47.000000000 -0800 @@ -117,7 +117,7 @@ unsigned int ui_NoOfChannel; unsigned int ui_Temp, ui_Temp1; ui_NoOfChannel = CR_CHAN(insn->chanspec); - if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) { + if (ui_NoOfChannel > 15) { comedi_error(dev, "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); return -EINVAL; @@ -272,7 +272,7 @@ unsigned int ui_Temp; unsigned int ui_NoOfChannel; ui_NoOfChannel = CR_CHAN(insn->chanspec); - if ((ui_NoOfChannel < 0) || (ui_NoOfChannel > 15)) { + if (ui_NoOfChannel > 15) { comedi_error(dev, "Invalid Channel Numbers !!!, Channel Numbers must be between 0 and 15\n"); return -EINVAL; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c 2009-11-06 20:57:47.000000000 -0800 @@ -79,7 +79,7 @@ unsigned int ui_TmpValue = 0; unsigned int ui_Channel; ui_Channel = CR_CHAN(insn->chanspec); - if (ui_Channel >= 0 && ui_Channel <= 7) { + if (ui_Channel <= 7) { ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI2200_DIGITAL_IP); *data = (ui_TmpValue >> ui_Channel) & 0x1; } /* if(ui_Channel >= 0 && ui_Channel <=7) */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 2009-11-06 20:57:47.000000000 -0800 @@ -2350,7 +2350,7 @@ ui_Chan = CR_CHAN(insn->chanspec); /* channel specified */ /* this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); */ - if (ui_Chan >= 0 && ui_Chan <= 3) { + if (ui_Chan <= 3) { ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS); /* @@ -2539,8 +2539,7 @@ "Not a valid Data !!! ,Data should be 1 or 0\n"); return -EINVAL; } - if ((ui_NoOfChannel > (this_board->i_NbrDoChannel - 1)) - || (ui_NoOfChannel < 0)) { + if (ui_NoOfChannel > this_board->i_NbrDoChannel - 1) { comedi_error(dev, "This board doesn't have specified channel !!! \n"); return -EINVAL; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c 2009-11-06 20:57:47.000000000 -0800 @@ -461,7 +461,7 @@ if (s_BoardInfos[dev->minor].i_ConnectionType == 1) { /* if diff */ - if ((ui_Channel_num >= 0) && (ui_Channel_num <= 1)) + if (ui_Channel_num <= 1) i_DiffChannel = ui_Channel_num, i_Module = 0; else if ((ui_Channel_num >= 2) && (ui_Channel_num <= 3)) i_DiffChannel = ui_Channel_num - 2, i_Module = 1; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c 2009-11-06 20:57:47.000000000 -0800 @@ -148,7 +148,7 @@ /* Test the convert time value */ /*******************************/ - if ((dw_ReloadValue >= 0) && (dw_ReloadValue <= 65535)) { + if (dw_ReloadValue <= 65535) { dw_TestReloadValue = dw_ReloadValue; if (b_TimeBase == 1) { diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci6208.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci6208.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci6208.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci6208.c 2009-11-06 20:57:47.000000000 -0800 @@ -133,9 +133,11 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); -/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* static int pci6208_dio_insn_bits (struct comedi_device *dev, + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data); */ -/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* static int pci6208_dio_insn_config(struct comedi_device *dev, + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data); */ /* @@ -151,7 +153,7 @@ int retval; unsigned long io_base; - printk("comedi%d: pci6208: ", dev->minor); + printk(KERN_INFO "comedi%d: pci6208: ", dev->minor); retval = alloc_private(dev, sizeof(struct pci6208_private)); if (retval < 0) @@ -195,7 +197,7 @@ /* s->insn_bits = pci6208_dio_insn_bits; */ /* s->insn_config = pci6208_dio_insn_config; */ - printk("attached\n"); + printk(KERN_INFO "attached\n"); return 1; } @@ -210,12 +212,11 @@ */ static int pci6208_detach(struct comedi_device *dev) { - printk("comedi%d: pci6208: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pci6208: remove\n", dev->minor); if (devpriv && devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } @@ -266,7 +267,8 @@ * useful to applications if you implement the insn_bits interface. * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ -/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* static int pci6208_dio_insn_bits(struct comedi_device *dev, + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data) */ /* { */ /* if(insn->n!=2)return -EINVAL; */ @@ -290,7 +292,8 @@ /* return 2; */ /* } */ -/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */ +/* static int pci6208_dio_insn_config(struct comedi_device *dev, + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data) */ /* { */ /* int chan=CR_CHAN(insn->chanspec); */ @@ -320,10 +323,16 @@ pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) { for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) { - if (pci6208_boards[i].dev_id == pci_dev->device) { - /* was a particular bus/slot requested? */ + if (pci6208_boards[i].dev_id == + pci_dev->device) { + /* + * was a particular bus/slot requested? + */ if ((bus != 0) || (slot != 0)) { - /* are we on the wrong bus/slot? */ + /* + * are we on the + * wrong bus/slot? + */ if (pci_dev->bus->number != bus || PCI_SLOT(pci_dev->devfn) @@ -338,8 +347,9 @@ } } - printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + printk(KERN_ERR "comedi%d: no supported board found! " + "(req. bus/slot : %d/%d)\n", + dev->minor, bus, slot); return -EIO; found: @@ -368,17 +378,20 @@ /* Enable PCI device and request regions */ if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) { - printk - ("comedi%d: Failed to enable PCI device and request regions\n", - dev_minor); + printk(KERN_ERR "comedi%d: Failed to enable PCI device " + "and request regions\n", + dev_minor); return -EIO; } - /* Read local configuration register base address [PCI_BASE_ADDRESS #1]. */ + /* Read local configuration register + * base address [PCI_BASE_ADDRESS #1]. + */ lcr_io_base = pci_resource_start(pci_dev, 1); lcr_io_range = pci_resource_len(pci_dev, 1); - printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n", - dev_minor, lcr_io_base, lcr_io_range); + printk(KERN_INFO "comedi%d: local config registers at address" + " 0x%4lx [0x%4lx]\n", + dev_minor, lcr_io_base, lcr_io_range); /* Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */ io_base = pci_resource_start(pci_dev, 2); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci7296.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci7296.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci7296.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci7296.c 2009-11-06 20:57:47.000000000 -0800 @@ -82,8 +82,7 @@ int bus, slot; int ret; - printk("comedi: attempt to attach...\n"); - printk("comedi%d: adl_pci7432\n", dev->minor); + printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor); dev->board_name = "pci7432"; bus = it->options[0]; @@ -110,14 +109,14 @@ } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) { - printk - ("comedi%d: Failed to enable PCI device and request regions\n", + printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } dev->iobase = pci_resource_start(pcidev, 2); - printk("comedi: base addr %4lx\n", dev->iobase); + printk(KERN_INFO "comedi: base addr %4lx\n", + dev->iobase); /* four 8255 digital io subdevices */ s = dev->subdevices + 0; @@ -145,25 +144,25 @@ if (ret < 0) return ret; - printk("attached\n"); + printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", + dev->minor); return 1; } } - printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", dev->minor, bus, slot); return -EIO; } static int adl_pci7296_detach(struct comedi_device *dev) { - printk("comedi%d: pci7432: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor); if (devpriv && devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } /* detach four 8255 digital io subdevices */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci7432.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci7432.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci7432.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci7432.c 2009-11-06 20:57:47.000000000 -0800 @@ -90,8 +90,7 @@ struct comedi_subdevice *s; int bus, slot; - printk("comedi: attempt to attach...\n"); - printk("comedi%d: adl_pci7432\n", dev->minor); + printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor); dev->board_name = "pci7432"; bus = it->options[0]; @@ -118,13 +117,13 @@ } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) { - printk - ("comedi%d: Failed to enable PCI device and request regions\n", + printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } dev->iobase = pci_resource_start(pcidev, 2); - printk("comedi: base addr %4lx\n", dev->iobase); + printk(KERN_INFO "comedi: base addr %4lx\n", + dev->iobase); s = dev->subdevices + 0; s->type = COMEDI_SUBD_DI; @@ -148,25 +147,24 @@ s->range_table = &range_digital; s->insn_bits = adl_pci7432_do_insn_bits; - printk("comedi: attached\n"); - + printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", + dev->minor); return 1; } } - printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", dev->minor, bus, slot); return -EIO; } static int adl_pci7432_detach(struct comedi_device *dev) { - printk("comedi%d: pci7432: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor); if (devpriv && devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } @@ -178,8 +176,8 @@ struct comedi_insn *insn, unsigned int *data) { - printk("comedi: pci7432_do_insn_bits called\n"); - printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); + printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n"); + printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]); if (insn->n != 2) return -EINVAL; @@ -188,7 +186,7 @@ s->state &= ~data[0]; s->state |= (data[0] & data[1]); - printk("comedi: out: %8x on iobase %4lx\n", s->state, + printk(KERN_DEBUG "comedi: out: %8x on iobase %4lx\n", s->state, dev->iobase + PCI7432_DO); outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO); } @@ -200,14 +198,14 @@ struct comedi_insn *insn, unsigned int *data) { - printk("comedi: pci7432_di_insn_bits called\n"); - printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]); + printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n"); + printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]); if (insn->n != 2) return -EINVAL; data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff; - printk("comedi: data1 %8x\n", data[1]); + printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]); return 2; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci8164.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci8164.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/adl_pci8164.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/adl_pci8164.c 2009-11-06 20:57:47.000000000 -0800 @@ -35,6 +35,7 @@ */ #include "../comedidev.h" +#include #include #include "comedi_fc.h" #include "comedi_pci.h" @@ -128,8 +129,8 @@ struct comedi_subdevice *s; int bus, slot; - printk("comedi: attempt to attach...\n"); - printk("comedi%d: adl_pci8164\n", dev->minor); + printk(KERN_INFO "comedi: attempt to attach...\n"); + printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor); dev->board_name = "pci8164"; bus = it->options[0]; @@ -150,19 +151,18 @@ if (bus || slot) { /* requested particular bus/slot */ if (pcidev->bus->number != bus - || PCI_SLOT(pcidev->devfn) != slot) { + || PCI_SLOT(pcidev->devfn) != slot) continue; - } } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) { - printk - ("comedi%d: Failed to enable PCI device and request regions\n", - dev->minor); + printk(KERN_ERR "comedi%d: Failed to enable " + "PCI device and request regions\n", dev->minor); return -EIO; } dev->iobase = pci_resource_start(pcidev, 2); - printk("comedi: base addr %4lx\n", dev->iobase); + printk(KERN_DEBUG "comedi: base addr %4lx\n", + dev->iobase); s = dev->subdevices + 0; s->type = COMEDI_SUBD_PROC; @@ -204,25 +204,24 @@ s->insn_read = adl_pci8164_insn_read_buf1; s->insn_write = adl_pci8164_insn_write_buf1; - printk("comedi: attached\n"); + printk(KERN_INFO "comedi: attached\n"); return 1; } } - printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); + printk(KERN_ERR "comedi%d: no supported board found!" + "(req. bus/slot : %d/%d)\n", dev->minor, bus, slot); return -EIO; } static int adl_pci8164_detach(struct comedi_device *dev) { - printk("comedi%d: pci8164: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pci8164: remove\n", dev->minor); if (devpriv && devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } @@ -267,8 +266,9 @@ } data[0] = inw(dev->iobase + axis_reg + offset); - printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, - data[0], data[1], axisname); + printk(KERN_DEBUG "comedi: pci8164 %s read -> " + "%04X:%04X on axis %s\n", + action, data[0], data[1], axisname); } static int adl_pci8164_insn_read_msts(struct comedi_device *dev, @@ -347,8 +347,9 @@ outw(data[0], dev->iobase + axis_reg + offset); - printk("comedi: pci8164 %s write -> %04X:%04X on axis %s\n", action, - data[0], data[1], axisname); + printk(KERN_DEBUG "comedi: pci8164 %s write -> " + "%04X:%04X on axis %s\n", + action, data[0], data[1], axisname); } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/amplc_pc263.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/amplc_pc263.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/amplc_pc263.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/amplc_pc263.c 2009-11-06 20:57:47.000000000 -0800 @@ -117,7 +117,8 @@ /* this structure is for data unique to this hardware driver. If several hardware drivers keep similar information in this structure, - feel free to suggest moving the variable to the struct comedi_device struct. */ + feel free to suggest moving the variable to the struct comedi_device struct. +*/ #ifdef CONFIG_COMEDI_PCI struct pc263_private { /* PCI device. */ @@ -281,7 +282,8 @@ ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME); if (ret < 0) { printk(KERN_ERR - "comedi%d: error! cannot enable PCI device and request regions!\n", + "comedi%d: error! cannot enable PCI device and " + "request regions!\n", dev->minor); return ret; } @@ -290,9 +292,8 @@ #endif { ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE); - if (ret < 0) { + if (ret < 0) return ret; - } } dev->iobase = iobase; @@ -350,21 +351,18 @@ PC263_DRIVER_NAME); #ifdef CONFIG_COMEDI_PCI - if (devpriv) + if (devpriv) { #endif - { #ifdef CONFIG_COMEDI_PCI if (devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } else #endif { - if (dev->iobase) { + if (dev->iobase) release_region(dev->iobase, PC263_IO_SIZE); - } } } if (dev->board_name) { diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/cb_das16_cs.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/cb_das16_cs.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/cb_das16_cs.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/cb_das16_cs.c 2009-11-06 20:57:48.000000000 -0800 @@ -100,7 +100,7 @@ .detach = das16cs_detach, }; -static struct pcmcia_device *cur_dev = NULL; +static struct pcmcia_device *cur_dev; static const struct comedi_lrange das16cs_ai_range = { 4, { RANGE(-10, 10), @@ -169,9 +169,8 @@ id = get_prodid(dev, link); for (i = 0; i < n_boards; i++) { - if (das16cs_boards[i].device_id == id) { + if (das16cs_boards[i].device_id == id) return das16cs_boards + i; - } } printk("unknown board!\n"); @@ -197,16 +196,14 @@ printk("I/O base=0x%04lx ", dev->iobase); printk("fingerprint:\n"); - for (i = 0; i < 48; i += 2) { + for (i = 0; i < 48; i += 2) printk("%04x ", inw(dev->iobase + i)); - } printk("\n"); ret = request_irq(link->irq.AssignedIRQ, das16cs_interrupt, IRQF_SHARED, "cb_das16_cs", dev); - if (ret < 0) { + if (ret < 0) return ret; - } dev->irq = link->irq.AssignedIRQ; printk("irq=%u ", dev->irq); @@ -284,9 +281,8 @@ { printk("comedi%d: das16cs: remove\n", dev->minor); - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } return 0; } @@ -393,9 +389,10 @@ if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* step 2: make sure trigger sources are unique + * and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) err++; @@ -672,9 +669,10 @@ #ifdef PCMCIA_DEBUG static int pc_debug = PCMCIA_DEBUG; module_param(pc_debug, int, 0644); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +#define DEBUG(n, args...) if (pc_debug > (n)) printk(KERN_DEBUG args) static char *version = - "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)"; + "cb_das16_cs.c pcmcia code (David Schleef),"\ + " modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)"; #else #define DEBUG(n, args...) #endif @@ -869,7 +867,8 @@ link->io.BasePort2 = io->win[1].base; link->io.NumPorts2 = io->win[1].len; } - /* This reserves IO space but doesn't actually enable it */ + /* This reserves IO space + * but doesn't actually enable it */ if (pcmcia_request_io(link, &link->io)) goto next_entry; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/cb_pcidda.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/cb_pcidda.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/cb_pcidda.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/cb_pcidda.c 2009-11-06 20:57:47.000000000 -0800 @@ -497,7 +497,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/comedi_fc.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/comedi_fc.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/comedi_fc.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/comedi_fc.c 2009-11-06 20:57:47.000000000 -0800 @@ -53,7 +53,7 @@ retval = comedi_buf_write_alloc(async, num_bytes); if (retval != num_bytes) { - printk("comedi: buffer overrun\n"); + printk(KERN_WARNING "comedi: buffer overrun\n"); async->events |= COMEDI_CB_OVERFLOW; return 0; } @@ -65,7 +65,6 @@ return num_bytes; } - EXPORT_SYMBOL(cfc_write_array_to_buffer); unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd, @@ -84,7 +83,6 @@ return num_bytes; } - EXPORT_SYMBOL(cfc_read_array_from_buffer); unsigned int cfc_handle_events(struct comedi_device *dev, @@ -102,7 +100,6 @@ return events; } - EXPORT_SYMBOL(cfc_handle_events); MODULE_AUTHOR("Frank Mori Hess "); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dmm32at.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dmm32at.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dmm32at.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dmm32at.c 2009-11-06 20:57:47.000000000 -0800 @@ -629,7 +629,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dt2814.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dt2814.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dt2814.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dt2814.c 2009-11-06 20:57:47.000000000 -0800 @@ -175,7 +175,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->stop_src != TRIG_TIMER && cmd->stop_src != TRIG_EXT) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dt282x.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dt282x.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/dt282x.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/dt282x.c 2009-11-06 20:57:47.000000000 -0800 @@ -777,7 +777,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->scan_begin_src != TRIG_EXT) err++; @@ -1050,7 +1050,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/gsc_hpdi.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/gsc_hpdi.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/gsc_hpdi.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/gsc_hpdi.c 2009-11-06 20:57:47.000000000 -0800 @@ -55,7 +55,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int hpdi_detach(struct comedi_device *dev); -void abort_dma(struct comedi_device *dev, unsigned int channel); +static void abort_dma(struct comedi_device *dev, unsigned int channel); static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s); static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); @@ -110,7 +110,8 @@ int command_channel_valid(unsigned int channel) { if (channel == 0 || channel > 6) { - printk("gsc_hpdi: bug! invalid cable command channel\n"); + printk(KERN_WARNING + "gsc_hpdi: bug! invalid cable command channel\n"); return 0; } return 1; @@ -142,7 +143,8 @@ RX_FIFO_RESET_BIT = 0x4, TX_ENABLE_BIT = 0x10, RX_ENABLE_BIT = 0x20, - DEMAND_DMA_DIRECTION_TX_BIT = 0x40, /* for channel 0, channel 1 can only transmit (when present) */ + DEMAND_DMA_DIRECTION_TX_BIT = 0x40, + /* for ch 0, ch 1 can only transmit (when present) */ LINE_VALID_ON_STATUS_VALID_BIT = 0x80, START_TX_BIT = 0x10, CABLE_THROTTLE_ENABLE_BIT = 0x20, @@ -420,9 +422,11 @@ bits |= PLX_DMA_EN_READYIN_BIT; /* enable dma chaining */ bits |= PLX_EN_CHAIN_BIT; - /* enable interrupt on dma done (probably don't need this, since chain never finishes) */ + /* enable interrupt on dma done + * (probably don't need this, since chain never finishes) */ bits |= PLX_EN_DMA_DONE_INTR_BIT; - /* don't increment local address during transfers (we are transferring from a fixed fifo register) */ + /* don't increment local address during transfers + * (we are transferring from a fixed fifo register) */ bits |= PLX_LOCAL_ADDR_CONST_BIT; /* route dma interrupt to pci bus */ bits |= PLX_DMA_INTR_PCI_BIT; @@ -560,7 +564,7 @@ int i; int retval; - printk("comedi%d: gsc_hpdi\n", dev->minor); + printk(KERN_WARNING "comedi%d: gsc_hpdi\n", dev->minor); if (alloc_private(dev, sizeof(struct hpdi_private)) < 0) return -ENOMEM; @@ -588,11 +592,12 @@ } while (pcidev != NULL); } if (dev->board_ptr == NULL) { - printk("gsc_hpdi: no hpdi card found\n"); + printk(KERN_WARNING "gsc_hpdi: no hpdi card found\n"); return -EIO; } - printk("gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name, + printk(KERN_WARNING + "gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name, pcidev->bus->number, PCI_SLOT(pcidev->devfn)); if (comedi_pci_enable(pcidev, driver_hpdi.driver_name)) { @@ -618,7 +623,7 @@ ioremap(priv(dev)->hpdi_phys_iobase, pci_resource_len(pcidev, HPDI_BADDRINDEX)); if (!priv(dev)->plx9080_iobase || !priv(dev)->hpdi_iobase) { - printk(" failed to remap io memory\n"); + printk(KERN_WARNING " failed to remap io memory\n"); return -ENOMEM; } @@ -630,12 +635,13 @@ /* get irq */ if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, driver_hpdi.driver_name, dev)) { - printk(" unable to allocate irq %u\n", pcidev->irq); + printk(KERN_WARNING + " unable to allocate irq %u\n", pcidev->irq); return -EINVAL; } dev->irq = pcidev->irq; - printk(" irq %u\n", dev->irq); + printk(KERN_WARNING " irq %u\n", dev->irq); /* alocate pci dma buffers */ for (i = 0; i < NUM_DMA_BUFFERS; i++) { @@ -653,7 +659,8 @@ &priv(dev)-> dma_desc_phys_addr); if (priv(dev)->dma_desc_phys_addr & 0xf) { - printk(" dma descriptors not quad-word aligned (bug)\n"); + printk(KERN_WARNING + " dma descriptors not quad-word aligned (bug)\n"); return -EIO; } @@ -672,42 +679,39 @@ { unsigned int i; - printk("comedi%d: gsc_hpdi: remove\n", dev->minor); + printk(KERN_WARNING "comedi%d: gsc_hpdi: remove\n", dev->minor); if (dev->irq) free_irq(dev->irq, dev); - if (priv(dev)) { - if (priv(dev)->hw_dev) { - if (priv(dev)->plx9080_iobase) { - disable_plx_interrupts(dev); - iounmap((void *)priv(dev)->plx9080_iobase); - } - if (priv(dev)->hpdi_iobase) - iounmap((void *)priv(dev)->hpdi_iobase); - /* free pci dma buffers */ - for (i = 0; i < NUM_DMA_BUFFERS; i++) { - if (priv(dev)->dio_buffer[i]) - pci_free_consistent(priv(dev)->hw_dev, - DMA_BUFFER_SIZE, - priv(dev)-> - dio_buffer[i], - priv - (dev)->dio_buffer_phys_addr - [i]); - } - /* free dma descriptors */ - if (priv(dev)->dma_desc) + if ((priv(dev)) && (priv(dev)->hw_dev)) { + if (priv(dev)->plx9080_iobase) { + disable_plx_interrupts(dev); + iounmap((void *)priv(dev)->plx9080_iobase); + } + if (priv(dev)->hpdi_iobase) + iounmap((void *)priv(dev)->hpdi_iobase); + /* free pci dma buffers */ + for (i = 0; i < NUM_DMA_BUFFERS; i++) { + if (priv(dev)->dio_buffer[i]) pci_free_consistent(priv(dev)->hw_dev, - sizeof(struct plx_dma_desc) - * NUM_DMA_DESCRIPTORS, - priv(dev)->dma_desc, + DMA_BUFFER_SIZE, priv(dev)-> - dma_desc_phys_addr); - if (priv(dev)->hpdi_phys_iobase) { - comedi_pci_disable(priv(dev)->hw_dev); - } - pci_dev_put(priv(dev)->hw_dev); + dio_buffer[i], + priv + (dev)->dio_buffer_phys_addr + [i]); } + /* free dma descriptors */ + if (priv(dev)->dma_desc) + pci_free_consistent(priv(dev)->hw_dev, + sizeof(struct plx_dma_desc) + * NUM_DMA_DESCRIPTORS, + priv(dev)->dma_desc, + priv(dev)-> + dma_desc_phys_addr); + if (priv(dev)->hpdi_phys_iobase) + comedi_pci_disable(priv(dev)->hw_dev); + pci_dev_put(priv(dev)->hw_dev); } return 0; } @@ -810,15 +814,16 @@ if (err) return 4; - if (cmd->chanlist) { - for (i = 1; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != i) { - /* XXX could support 8 channels or 16 channels */ - comedi_error(dev, - "chanlist must be channels 0 to 31 in order"); - err++; - break; - } + if (!cmd->chanlist) + return 0; + + for (i = 1; i < cmd->chanlist_len; i++) { + if (CR_CHAN(cmd->chanlist[i]) != i) { + /* XXX could support 8 or 16 channels */ + comedi_error(dev, + "chanlist must be ch 0 to 31 in order"); + err++; + break; } } @@ -831,9 +836,9 @@ static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - if (priv(dev)->dio_config_output) { + if (priv(dev)->dio_config_output) return -EINVAL; - } else + else return di_cmd_test(dev, s, cmd); } @@ -899,9 +904,9 @@ static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - if (priv(dev)->dio_config_output) { + if (priv(dev)->dio_config_output) return -EINVAL; - } else + else return di_cmd(dev, s); } @@ -963,14 +968,12 @@ uint8_t dma0_status, dma1_status; unsigned long flags; - if (!dev->attached) { + if (!dev->attached) return IRQ_NONE; - } plx_status = readl(priv(dev)->plx9080_iobase + PLX_INTRCS_REG); - if ((plx_status & (ICS_DMA0_A | ICS_DMA1_A | ICS_LIA)) == 0) { + if ((plx_status & (ICS_DMA0_A | ICS_DMA1_A | ICS_LIA)) == 0) return IRQ_NONE; - } hpdi_intr_status = readl(priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG); hpdi_board_status = readl(priv(dev)->hpdi_iobase + BOARD_STATUS_REG); @@ -990,9 +993,8 @@ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG); DEBUG_PRINT("dma0 status 0x%x\n", dma0_status); - if (dma0_status & PLX_DMA_EN_BIT) { + if (dma0_status & PLX_DMA_EN_BIT) drain_dma_buffers(dev, 0); - } DEBUG_PRINT(" cleared dma ch0 interrupt\n"); } spin_unlock_irqrestore(&dev->spinlock, flags); @@ -1042,7 +1044,7 @@ return IRQ_HANDLED; } -void abort_dma(struct comedi_device *dev, unsigned int channel) +static void abort_dma(struct comedi_device *dev, unsigned int channel) { unsigned long flags; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/icp_multi.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/icp_multi.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/icp_multi.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/icp_multi.c 2009-11-06 20:57:48.000000000 -0800 @@ -46,7 +46,7 @@ Options: [0] - PCI bus number - if bus number and slot number are 0, - then driver search for first unused card + then driver search for first unused card [1] - PCI slot number */ @@ -133,7 +133,7 @@ Data & Structure declarations ============================================================================== */ -static unsigned short pci_list_builded = 0; /*>0 list of card is known */ +static unsigned short pci_list_builded; /*>0 list of card is known */ struct boardtype { const char *name; /* driver name */ @@ -176,13 +176,13 @@ #define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype)) static struct comedi_driver driver_icp_multi = { -driver_name:"icp_multi", -module:THIS_MODULE, -attach:icp_multi_attach, -detach:icp_multi_detach, -num_names:n_boardtypes, -board_name:&boardtypes[0].name, -offset:sizeof(struct boardtype), +driver_name: "icp_multi", +module : THIS_MODULE, +attach : icp_multi_attach, +detach : icp_multi_detach, +num_names : n_boardtypes, +board_name : &boardtypes[0].name, +offset : sizeof(struct boardtype), }; COMEDI_INITCLEANUP(driver_icp_multi); @@ -234,18 +234,18 @@ /* ============================================================================== - Name: icp_multi_insn_read_ai +Name: icp_multi_insn_read_ai - Description: - This function reads a single analogue input. +Description: + This function reads a single analogue input. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to analogue input data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to analogue input data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -256,7 +256,7 @@ int n, timeout; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: BGN: icp_multi_insn_read_ai(...)\n"); + printk(KERN_DEBUG "icp multi EDBG: BGN: icp_multi_insn_read_ai(...)\n"); #endif /* Disable A/D conversion ready interrupt */ devpriv->IntEnable &= ~ADC_READY; @@ -266,11 +266,11 @@ devpriv->IntStatus |= ADC_READY; writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); - /* Set up appropriate channel, mode and range data, for specified channel */ + /* Set up appropriate channel, mode and range data, for specified ch */ setup_channel_list(dev, s, &insn->chanspec, 1); #ifdef ICP_MULTI_EXTDEBUG - printk("icp_multi A ST=%4x IO=%p\n", + printk(KERN_DEBUG "icp_multi A ST=%4x IO=%p\n", readw(devpriv->io_addr + ICP_MULTI_ADC_CSR), devpriv->io_addr + ICP_MULTI_ADC_CSR); #endif @@ -283,14 +283,14 @@ devpriv->AdcCmdStatus &= ~ADC_ST; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi B n=%d ST=%4x\n", n, + printk(KERN_DEBUG "icp multi B n=%d ST=%4x\n", n, readw(devpriv->io_addr + ICP_MULTI_ADC_CSR)); #endif udelay(1); #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi C n=%d ST=%4x\n", n, + printk(KERN_DEBUG "icp multi C n=%d ST=%4x\n", n, readw(devpriv->io_addr + ICP_MULTI_ADC_CSR)); #endif @@ -303,7 +303,8 @@ #ifdef ICP_MULTI_EXTDEBUG if (!(timeout % 10)) - printk("icp multi D n=%d tm=%d ST=%4x\n", n, + printk(KERN_DEBUG + "icp multi D n=%d tm=%d ST=%4x\n", n, timeout, readw(devpriv->io_addr + ICP_MULTI_ADC_CSR)); @@ -328,9 +329,9 @@ data[n] = 0; #ifdef ICP_MULTI_EXTDEBUG - printk - ("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", - n); + printk(KERN_DEBUG + "icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", + n); #endif return -ETIME; @@ -348,7 +349,8 @@ writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", n); + printk(KERN_DEBUG + "icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", n); #endif return n; } @@ -356,18 +358,18 @@ /* ============================================================================== - Name: icp_multi_insn_write_ao +Name: icp_multi_insn_write_ao - Description: - This function writes a single analogue output. +Description: + This function writes a single analogue output. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to analogue output data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to analogue output data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -378,7 +380,8 @@ int n, chan, range, timeout; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: BGN: icp_multi_insn_write_ao(...)\n"); + printk(KERN_DEBUG + "icp multi EDBG: BGN: icp_multi_insn_write_ao(...)\n"); #endif /* Disable D/A conversion ready interrupt */ devpriv->IntEnable &= ~DAC_READY; @@ -404,7 +407,8 @@ writew(devpriv->DacCmdStatus, devpriv->io_addr + ICP_MULTI_DAC_CSR); for (n = 0; n < insn->n; n++) { - /* Wait for analogue output data register to be ready for new data, or get fed up waiting */ + /* Wait for analogue output data register to be + * ready for new data, or get fed up waiting */ timeout = 100; while (timeout--) { if (!(readw(devpriv->io_addr + @@ -413,7 +417,8 @@ #ifdef ICP_MULTI_EXTDEBUG if (!(timeout % 10)) - printk("icp multi A n=%d tm=%d ST=%4x\n", n, + printk(KERN_DEBUG + "icp multi A n=%d tm=%d ST=%4x\n", n, timeout, readw(devpriv->io_addr + ICP_MULTI_DAC_CSR)); @@ -438,8 +443,8 @@ devpriv->ao_data[chan] = 0; #ifdef ICP_MULTI_EXTDEBUG - printk - ("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", + printk(KERN_DEBUG + "icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", n); #endif return -ETIME; @@ -459,7 +464,8 @@ } #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", n); + printk(KERN_DEBUG + "icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", n); #endif return n; } @@ -467,18 +473,18 @@ /* ============================================================================== - Name: icp_multi_insn_read_ao +Name: icp_multi_insn_read_ao - Description: - This function reads a single analogue output. +Description: + This function reads a single analogue output. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to analogue output data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to analogue output data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -501,18 +507,18 @@ /* ============================================================================== - Name: icp_multi_insn_bits_di +Name: icp_multi_insn_bits_di - Description: - This function reads the digital inputs. +Description: + This function reads the digital inputs. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to analogue output data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to analogue output data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -528,18 +534,18 @@ /* ============================================================================== - Name: icp_multi_insn_bits_do +Name: icp_multi_insn_bits_do - Description: - This function writes the appropriate digital outputs. +Description: + This function writes the appropriate digital outputs. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to analogue output data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to analogue output data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -548,14 +554,14 @@ struct comedi_insn *insn, unsigned int *data) { #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: BGN: icp_multi_insn_bits_do(...)\n"); + printk(KERN_DEBUG "icp multi EDBG: BGN: icp_multi_insn_bits_do(...)\n"); #endif if (data[0]) { s->state &= ~data[0]; s->state |= (data[0] & data[1]); - printk("Digital outputs = %4x \n", s->state); + printk(KERN_DEBUG "Digital outputs = %4x \n", s->state); writew(s->state, devpriv->io_addr + ICP_MULTI_DO); } @@ -563,7 +569,7 @@ data[1] = readw(devpriv->io_addr + ICP_MULTI_DI); #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: icp_multi_insn_bits_do(...)\n"); + printk(KERN_DEBUG "icp multi EDBG: END: icp_multi_insn_bits_do(...)\n"); #endif return 2; } @@ -571,18 +577,18 @@ /* ============================================================================== - Name: icp_multi_insn_read_ctr +Name: icp_multi_insn_read_ctr - Description: - This function reads the specified counter. +Description: + This function reads the specified counter. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to counter data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to counter data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -596,18 +602,18 @@ /* ============================================================================== - Name: icp_multi_insn_write_ctr +Name: icp_multi_insn_write_ctr - Description: - This function write to the specified counter. +Description: + This function write to the specified counter. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_subdevice *s Pointer to current subdevice structure - struct comedi_insn *insn Pointer to current comedi instruction - unsigned int *data Pointer to counter data +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_subdevice *s Pointer to current subdevice structure + struct comedi_insn *insn Pointer to current comedi instruction + unsigned int *data Pointer to counter data - Returns:int Nmuber of instructions executed +Returns:int Nmuber of instructions executed ============================================================================== */ @@ -622,15 +628,15 @@ /* ============================================================================== - Name: interrupt_service_icp_multi +Name: interrupt_service_icp_multi - Description: - This function is the interrupt service routine for all - interrupts generated by the icp multi board. - - Parameters: - int irq - void *d Pointer to current device +Description: + This function is the interrupt service routine for all + interrupts generated by the icp multi board. + +Parameters: + int irq + void *d Pointer to current device ============================================================================== */ @@ -640,7 +646,8 @@ int int_no; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: BGN: interrupt_service_icp_multi(%d,...)\n", + printk(KERN_DEBUG + "icp multi EDBG: BGN: interrupt_service_icp_multi(%d,...)\n", irq); #endif @@ -651,7 +658,8 @@ return IRQ_NONE; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: interrupt_service_icp_multi() ST: %4x\n", + printk(KERN_DEBUG + "icp multi EDBG: interrupt_service_icp_multi() ST: %4x\n", readw(devpriv->io_addr + ICP_MULTI_INT_STAT)); #endif @@ -679,7 +687,8 @@ } #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: interrupt_service_icp_multi(...)\n"); + printk(KERN_DEBUG + "icp multi EDBG: END: interrupt_service_icp_multi(...)\n"); #endif return IRQ_HANDLED; } @@ -688,20 +697,20 @@ /* ============================================================================== - Name: check_channel_list +Name: check_channel_list - Description: - This function checks if the channel list, provided by user - is built correctly - - Parameters: - struct comedi_device *dev Pointer to current sevice structure - struct comedi_subdevice *s Pointer to current subdevice structure - unsigned int *chanlist Pointer to packed channel list - unsigned int n_chan Number of channels to scan +Description: + This function checks if the channel list, provided by user + is built correctly + +Parameters: + struct comedi_device *dev Pointer to current sevice structure + struct comedi_subdevice *s Pointer to current subdevice structure + unsigned int *chanlist Pointer to packed channel list + unsigned int n_chan Number of channels to scan - Returns:int 0 = failure - 1 = success +Returns:int 0 = failure + 1 = success ============================================================================== */ @@ -712,7 +721,8 @@ unsigned int i; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: check_channel_list(...,%d)\n", n_chan); + printk(KERN_DEBUG + "icp multi EDBG: check_channel_list(...,%d)\n", n_chan); #endif /* Check that we at least have one channel to check */ if (n_chan < 1) { @@ -725,7 +735,7 @@ if (CR_AREF(chanlist[i]) == AREF_DIFF) { if (CR_CHAN(chanlist[i]) > this_board->n_aichand) { comedi_error(dev, - "Incorrect differential ai channel number"); + "Incorrect differential ai ch-nr"); return 0; } } else { @@ -743,20 +753,20 @@ /* ============================================================================== - Name: setup_channel_list +Name: setup_channel_list - Description: - This function sets the appropriate channel selection, - differential input mode and range bits in the ADC Command/ - Status register. - - Parameters: - struct comedi_device *dev Pointer to current sevice structure - struct comedi_subdevice *s Pointer to current subdevice structure - unsigned int *chanlist Pointer to packed channel list - unsigned int n_chan Number of channels to scan +Description: + This function sets the appropriate channel selection, + differential input mode and range bits in the ADC Command/ + Status register. + +Parameters: + struct comedi_device *dev Pointer to current sevice structure + struct comedi_subdevice *s Pointer to current subdevice structure + unsigned int *chanlist Pointer to packed channel list + unsigned int n_chan Number of channels to scan - Returns:Void +Returns:Void ============================================================================== */ @@ -768,7 +778,8 @@ unsigned int diff; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: setup_channel_list(...,%d)\n", n_chan); + printk(KERN_DEBUG + "icp multi EDBG: setup_channel_list(...,%d)\n", n_chan); #endif devpriv->act_chanlist_len = n_chan; devpriv->act_chanlist_pos = 0; @@ -786,7 +797,8 @@ chanprog &= 0x000f; } - /* Clear channel, range and input mode bits in A/D command/status register */ + /* Clear channel, range and input mode bits + * in A/D command/status register */ devpriv->AdcCmdStatus &= 0xf00f; /* Set channel number and differential mode status bit */ @@ -808,7 +820,8 @@ devpriv->io_addr + ICP_MULTI_ADC_CSR); #ifdef ICP_MULTI_EXTDEBUG - printk("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range, + printk(KERN_DEBUG + "GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range, devpriv->act_chanlist[i]); #endif } @@ -818,15 +831,15 @@ /* ============================================================================== - Name: icp_multi_reset +Name: icp_multi_reset - Description: - This function resets the icp multi device to a 'safe' state +Description: + This function resets the icp multi device to a 'safe' state - Parameters: - struct comedi_device *dev Pointer to current sevice structure +Parameters: + struct comedi_device *dev Pointer to current sevice structure - Returns:int 0 = success +Returns:int 0 = success ============================================================================== */ @@ -835,7 +848,8 @@ unsigned int i; #ifdef ICP_MULTI_EXTDEBUG - printk("icp_multi EDBG: BGN: icp_multi_reset(...)\n"); + printk(KERN_DEBUG + "icp_multi EDBG: BGN: icp_multi_reset(...)\n"); #endif /* Clear INT enables and requests */ writew(0, devpriv->io_addr + ICP_MULTI_INT_EN); @@ -866,7 +880,8 @@ writew(0, devpriv->io_addr + ICP_MULTI_DO); #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: icp_multi_reset(...)\n"); + printk(KERN_DEBUG + "icp multi EDBG: END: icp_multi_reset(...)\n"); #endif return 0; } @@ -874,17 +889,17 @@ /* ============================================================================== - Name: icp_multi_attach +Name: icp_multi_attach - Description: - This function sets up all the appropriate data for the current - device. +Description: + This function sets up all the appropriate data for the current + device. - Parameters: - struct comedi_device *dev Pointer to current device structure - struct comedi_devconfig *it Pointer to current device configuration +Parameters: + struct comedi_device *dev Pointer to current device structure + struct comedi_devconfig *it Pointer to current device configuration - Returns:int 0 = success +Returns:int 0 = success ============================================================================== */ @@ -898,7 +913,8 @@ resource_size_t io_addr[5], iobase; unsigned char pci_bus, pci_slot, pci_func; - printk("icp_multi EDBG: BGN: icp_multi_attach(...)\n"); + printk(KERN_WARNING + "icp_multi EDBG: BGN: icp_multi_attach(...)\n"); /* Alocate private data storage space */ ret = alloc_private(dev, sizeof(struct icp_multi_private)); @@ -916,7 +932,8 @@ ); } - printk("Anne's comedi%d: icp_multi: board=%s", dev->minor, + printk(KERN_WARNING + "Anne's comedi%d: icp_multi: board=%s", dev->minor, this_board->name); card = select_and_alloc_pci_card(PCI_VENDOR_ID_ICP, @@ -930,24 +947,26 @@ if ((pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0], &irq)) < 0) { - printk(" - Can't get configuration data!\n"); + printk(KERN_WARNING " - Can't get configuration data!\n"); return -EIO; } iobase = io_addr[2]; devpriv->phys_iobase = iobase; - printk(", b:s:f=%d:%d:%d, io=0x%8llx \n", pci_bus, pci_slot, pci_func, + printk(KERN_WARNING + ", b:s:f=%d:%d:%d, io=0x%8llx \n", pci_bus, pci_slot, pci_func, (unsigned long long)iobase); devpriv->io_addr = ioremap(iobase, ICP_MULTI_SIZE); if (devpriv->io_addr == NULL) { - printk("ioremap failed.\n"); + printk(KERN_WARNING "ioremap failed.\n"); return -ENOMEM; } #ifdef ICP_MULTI_EXTDEBUG - printk("0x%08llx mapped to %p, ", (unsigned long long)iobase, + printk(KERN_DEBUG + "0x%08llx mapped to %p, ", (unsigned long long)iobase, devpriv->io_addr); #endif @@ -975,20 +994,20 @@ if (irq) { if (request_irq(irq, interrupt_service_icp_multi, IRQF_SHARED, "Inova Icp Multi", dev)) { - printk - (", unable to allocate IRQ %u, DISABLING IT", + printk(KERN_WARNING + "unable to allocate IRQ %u, DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else - printk(", irq=%u", irq); + printk(KERN_WARNING ", irq=%u", irq); } else - printk(", IRQ disabled"); + printk(KERN_WARNING ", IRQ disabled"); } else irq = 0; dev->irq = irq; - printk(".\n"); + printk(KERN_WARNING ".\n"); subdev = 0; @@ -1063,7 +1082,7 @@ devpriv->valid = 1; #ifdef ICP_MULTI_EXTDEBUG - printk("icp multi EDBG: END: icp_multi_attach(...)\n"); + printk(KERN_DEBUG "icp multi EDBG: END: icp_multi_attach(...)\n"); #endif return 0; @@ -1072,16 +1091,16 @@ /* ============================================================================== - Name: icp_multi_detach +Name: icp_multi_detach - Description: - This function releases all the resources used by the current - device. +Description: + This function releases all the resources used by the current + device. - Parameters: - struct comedi_device *dev Pointer to current device structure +Parameters: + struct comedi_device *dev Pointer to current device structure - Returns:int 0 = success +Returns:int 0 = success ============================================================================== */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ii_pci20kc.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ii_pci20kc.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ii_pci20kc.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ii_pci20kc.c 2009-11-06 20:57:48.000000000 -0800 @@ -23,7 +23,8 @@ * no extern trigger implemented * * NOT WORKING (but soon) only 4 on-board differential channels supported - * NOT WORKING (but soon) only ONE di-port and ONE do-port supported instead of 4 digital ports + * NOT WORKING (but soon) only ONE di-port and ONE do-port supported + * instead of 4 digital ports * di-port == Port 0 * do-port == Port 1 * @@ -63,17 +64,17 @@ options for PCI-20006M: first: Analog output channel 0 range configuration - 0 bipolar 10 (-10V -- +10V) - 1 unipolar 10 (0V -- +10V) - 2 bipolar 5 (-5V -- 5V) + 0 bipolar 10 (-10V -- +10V) + 1 unipolar 10 (0V -- +10V) + 2 bipolar 5 (-5V -- 5V) second: Analog output channel 1 range configuration options for PCI-20341M: first: Analog input gain configuration - 0 1 - 1 10 - 2 100 - 3 200 + 0 1 + 1 10 + 2 100 + 3 200 */ /* XXX needs to use ioremap() for compatibility with 2.4 kernels. Should also @@ -95,12 +96,12 @@ #define PCI20000_DIO_3 0xc1 #define PCI20000_DIO_CONTROL_01 0x83 /* port 0, 1 control */ #define PCI20000_DIO_CONTROL_23 0xc3 /* port 2, 3 control */ -#define PCI20000_DIO_BUFFER 0x82 /* buffer direction and enable */ +#define PCI20000_DIO_BUFFER 0x82 /* buffer direction & enable */ #define PCI20000_DIO_EOC 0xef /* even port, control output */ #define PCI20000_DIO_OOC 0xfd /* odd port, control output */ #define PCI20000_DIO_EIC 0x90 /* even port, control input */ #define PCI20000_DIO_OIC 0x82 /* odd port, control input */ -#define DIO_CAND 0x12 /* and bit 1, bit 4 of control */ +#define DIO_CAND 0x12 /* and bit 1 & 4 of control */ #define DIO_BE 0x01 /* buffer: port enable */ #define DIO_BO 0x04 /* buffer: output */ #define DIO_BI 0x05 /* buffer: input */ @@ -137,7 +138,8 @@ void *iobase; struct { void *iobase; - const struct comedi_lrange *ao_range_list[2]; /* range of channels of ao module */ + const struct comedi_lrange *ao_range_list[2]; + /* range of channels of ao module */ unsigned int last_data[2]; } pci20006; struct { @@ -224,14 +226,13 @@ /* Check PCI-20001 C-2A Carrier Board ID */ if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) { - printk("comedi%d: ii_pci20kc", dev->minor); - printk - (" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", - devpriv->ioaddr); + printk(KERN_WARNING "comedi%d: ii_pci20kc PCI-20001" + " C-2A Carrier Board at base=0x%p not found !\n", + dev->minor, devpriv->ioaddr); return -EINVAL; } - printk("comedi%d:\n", dev->minor); - printk("ii_pci20kc: PCI-20001 C-2A at base=0x%p\n", devpriv->ioaddr); + printk(KERN_INFO "comedi%d: ii_pci20kc: PCI-20001 C-2A at base=0x%p\n", + dev->minor, devpriv->ioaddr); for (i = 0; i < PCI20000_MODULES; i++) { s = dev->subdevices + i; @@ -244,21 +245,23 @@ devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; pci20006_init(dev, s, it->options[2 * i + 2], it->options[2 * i + 3]); - printk("comedi%d: ii_pci20kc", dev->minor); - printk(" PCI-20006 module in slot %d \n", i + 1); + printk(KERN_INFO "comedi%d: " + "ii_pci20kc PCI-20006 module in slot %d \n", + dev->minor, i + 1); break; case PCI20341_ID: sdp->pci20341.iobase = devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; pci20341_init(dev, s, it->options[2 * i + 2], it->options[2 * i + 3]); - printk("comedi%d: ii_pci20kc", dev->minor); - printk(" PCI-20341 module in slot %d \n", i + 1); + printk(KERN_INFO "comedi%d: " + "ii_pci20kc PCI-20341 module in slot %d \n", + dev->minor, i + 1); break; default: - printk - ("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n", - id, i); + printk(KERN_WARNING "ii_pci20kc: unknown module " + "code 0x%02x in slot %d: module disabled\n", + id, i); /* XXX this looks like a bug! i + 1 ?? */ /* fall through */ case PCI20xxx_EMPTY_ID: s->type = COMEDI_SUBD_UNUSED; @@ -274,7 +277,7 @@ static int pci20xxx_detach(struct comedi_device *dev) { - printk("comedi%d: pci20xxx: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pci20xxx: remove\n", dev->minor); return 0; } @@ -339,7 +342,8 @@ unsigned int boarddata; sdp->pci20006.last_data[CR_CHAN(insn->chanspec)] = data[0]; - boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff); /* comedi-data -> board-data */ + boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff); + /* comedi-data -> board-data */ lo = (boarddata & 0xff); hi = ((boarddata >> 8) & 0xff); @@ -355,7 +359,8 @@ writeb(0x00, sdp->iobase + PCI20006_STROBE1); break; default: - printk(" comedi%d: pci20xxx: ao channel Error!\n", dev->minor); + printk(KERN_WARNING + " comedi%d: pci20xxx: ao channel Error!\n", dev->minor); return -EINVAL; } @@ -373,8 +378,7 @@ static const struct comedi_lrange range_bipolar0_5 = { 1, {BIP_RANGE(0.5)} }; static const struct comedi_lrange range_bipolar0_05 = { 1, {BIP_RANGE(0.05)} }; -static const struct comedi_lrange range_bipolar0_025 = - { 1, {BIP_RANGE(0.025)} }; +static const struct comedi_lrange range_bipolar0_025 = { 1, {BIP_RANGE(0.025)} }; static const struct comedi_lrange *const pci20341_ranges[] = { &range_bipolar5, @@ -447,9 +451,10 @@ eoc = readb(sdp->iobase + PCI20341_STATUS_REG); } if (j >= 100) { - printk - ("comedi%d: pci20xxx: AI interrupt channel %i polling exit !\n", - dev->minor, i); + printk(KERN_WARNING + "comedi%d: pci20xxx: " + "AI interrupt channel %i polling exit !\n", + dev->minor, i); return -EINVAL; } lo = readb(sdp->iobase + PCI20341_LDATA); @@ -502,20 +507,18 @@ int mask, bits; mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x000000ff) { + if (mask & 0x000000ff) bits = 0x000000ff; - } else if (mask & 0x0000ff00) { + else if (mask & 0x0000ff00) bits = 0x0000ff00; - } else if (mask & 0x00ff0000) { + else if (mask & 0x00ff0000) bits = 0x00ff0000; - } else { + else bits = 0xff000000; - } - if (data[0]) { + if (data[0]) s->io_bits |= bits; - } else { + else s->io_bits &= ~bits; - } pci20xxx_dio_config(dev, s); return 1; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ke_counter.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ke_counter.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ke_counter.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ke_counter.c 2009-11-06 20:57:48.000000000 -0800 @@ -192,12 +192,14 @@ } } } - printk("comedi%d: no supported board found! (req. bus/slot: %d/%d)\n", + printk(KERN_WARNING + "comedi%d: no supported board found! (req. bus/slot: %d/%d)\n", dev->minor, it->options[0], it->options[1]); return -EIO; found: - printk("comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor, + printk(KERN_INFO + "comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor, board->name, pci_device->bus->number, PCI_SLOT(pci_device->devfn)); devpriv->pcidev = pci_device; @@ -206,9 +208,9 @@ /* enable PCI device and request regions */ error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME); if (error < 0) { - printk - ("comedi%d: failed to enable PCI device and request regions!\n", - dev->minor); + printk(KERN_WARNING "comedi%d: " + "failed to enable PCI device and request regions!\n", + dev->minor); return error; } @@ -239,7 +241,8 @@ outb(0, dev->iobase + 0x20); outb(0, dev->iobase + 0x40); - printk("comedi%d: " CNT_DRIVER_NAME " attached.\n", dev->minor); + printk(KERN_INFO "comedi%d: " CNT_DRIVER_NAME " attached.\n", + dev->minor); return 0; } @@ -248,11 +251,11 @@ static int cnt_detach(struct comedi_device *dev) { if (devpriv && devpriv->pcidev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pcidev); - } pci_dev_put(devpriv->pcidev); } - printk("comedi%d: " CNT_DRIVER_NAME " remove\n", dev->minor); + printk(KERN_INFO "comedi%d: " CNT_DRIVER_NAME " remove\n", + dev->minor); return 0; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/mite.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/mite.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/mite.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/mite.c 2009-11-06 20:57:47.000000000 -0800 @@ -64,6 +64,7 @@ MODULE_LICENSE("GPL"); struct mite_struct *mite_devices; +EXPORT_SYMBOL(mite_devices); #define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK))) @@ -80,7 +81,7 @@ mite = kzalloc(sizeof(*mite), GFP_KERNEL); if (!mite) { - printk("mite: allocation failed\n"); + printk(KERN_ERR "mite: allocation failed\n"); pci_dev_put(pcidev); return; } @@ -99,14 +100,14 @@ static void dump_chip_signature(u32 csigr_bits) { - printk - ("mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n", - mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits), - mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits)); - printk - ("mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n", - mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits), - mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits)); + printk(KERN_INFO "mite: version = %i, type = %i, mite mode = %i," + "interface mode = %i\n", + mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits), + mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits)); + printk(KERN_INFO "mite: num channels = %i, write post fifo depth = %i," + "wins = %i, iowins = %i\n", + mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits), + mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits)); } unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel) @@ -126,7 +127,7 @@ unsigned unknown_dma_burst_bits; if (comedi_pci_enable(mite->pcidev, "mite")) { - printk("error enabling mite and requesting io regions\n"); + printk(KERN_ERR "error enabling mite and requesting io regions\n"); return -EIO; } pci_set_master(mite->pcidev); @@ -135,27 +136,30 @@ mite->mite_phys_addr = addr; mite->mite_io_addr = ioremap(addr, PCI_MITE_SIZE); if (!mite->mite_io_addr) { - printk("failed to remap mite io memory address\n"); + printk(KERN_ERR "Failed to remap mite io memory address\n"); return -ENOMEM; } - printk("MITE:0x%08llx mapped to %p ", + printk(KERN_INFO "MITE:0x%08llx mapped to %p ", (unsigned long long)mite->mite_phys_addr, mite->mite_io_addr); addr = pci_resource_start(mite->pcidev, 1); mite->daq_phys_addr = addr; length = pci_resource_len(mite->pcidev, 1); - /* In case of a 660x board, DAQ size is 8k instead of 4k (see as shown by lspci output) */ + /* + * In case of a 660x board, DAQ size is 8k instead of 4k + * (see as shown by lspci output) + */ mite->daq_io_addr = ioremap(mite->daq_phys_addr, length); if (!mite->daq_io_addr) { - printk("failed to remap daq io memory address\n"); + printk(KERN_ERR "Failed to remap daq io memory address\n"); return -ENOMEM; } - printk("DAQ:0x%08llx mapped to %p\n", + printk(KERN_INFO "DAQ:0x%08llx mapped to %p\n", (unsigned long long)mite->daq_phys_addr, mite->daq_io_addr); if (use_iodwbsr_1) { writel(0, mite->mite_io_addr + MITE_IODWBSR); - printk("mite: using I/O Window Base Size register 1\n"); + printk(KERN_INFO "mite: using I/O Window Base Size register 1\n"); writel(mite->daq_phys_addr | WENAB | MITE_IODWBSR_1_WSIZE_bits(length), mite->mite_io_addr + MITE_IODWBSR_1); @@ -164,11 +168,12 @@ writel(mite->daq_phys_addr | WENAB, mite->mite_io_addr + MITE_IODWBSR); } - /* make sure dma bursts work. I got this from running a bus analyzer - on a pxi-6281 and a pxi-6713. 6713 powered up with register value - of 0x61f and bursts worked. 6281 powered up with register value of - 0x1f and bursts didn't work. The NI windows driver reads the register, - then does a bitwise-or of 0x600 with it and writes it back. + /* + * make sure dma bursts work. I got this from running a bus analyzer + * on a pxi-6281 and a pxi-6713. 6713 powered up with register value + * of 0x61f and bursts worked. 6281 powered up with register value of + * 0x1f and bursts didn't work. The NI windows driver reads the + * register, then does a bitwise-or of 0x600 with it and writes it back. */ unknown_dma_burst_bits = readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG); @@ -179,9 +184,9 @@ csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR); mite->num_channels = mite_csigr_dmac(csigr_bits); if (mite->num_channels > MAX_MITE_DMA_CHANNELS) { - printk - ("mite: bug? chip claims to have %i dma channels. Setting to %i.\n", - mite->num_channels, MAX_MITE_DMA_CHANNELS); + printk(KERN_WARNING "mite: bug? chip claims to have %i dma " + "channels. Setting to %i.\n", + mite->num_channels, MAX_MITE_DMA_CHANNELS); mite->num_channels = MAX_MITE_DMA_CHANNELS; } dump_chip_signature(csigr_bits); @@ -194,16 +199,18 @@ mite->mite_io_addr + MITE_CHCR(i)); } mite->fifo_size = mite_fifo_size(mite, 0); - printk("mite: fifo size is %i.\n", mite->fifo_size); + printk(KERN_INFO "mite: fifo size is %i.\n", mite->fifo_size); mite->used = 1; return 0; } +EXPORT_SYMBOL(mite_setup2); int mite_setup(struct mite_struct *mite) { return mite_setup2(mite, 0); } +EXPORT_SYMBOL(mite_setup); void mite_cleanup(void) { @@ -238,22 +245,23 @@ mite->used = 0; } +EXPORT_SYMBOL(mite_unsetup); void mite_list_devices(void) { struct mite_struct *mite, *next; - printk("Available NI device IDs:"); + printk(KERN_INFO "Available NI device IDs:"); if (mite_devices) for (mite = mite_devices; mite; mite = next) { next = mite->next; - printk(" 0x%04x", mite_device_id(mite)); + printk(KERN_INFO " 0x%04x", mite_device_id(mite)); if (mite->used) - printk("(used)"); + printk(KERN_INFO "(used)"); } - printk("\n"); - + printk(KERN_INFO "\n"); } +EXPORT_SYMBOL(mite_list_devices); struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite, struct @@ -265,7 +273,9 @@ unsigned long flags; struct mite_channel *channel = NULL; - /* spin lock so mite_release_channel can be called safely from interrupts */ + /* spin lock so mite_release_channel can be called safely + * from interrupts + */ spin_lock_irqsave(&mite->lock, flags); for (i = min_channel; i <= max_channel; ++i) { if (mite->channel_allocated[i] == 0) { @@ -278,6 +288,7 @@ spin_unlock_irqrestore(&mite->lock, flags); return channel; } +EXPORT_SYMBOL(mite_request_channel_in_range); void mite_release_channel(struct mite_channel *mite_chan) { @@ -289,8 +300,10 @@ if (mite->channel_allocated[mite_chan->channel]) { mite_dma_disarm(mite_chan); mite_dma_reset(mite_chan); -/* disable all channel's interrupts (do it after disarm/reset so -MITE_CHCR reg isn't changed while dma is still active!) */ + /* + * disable all channel's interrupts (do it after disarm/reset so + * MITE_CHCR reg isn't changed while dma is still active!) + */ writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE | @@ -302,6 +315,7 @@ } spin_unlock_irqrestore(&mite->lock, flags); } +EXPORT_SYMBOL(mite_release_channel); void mite_dma_arm(struct mite_channel *mite_chan) { @@ -310,8 +324,10 @@ unsigned long flags; MDPRINTK("mite_dma_arm ch%i\n", channel); - /* memory barrier is intended to insure any twiddling with the buffer - is done before writing to the mite to arm dma transfer */ + /* + * memory barrier is intended to insure any twiddling with the buffer + * is done before writing to the mite to arm dma transfer + */ smp_mb(); /* arm */ chor = CHOR_START; @@ -322,6 +338,7 @@ spin_unlock_irqrestore(&mite->lock, flags); /* mite_dma_tcr(mite, channel); */ } +EXPORT_SYMBOL(mite_dma_arm); /**************************************/ @@ -354,7 +371,7 @@ n_links * sizeof(struct mite_dma_descriptor), &ring->descriptors_dma_addr, GFP_KERNEL); if (!ring->descriptors) { - printk("mite: ring buffer allocation failed\n"); + printk(KERN_ERR "mite: ring buffer allocation failed\n"); return -ENOMEM; } ring->n_links = n_links; @@ -370,11 +387,14 @@ } ring->descriptors[n_links - 1].next = cpu_to_le32(ring->descriptors_dma_addr); - /* barrier is meant to insure that all the writes to the dma descriptors - have completed before the dma controller is commanded to read them */ + /* + * barrier is meant to insure that all the writes to the dma descriptors + * have completed before the dma controller is commanded to read them + */ smp_wmb(); return 0; } +EXPORT_SYMBOL(mite_buf_change); void mite_prep_dma(struct mite_channel *mite_chan, unsigned int num_device_bits, unsigned int num_memory_bits) @@ -395,16 +415,19 @@ * Link Complete Interrupt: interrupt every time a link * in MITE_RING is completed. This can generate a lot of * extra interrupts, but right now we update the values - * of buf_int_ptr and buf_int_count at each interrupt. A + * of buf_int_ptr and buf_int_count at each interrupt. A * better method is to poll the MITE before each user * "read()" to calculate the number of bytes available. */ chcr |= CHCR_SET_LC_IE; if (num_memory_bits == 32 && num_device_bits == 16) { - /* Doing a combined 32 and 16 bit byteswap gets the 16 bit samples into the fifo in the right order. - Tested doing 32 bit memory to 16 bit device transfers to the analog out of a pxi-6281, - which has mite version = 1, type = 4. This also works for dma reads from the counters - on e-series boards. */ + /* + * Doing a combined 32 and 16 bit byteswap gets the 16 bit + * samples into the fifo in the right order. Tested doing 32 bit + * memory to 16 bit device transfers to the analog out of a + * pxi-6281, which has mite version = 1, type = 4. This also + * works for dma reads from the counters on e-series boards. + */ chcr |= CHCR_BYTE_SWAP_DEVICE | CHCR_BYTE_SWAP_MEMORY; } if (mite_chan->dir == COMEDI_INPUT) @@ -425,7 +448,8 @@ mcr |= CR_PSIZE32; break; default: - printk("mite: bug! invalid mem bit width for dma transfer\n"); + printk(KERN_WARNING "mite: bug! invalid mem bit width for dma " + "transfer\n"); break; } writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel)); @@ -444,7 +468,8 @@ dcr |= CR_PSIZE32; break; default: - printk("mite: bug! invalid dev bit width for dma transfer\n"); + printk(KERN_WARNING "mite: bug! invalid dev bit width for dma " + "transfer\n"); break; } writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel)); @@ -462,6 +487,7 @@ MDPRINTK("exit mite_prep_dma\n"); } +EXPORT_SYMBOL(mite_prep_dma); u32 mite_device_bytes_transferred(struct mite_channel *mite_chan) { @@ -469,48 +495,53 @@ return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel)); } -u32 mite_bytes_in_transit(struct mite_channel * mite_chan) +u32 mite_bytes_in_transit(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; return readl(mite->mite_io_addr + MITE_FCR(mite_chan->channel)) & 0x000000FF; } +EXPORT_SYMBOL(mite_bytes_in_transit); -/* returns lower bound for number of bytes transferred from device to memory */ -u32 mite_bytes_written_to_memory_lb(struct mite_channel * mite_chan) +/* returns lower bound for number of bytes transferred from device to memory */ +u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan) { u32 device_byte_count; device_byte_count = mite_device_bytes_transferred(mite_chan); return device_byte_count - mite_bytes_in_transit(mite_chan); } +EXPORT_SYMBOL(mite_bytes_written_to_memory_lb); -/* returns upper bound for number of bytes transferred from device to memory */ -u32 mite_bytes_written_to_memory_ub(struct mite_channel * mite_chan) +/* returns upper bound for number of bytes transferred from device to memory */ +u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan) { u32 in_transit_count; in_transit_count = mite_bytes_in_transit(mite_chan); return mite_device_bytes_transferred(mite_chan) - in_transit_count; } +EXPORT_SYMBOL(mite_bytes_written_to_memory_ub); -/* returns lower bound for number of bytes read from memory for transfer to device */ -u32 mite_bytes_read_from_memory_lb(struct mite_channel * mite_chan) +/* returns lower bound for number of bytes read from memory to device */ +u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan) { u32 device_byte_count; device_byte_count = mite_device_bytes_transferred(mite_chan); return device_byte_count + mite_bytes_in_transit(mite_chan); } +EXPORT_SYMBOL(mite_bytes_read_from_memory_lb); -/* returns upper bound for number of bytes read from memory for transfer to device */ -u32 mite_bytes_read_from_memory_ub(struct mite_channel * mite_chan) +/* returns upper bound for number of bytes read from memory to device */ +u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) { u32 in_transit_count; in_transit_count = mite_bytes_in_transit(mite_chan); return mite_device_bytes_transferred(mite_chan) + in_transit_count; } +EXPORT_SYMBOL(mite_bytes_read_from_memory_ub); unsigned mite_dma_tcr(struct mite_channel *mite_chan) { @@ -525,6 +556,7 @@ return tcr; } +EXPORT_SYMBOL(mite_dma_tcr); void mite_dma_disarm(struct mite_channel *mite_chan) { @@ -535,6 +567,7 @@ chor = CHOR_ABORT; writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } +EXPORT_SYMBOL(mite_dma_disarm); int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async *async) @@ -544,7 +577,7 @@ const unsigned bytes_per_scan = cfc_bytes_per_scan(async->subdevice); old_alloc_count = async->buf_write_alloc_count; - /* write alloc as much as we can */ + /* write alloc as much as we can */ comedi_buf_write_alloc(async, async->prealloc_bufsz); nbytes = mite_bytes_written_to_memory_lb(mite_chan); @@ -571,6 +604,7 @@ async->events |= COMEDI_CB_BLOCK; return 0; } +EXPORT_SYMBOL(mite_sync_input_dma); int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async *async) @@ -593,7 +627,7 @@ (int)(nbytes_ub - stop_count) > 0) nbytes_ub = stop_count; if ((int)(nbytes_ub - old_alloc_count) > 0) { - printk("mite: DMA underrun\n"); + printk(KERN_ERR "mite: DMA underrun\n"); async->events |= COMEDI_CB_OVERFLOW; return -1; } @@ -607,6 +641,7 @@ } return 0; } +EXPORT_SYMBOL(mite_sync_output_dma); unsigned mite_get_status(struct mite_channel *mite_chan) { @@ -625,6 +660,7 @@ spin_unlock_irqrestore(&mite->lock, flags); return status; } +EXPORT_SYMBOL(mite_get_status); int mite_done(struct mite_channel *mite_chan) { @@ -638,6 +674,7 @@ spin_unlock_irqrestore(&mite->lock, flags); return done; } +EXPORT_SYMBOL(mite_done); #ifdef DEBUG_MITE @@ -719,46 +756,51 @@ unsigned long addr = 0; unsigned long temp = 0; - printk("mite_dump_regs ch%i\n", mite_chan->channel); - printk("mite address is =0x%08lx\n", mite_io_addr); + printk(KERN_DEBUG "mite_dump_regs ch%i\n", mite_chan->channel); + printk(KERN_DEBUG "mite address is =0x%08lx\n", mite_io_addr); addr = mite_io_addr + MITE_CHOR(channel); - printk("mite status[CHOR]at 0x%08lx =0x%08lx\n", addr, temp = - readl(addr)); + printk(KERN_DEBUG "mite status[CHOR]at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_CHOR_strings, temp); addr = mite_io_addr + MITE_CHCR(channel); - printk("mite status[CHCR]at 0x%08lx =0x%08lx\n", addr, temp = - readl(addr)); + printk(KERN_DEBUG "mite status[CHCR]at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_CHCR_strings, temp); addr = mite_io_addr + MITE_TCR(channel); - printk("mite status[TCR] at 0x%08lx =0x%08x\n", addr, readl(addr)); - addr = mite_io_addr + MITE_MCR(channel); - printk("mite status[MCR] at 0x%08lx =0x%08lx\n", addr, temp = + printk(KERN_DEBUG "mite status[TCR] at 0x%08lx =0x%08x\n", addr, readl(addr)); + addr = mite_io_addr + MITE_MCR(channel); + printk(KERN_DEBUG "mite status[MCR] at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_MCR_strings, temp); addr = mite_io_addr + MITE_MAR(channel); - printk("mite status[MAR] at 0x%08lx =0x%08x\n", addr, readl(addr)); - addr = mite_io_addr + MITE_DCR(channel); - printk("mite status[DCR] at 0x%08lx =0x%08lx\n", addr, temp = + printk(KERN_DEBUG "mite status[MAR] at 0x%08lx =0x%08x\n", addr, readl(addr)); + addr = mite_io_addr + MITE_DCR(channel); + printk(KERN_DEBUG "mite status[DCR] at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_DCR_strings, temp); addr = mite_io_addr + MITE_DAR(channel); - printk("mite status[DAR] at 0x%08lx =0x%08x\n", addr, readl(addr)); - addr = mite_io_addr + MITE_LKCR(channel); - printk("mite status[LKCR]at 0x%08lx =0x%08lx\n", addr, temp = + printk(KERN_DEBUG "mite status[DAR] at 0x%08lx =0x%08x\n", addr, readl(addr)); + addr = mite_io_addr + MITE_LKCR(channel); + printk(KERN_DEBUG "mite status[LKCR]at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_LKCR_strings, temp); addr = mite_io_addr + MITE_LKAR(channel); - printk("mite status[LKAR]at 0x%08lx =0x%08x\n", addr, readl(addr)); - - addr = mite_io_addr + MITE_CHSR(channel); - printk("mite status[CHSR]at 0x%08lx =0x%08lx\n", addr, temp = + printk(KERN_DEBUG "mite status[LKAR]at 0x%08lx =0x%08x\n", addr, readl(addr)); + addr = mite_io_addr + MITE_CHSR(channel); + printk(KERN_DEBUG "mite status[CHSR]at 0x%08lx =0x%08lx\n", addr, + temp = readl(addr)); mite_decode(mite_CHSR_strings, temp); addr = mite_io_addr + MITE_FCR(channel); - printk("mite status[FCR] at 0x%08lx =0x%08x\n\n", addr, readl(addr)); + printk(KERN_DEBUG "mite status[FCR] at 0x%08lx =0x%08x\n\n", addr, + readl(addr)); } +EXPORT_SYMBOL(mite_dump_regs); static void mite_decode(char **bit_str, unsigned int bits) { @@ -766,10 +808,11 @@ for (i = 31; i >= 0; i--) { if (bits & (1 << i)) - printk(" %s", bit_str[i]); + printk(KERN_DEBUG " %s", bit_str[i]); } - printk("\n"); + printk(KERN_DEBUG "\n"); } +EXPORT_SYMBOL(mite_decode); #endif #ifdef MODULE @@ -785,36 +828,4 @@ { mite_cleanup(); } - -EXPORT_SYMBOL(mite_dma_tcr); -EXPORT_SYMBOL(mite_dma_arm); -EXPORT_SYMBOL(mite_dma_disarm); -EXPORT_SYMBOL(mite_sync_input_dma); -EXPORT_SYMBOL(mite_sync_output_dma); -EXPORT_SYMBOL(mite_setup); -EXPORT_SYMBOL(mite_setup2); -EXPORT_SYMBOL(mite_unsetup); -#if 0 -EXPORT_SYMBOL(mite_kvmem_segment_load); -EXPORT_SYMBOL(mite_ll_from_kvmem); -EXPORT_SYMBOL(mite_setregs); -#endif -EXPORT_SYMBOL(mite_devices); -EXPORT_SYMBOL(mite_list_devices); -EXPORT_SYMBOL(mite_request_channel_in_range); -EXPORT_SYMBOL(mite_release_channel); -EXPORT_SYMBOL(mite_prep_dma); -EXPORT_SYMBOL(mite_buf_change); -EXPORT_SYMBOL(mite_bytes_written_to_memory_lb); -EXPORT_SYMBOL(mite_bytes_written_to_memory_ub); -EXPORT_SYMBOL(mite_bytes_read_from_memory_lb); -EXPORT_SYMBOL(mite_bytes_read_from_memory_ub); -EXPORT_SYMBOL(mite_bytes_in_transit); -EXPORT_SYMBOL(mite_get_status); -EXPORT_SYMBOL(mite_done); -#ifdef DEBUG_MITE -EXPORT_SYMBOL(mite_decode); -EXPORT_SYMBOL(mite_dump_regs); -#endif - #endif diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/mite.h linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/mite.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/mite.h 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/mite.h 2009-11-06 20:57:47.000000000 -0800 @@ -163,13 +163,6 @@ unsigned mite_get_status(struct mite_channel *mite_chan); int mite_done(struct mite_channel *mite_chan); -#if 0 -unsigned long mite_ll_from_kvmem(struct mite_struct *mite, - struct comedi_async *async, int len); -void mite_setregs(struct mite_struct *mite, unsigned long ll_start, int chan, - int dir); -#endif - void mite_prep_dma(struct mite_channel *mite_chan, unsigned int num_device_bits, unsigned int num_memory_bits); int mite_buf_change(struct mite_dma_descriptor_ring *ring, diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/multiq3.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/multiq3.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/multiq3.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/multiq3.c 2009-11-06 20:57:47.000000000 -0800 @@ -144,9 +144,8 @@ int i; int chan = CR_CHAN(insn->chanspec); - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = devpriv->ao_readback[chan]; - } return i; } @@ -253,20 +252,20 @@ struct comedi_subdevice *s; iobase = it->options[0]; - printk("comedi%d: multiq3: 0x%04lx ", dev->minor, iobase); + printk(KERN_INFO "comedi%d: multiq3: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, MULTIQ3_SIZE, "multiq3")) { - printk("comedi%d: I/O port conflict\n", dev->minor); + printk(KERN_ERR "comedi%d: I/O port conflict\n", dev->minor); return -EIO; } dev->iobase = iobase; irq = it->options[1]; - if (irq) { - printk("comedi%d: irq = %u ignored\n", dev->minor, irq); - } else { - printk("comedi%d: no irq\n", dev->minor); - } + if (irq) + printk(KERN_WARNING "comedi%d: irq = %u ignored\n", + dev->minor, irq); + else + printk(KERN_WARNING "comedi%d: no irq\n", dev->minor); dev->board_name = "multiq3"; result = alloc_subdevices(dev, 5); if (result < 0) @@ -330,14 +329,12 @@ static int multiq3_detach(struct comedi_device *dev) { - printk("comedi%d: multiq3: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: multiq3: remove\n", dev->minor); - if (dev->iobase) { + if (dev->iobase) release_region(dev->iobase, MULTIQ3_SIZE); - } - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } return 0; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_6527.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_6527.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_6527.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_6527.c 2009-11-06 20:57:47.000000000 -0800 @@ -273,7 +273,8 @@ if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* step 2: make sure trigger sources are unique and */ + /* are mutually compatible */ if (err) return 2; @@ -377,7 +378,7 @@ struct comedi_subdevice *s; int ret; - printk("comedi%d: ni6527:", dev->minor); + printk(KERN_INFO "comedi%d: ni6527\n", dev->minor); ret = alloc_private(dev, sizeof(struct ni6527_private)); if (ret < 0) @@ -389,14 +390,13 @@ ret = mite_setup(devpriv->mite); if (ret < 0) { - printk("error setting up mite\n"); + printk(KERN_ERR "comedi: error setting up mite\n"); return ret; } dev->board_name = this_board->name; - printk(" %s", dev->board_name); - - printk(" ID=0x%02x", readb(devpriv->mite->daq_io_addr + ID_Register)); + printk(KERN_INFO "comedi board: %s, ID=0x%02x\n", dev->board_name, + readb(devpriv->mite->daq_io_addr + ID_Register)); ret = alloc_subdevices(dev, 3); if (ret < 0) @@ -415,7 +415,7 @@ s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 24; - s->range_table = &range_unknown; /* FIXME: actually conductance */ + s->range_table = &range_unknown; /* FIXME: actually conductance */ s->maxdata = 1; s->insn_bits = ni6527_do_insn_bits; @@ -442,30 +442,25 @@ ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt, IRQF_SHARED, "ni6527", dev); - if (ret < 0) { - printk(" irq not available"); - } else + if (ret < 0) + printk(KERN_WARNING "comedi i6527 irq not available\n"); + else dev->irq = mite_irq(devpriv->mite); - printk("\n"); - return 0; } static int ni6527_detach(struct comedi_device *dev) { - if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) { + if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control); - } - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } - if (devpriv && devpriv->mite) { + if (devpriv && devpriv->mite) mite_unsetup(devpriv->mite); - } return 0; } @@ -491,7 +486,7 @@ } } } - printk("no device found\n"); + printk(KERN_ERR "comedi 6527: no device found\n"); mite_list_devices(); return -EIO; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_at_ao.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_at_ao.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_at_ao.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_at_ao.c 2009-11-06 20:57:47.000000000 -0800 @@ -32,7 +32,8 @@ [0] - I/O port base address [1] - IRQ (unused) [2] - DMA (unused) - [3] - analog output range, set by jumpers on hardware (0 for -10 to 10V bipolar, 1 for 0V to 10V unipolar) + [3] - analog output range, set by jumpers on hardware (0 for -10 to 10V + bipolar, 1 for 0V to 10V unipolar) */ /* @@ -431,9 +432,8 @@ struct comedi_insn *insn, unsigned int *data) { int i; - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = 0; /* XXX */ - } return insn->n; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_atmio16d.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_atmio16d.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_atmio16d.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_atmio16d.c 2009-11-06 20:57:47.000000000 -0800 @@ -200,8 +200,8 @@ enum { dac_2comp, dac_straight } dac0_coding, dac1_coding; const struct comedi_lrange *ao_range_type_list[2]; unsigned int ao_readback[2]; - unsigned int com_reg_1_state; /* current state of command register 1 */ - unsigned int com_reg_2_state; /* current state of command register 2 */ + unsigned int com_reg_1_state; /* current state of command register 1 */ + unsigned int com_reg_2_state; /* current state of command register 2 */ }; static void reset_counters(struct comedi_device *dev) @@ -279,7 +279,9 @@ struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 0; -/* printk("atmio16d_interrupt!\n"); */ +#ifdef DEBUG1 + printk(KERN_DEBUG "atmio16d_interrupt!\n"); +#endif comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG)); @@ -293,7 +295,7 @@ { int err = 0, tmp; #ifdef DEBUG1 - printk("atmio16d_ai_cmdtest\n"); + printk(KERN_DEBUG "atmio16d_ai_cmdtest\n"); #endif /* make sure triggers are valid */ tmp = cmd->start_src; @@ -324,8 +326,8 @@ if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* step 2: make sure trigger sources are unique & mutually compatible */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->scan_begin_src != TRIG_EXT && cmd->scan_begin_src != TRIG_TIMER) @@ -397,7 +399,7 @@ unsigned int sample_count, tmp, chan, gain; int i; #ifdef DEBUG1 - printk("atmio16d_ai_cmd\n"); + printk(KERN_DEBUG "atmio16d_ai_cmd\n"); #endif /* This is slowly becoming a working command interface. * * It is still uber-experimental */ @@ -436,10 +438,10 @@ } else if (cmd->convert_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->convert_arg / 10000; - } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->convert_arg / 100000; - } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->convert_arg / 1000000; } @@ -504,10 +506,10 @@ } else if (cmd->scan_begin_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->scan_begin_arg / 10000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->scan_begin_arg / 100000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->scan_begin_arg / 1000000; } @@ -559,7 +561,7 @@ int status; #ifdef DEBUG1 - printk("atmio16d_ai_insn_read\n"); + printk(KERN_DEBUG "atmio16d_ai_insn_read\n"); #endif chan = CR_CHAN(insn->chanspec); gain = CR_RANGE(insn->chanspec); @@ -580,19 +582,18 @@ /* check conversion status */ status = inw(dev->iobase + STAT_REG); #ifdef DEBUG1 - printk("status=%x\n", status); + printk(KERN_DEBUG "status=%x\n", status); #endif if (status & STAT_AD_CONVAVAIL) { /* read the data now */ data[i] = inw(dev->iobase + AD_FIFO_REG); /* change to two's complement if need be */ - if (devpriv->adc_coding == adc_2comp) { + if (devpriv->adc_coding == adc_2comp) data[i] ^= 0x800; - } break; } if (status & STAT_AD_OVERFLOW) { - printk("atmio16d: a/d FIFO overflow\n"); + printk(KERN_INFO "atmio16d: a/d FIFO overflow\n"); outw(0, dev->iobase + AD_CLEAR_REG); return -ETIME; @@ -600,7 +601,7 @@ } /* end waiting, now check if it timed out */ if (t == ATMIO16D_TIMEOUT) { - printk("atmio16d: timeout\n"); + printk(KERN_INFO "atmio16d: timeout\n"); return -ETIME; } @@ -615,13 +616,11 @@ { int i; #ifdef DEBUG1 - printk("atmio16d_ao_insn_read\n"); + printk(KERN_DEBUG "atmio16d_ao_insn_read\n"); #endif - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; - } - return i; } @@ -633,7 +632,7 @@ int chan; int d; #ifdef DEBUG1 - printk("atmio16d_ao_insn_write\n"); + printk(KERN_DEBUG "atmio16d_ao_insn_write\n"); #endif chan = CR_CHAN(insn->chanspec); @@ -642,15 +641,13 @@ d = data[i]; switch (chan) { case 0: - if (devpriv->dac0_coding == dac_2comp) { + if (devpriv->dac0_coding == dac_2comp) d ^= 0x800; - } outw(d, dev->iobase + DAC0_REG); break; case 1: - if (devpriv->dac1_coding == dac_2comp) { + if (devpriv->dac1_coding == dac_2comp) d ^= 0x800; - } outw(d, dev->iobase + DAC1_REG); break; default: @@ -705,29 +702,29 @@ /* options[0] - I/O port options[1] - MIO irq - 0 == no irq - N == irq N {3,4,5,6,7,9,10,11,12,14,15} + 0 == no irq + N == irq N {3,4,5,6,7,9,10,11,12,14,15} options[2] - DIO irq - 0 == no irq - N == irq N {3,4,5,6,7,9} + 0 == no irq + N == irq N {3,4,5,6,7,9} options[3] - DMA1 channel - 0 == no DMA - N == DMA N {5,6,7} + 0 == no DMA + N == DMA N {5,6,7} options[4] - DMA2 channel - 0 == no DMA - N == DMA N {5,6,7} + 0 == no DMA + N == DMA N {5,6,7} options[5] - a/d mux - 0=differential, 1=single + 0=differential, 1=single options[6] - a/d range - 0=bipolar10, 1=bipolar5, 2=unipolar10 + 0=bipolar10, 1=bipolar5, 2=unipolar10 options[7] - dac0 range - 0=bipolar, 1=unipolar + 0=bipolar, 1=unipolar options[8] - dac0 reference - 0=internal, 1=external + 0=internal, 1=external options[9] - dac0 coding - 0=2's comp, 1=straight binary + 0=2's comp, 1=straight binary options[10] - dac1 range options[11] - dac1 reference @@ -745,7 +742,7 @@ /* make sure the address range is free and allocate it */ iobase = it->options[0]; - printk("comedi%d: atmio16d: 0x%04lx ", dev->minor, iobase); + printk(KERN_INFO "comedi%d: atmio16d: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, ATMIO16D_SIZE, "ni_atmio16d")) { printk("I/O port conflict\n"); return -EIO; @@ -772,13 +769,13 @@ ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev); if (ret < 0) { - printk("failed to allocate irq %u\n", irq); + printk(KERN_INFO "failed to allocate irq %u\n", irq); return ret; } dev->irq = irq; - printk("( irq = %u )\n", irq); + printk(KERN_INFO "( irq = %u )\n", irq); } else { - printk("( no irq )"); + printk(KERN_INFO "( no irq )"); } /* set device options */ @@ -855,11 +852,10 @@ /* 8255 subdevice */ s++; - if (boardtype->has_8255) { + if (boardtype->has_8255) subdev_8255_init(dev, s, NULL, dev->iobase); - } else { + else s->type = COMEDI_SUBD_UNUSED; - } /* don't yet know how to deal with counter/timers */ #if 0 @@ -876,7 +872,7 @@ static int atmio16d_detach(struct comedi_device *dev) { - printk("comedi%d: atmio16d: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: atmio16d: remove\n", dev->minor); if (dev->subdevices && boardtype->has_8255) subdev_8255_cleanup(dev, dev->subdevices + 3); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_labpc_cs.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_labpc_cs.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_labpc_cs.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_labpc_cs.c 2009-11-06 20:57:47.000000000 -0800 @@ -59,8 +59,7 @@ */ -#undef LABPC_DEBUG - /* #define LABPC_DEBUG *//* enable debugging messages */ +#undef LABPC_DEBUG /* debugging messages */ #include "../comedidev.h" @@ -77,14 +76,15 @@ #include #include -static struct pcmcia_device *pcmcia_cur_dev = NULL; +static struct pcmcia_device *pcmcia_cur_dev; static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it); static const struct labpc_board_struct labpc_cs_boards[] = { { .name = "daqcard-1200", - .device_id = 0x103, /* 0x10b is manufacturer id, 0x103 is device id */ + .device_id = 0x103, /* 0x10b is manufacturer id, + 0x103 is device id */ .ai_speed = 10000, .bustype = pcmcia_bustype, .register_layout = labpc_1200_layout, @@ -163,7 +163,7 @@ #ifdef PCMCIA_DEBUG static int pc_debug = PCMCIA_DEBUG; module_param(pc_debug, int, 0644); -#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) +#define DEBUG(n, args...) if (pc_debug > (n)) printk(KERN_DEBUG args) static const char *version = "ni_labpc.c, based on dummy_cs.c 1.31 2001/08/24 12:13:13"; #else @@ -291,9 +291,8 @@ labpc_release(link); } - /* This points to the parent local_info_t struct */ - if (link->priv) - kfree(link->priv); + /* This points to the parent local_info_t struct (may be null) */ + kfree(link->priv); } /* labpc_cs_detach */ @@ -402,7 +401,8 @@ link->io.BasePort2 = io->win[1].base; link->io.NumPorts2 = io->win[1].len; } - /* This reserves IO space but doesn't actually enable it */ + /* This reserves IO space but doesn't + actually enable it */ if (pcmcia_request_io(link, &link->io)) goto next_entry; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_labpc.h linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_labpc.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_labpc.h 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_labpc.h 2009-11-06 20:57:47.000000000 -0800 @@ -38,19 +38,27 @@ int device_id; /* device id for pci and pcmcia boards */ int ai_speed; /* maximum input speed in nanoseconds */ enum labpc_bustype bustype; /* ISA/PCI/etc. */ - enum labpc_register_layout register_layout; /* 1200 has extra registers compared to pc+ */ + + /* 1200 has extra registers compared to pc+ */ + enum labpc_register_layout register_layout; int has_ao; /* has analog output true/false */ const struct comedi_lrange *ai_range_table; const int *ai_range_code; const int *ai_range_is_unipolar; - unsigned ai_scan_up:1; /* board can auto scan up in ai channels, not just down */ - unsigned memory_mapped_io:1; /* uses memory mapped io instead of ioports */ + + /* board can auto scan up in ai channels, not just down */ + unsigned ai_scan_up:1; + + /* uses memory mapped io instead of ioports */ + unsigned memory_mapped_io:1; }; struct labpc_private { struct mite_struct *mite; /* for mite chip on pci-1200 */ - volatile unsigned long long count; /* number of data points left to be taken */ - unsigned int ao_value[NUM_AO_CHAN]; /* software copy of analog output values */ + /* number of data points left to be taken */ + volatile unsigned long long count; + /* software copy of analog output values */ + unsigned int ao_value[NUM_AO_CHAN]; /* software copys of bits written to command registers */ volatile unsigned int command1_bits; volatile unsigned int command2_bits; @@ -61,16 +69,34 @@ /* store last read of board status registers */ volatile unsigned int status1_bits; volatile unsigned int status2_bits; - unsigned int divisor_a0; /* value to load into board's counter a0 (conversion pacing) for timed conversions */ - unsigned int divisor_b0; /* value to load into board's counter b0 (master) for timed conversions */ - unsigned int divisor_b1; /* value to load into board's counter b1 (scan pacing) for timed conversions */ + /* + * value to load into board's counter a0 (conversion pacing) for timed + * conversions + */ + unsigned int divisor_a0; + /* + * value to load into board's counter b0 (master) for timed conversions + */ + unsigned int divisor_b0; + /* + * value to load into board's counter b1 (scan pacing) for timed + * conversions + */ + unsigned int divisor_b1; unsigned int dma_chan; /* dma channel to use */ u16 *dma_buffer; /* buffer ai will dma into */ - unsigned int dma_transfer_size; /* transfer size in bytes for current transfer */ - enum transfer_type current_transfer; /* we are using dma/fifo-half-full/etc. */ - unsigned int eeprom_data[EEPROM_SIZE]; /* stores contents of board's eeprom */ - unsigned int caldac[16]; /* stores settings of calibration dacs */ - /* function pointers so we can use inb/outb or readb/writeb as appropriate */ + /* transfer size in bytes for current transfer */ + unsigned int dma_transfer_size; + /* we are using dma/fifo-half-full/etc. */ + enum transfer_type current_transfer; + /* stores contents of board's eeprom */ + unsigned int eeprom_data[EEPROM_SIZE]; + /* stores settings of calibration dacs */ + unsigned int caldac[16]; + /* + * function pointers so we can use inb/outb or readb/writeb as + * appropriate + */ unsigned int (*read_byte) (unsigned long address); void (*write_byte) (unsigned int byte, unsigned long address); }; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_mio_common.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_mio_common.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_mio_common.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_mio_common.c 2009-11-06 20:57:47.000000000 -0800 @@ -2207,7 +2207,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_mio_cs.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_mio_cs.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_mio_cs.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_mio_cs.c 2009-11-06 20:57:47.000000000 -0800 @@ -250,9 +250,8 @@ /* PCMCIA layer frees the IO region */ - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } return 0; } @@ -294,9 +293,8 @@ { DPRINTK("cs_detach(link=%p)\n", link); - if (link->dev_node) { + if (link->dev_node) cs_release(link); - } } static int mio_cs_suspend(struct pcmcia_device *link) @@ -393,9 +391,8 @@ link->irq.IRQInfo1 = parse.cftable_entry.irq.IRQInfo1; link->irq.IRQInfo2 = parse.cftable_entry.irq.IRQInfo2; ret = pcmcia_request_irq(link, &link->irq); - if (ret) { + if (ret) printk("pcmcia_request_irq() returned error: %i\n", ret); - } /* printk("RequestIRQ 0x%02x\n",ret); */ link->conf.ConfigIndex = 1; @@ -437,9 +434,8 @@ } printk("\n"); printk(" board fingerprint (windowed):"); - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) printk(" 0x%04x", win_in(i)); - } printk("\n"); } #endif @@ -503,9 +499,8 @@ id = get_prodid(dev, link); for (i = 0; i < n_ni_boards; i++) { - if (ni_boards[i].device_id == id) { + if (ni_boards[i].device_id == id) return i; - } } printk("unknown board 0x%04x -- pretend it is a ", id); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_pcidio.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_pcidio.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/ni_pcidio.c 2009-11-04 15:20:35.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/ni_pcidio.c 2009-11-06 20:57:47.000000000 -0800 @@ -795,7 +795,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT) err++; if (cmd->scan_begin_src != TRIG_TIMER && diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcl726.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcl726.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcl726.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcl726.c 2009-11-06 20:57:47.000000000 -0800 @@ -39,27 +39,27 @@ Options for PCL-726: [0] - IO Base [2]...[7] - D/A output range for channel 1-6: - 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, - 4: 4-20mA, 5: unknown (external reference) + 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, + 4: 4-20mA, 5: unknown (external reference) Options for PCL-727: [0] - IO Base [2]...[13] - D/A output range for channel 1-12: - 0: 0-5V, 1: 0-10V, 2: +/-5V, - 3: 4-20mA + 0: 0-5V, 1: 0-10V, 2: +/-5V, + 3: 4-20mA Options for PCL-728 and ACL-6128: [0] - IO Base [2], [3] - D/A output range for channel 1 and 2: - 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, - 4: 4-20mA, 5: 0-20mA + 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, + 4: 4-20mA, 5: 0-20mA Options for ACL-6126: [0] - IO Base [1] - IRQ (0=disable, 3, 5, 6, 7, 9, 10, 11, 12, 15) (currently ignored) [2]...[7] - D/A output range for channel 1-6: - 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, - 4: 4-20mA + 0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V, + 4: 4-20mA */ /* @@ -127,7 +127,8 @@ int di_lo; int do_hi; int do_lo; - const struct comedi_lrange *const *range_type_list; /* list of supported ranges */ + const struct comedi_lrange *const *range_type_list; + /* list of supported ranges */ }; static const struct pcl726_board boardtypes[] = { @@ -204,9 +205,8 @@ int chan = CR_CHAN(insn->chanspec); int n; - for (n = 0; n < insn->n; n++) { + for (n = 0; n < insn->n; n++) data[n] = devpriv->ao_readback[chan]; - } return n; } @@ -256,10 +256,10 @@ iobase = it->options[0]; iorange = this_board->io_range; - printk("comedi%d: pcl726: board=%s, 0x%03lx ", dev->minor, + printk(KERN_WARNING "comedi%d: pcl726: board=%s, 0x%03lx ", dev->minor, this_board->name, iobase); if (!request_region(iobase, iorange, "pcl726")) { - printk("I/O port conflict\n"); + printk(KERN_WARNING "I/O port conflict\n"); return -EIO; } @@ -283,16 +283,16 @@ devpriv->first_chan = 2; if (irq) { /* we want to use IRQ */ if (((1 << irq) & boardtypes[board].IRQbits) == 0) { - printk - (", IRQ %d is out of allowed range, DISABLING IT", - irq); + printk(KERN_WARNING + ", IRQ %d is out of allowed range," + " DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { if (request_irq(irq, interrupt_pcl818, 0, "pcl726", dev)) { - printk - (", unable to allocate IRQ %d, DISABLING IT", - irq); + printk(KERN_WARNING + ", unable to allocate IRQ %d," + " DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { printk(", irq=%d", irq); @@ -372,9 +372,8 @@ /* printk("comedi%d: pcl726: remove\n",dev->minor); */ #ifdef ACL6126_IRQ - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } #endif if (dev->iobase) diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcm_common.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcm_common.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcm_common.c 2009-10-05 16:45:22.000000000 -0700 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcm_common.c 2009-11-06 20:57:47.000000000 -0800 @@ -41,7 +41,8 @@ if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* step 2: make sure trigger sources are unique and + * mutually compatible */ /* these tests are true if more than one _src bit is set */ if ((cmd->start_src & (cmd->start_src - 1)) != 0) @@ -107,5 +108,4 @@ return 0; } - EXPORT_SYMBOL(comedi_pcm_cmdtest); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcmmio.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcmmio.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/pcmmio.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/pcmmio.c 2009-11-06 20:57:47.000000000 -0800 @@ -32,8 +32,10 @@ four subdevices: subdevice 0 - 16 channels of 16-bit AI subdevice 1 - 8 channels of 16-bit AO - subdevice 2 - first 24 channels of the 48 channel of DIO (with edge-triggered interrupt support) - subdevice 3 - last 24 channels of the 48 channel DIO (no interrupt support for this bank of channels) + subdevice 2 - first 24 channels of the 48 channel of DIO + (with edge-triggered interrupt support) + subdevice 3 - last 24 channels of the 48 channel DIO + (no interrupt support for this bank of channels) Some notes: @@ -70,7 +72,8 @@ Configuration Options: [0] - I/O port base address - [1] - IRQ (optional -- for edge-detect interrupt support only, leave out if you don't need this feature) + [1] - IRQ (optional -- for edge-detect interrupt support only, + leave out if you don't need this feature) */ #include @@ -115,9 +118,11 @@ #define REG_PORT4 0x4 #define REG_PORT5 0x5 #define REG_INT_PENDING 0x6 -#define REG_PAGELOCK 0x7 /* page selector register, upper 2 bits select a page - and bits 0-5 are used to 'lock down' a particular - port above to make it readonly. */ +#define REG_PAGELOCK 0x7 /* + * page selector register, upper 2 bits select + * a page and bits 0-5 are used to 'lock down' + * a particular port above to make it readonly. + */ #define REG_POL0 0x8 #define REG_POL1 0x9 #define REG_POL2 0xA @@ -134,7 +139,7 @@ #define REG_PAGE_BITOFFSET 6 #define REG_LOCK_BITOFFSET 0 #define REG_PAGE_MASK (~((0x1<asics[asic].num = asic; devpriv->asics[asic].iobase = dev->iobase + 16 + asic * ASIC_IOSIZE; - devpriv->asics[asic].irq = 0; /* this gets actually set at the end of - this function when we - request_irqs */ + /* + * this gets actually set at the end of this function when we + * request_irqs + */ + devpriv->asics[asic].irq = 0; spin_lock_init(&devpriv->asics[asic].spinlock); } @@ -463,7 +492,10 @@ if (thisasic_chanct < CHANS_PER_PORT * INTR_PORTS_PER_ASIC && subpriv->dio.intr.asic < 0) { - /* this is an interrupt subdevice, so setup the struct */ + /* + * this is an interrupt subdevice, + * so setup the struct + */ subpriv->dio.intr.asic = asic; subpriv->dio.intr.active = 0; subpriv->dio.intr.stop_count = 0; @@ -484,7 +516,11 @@ chans_left -= s->n_chan; if (!chans_left) { - asic = 0; /* reset the asic to our first asic, to do intr subdevs */ + /* + * reset the asic to our first asic, + * to do intr subdevs + */ + asic = 0; port = 0; } @@ -507,8 +543,10 @@ devpriv->asics[asic].irq = irq[asic]; } - dev->irq = irq[0]; /* grr.. wish comedi dev struct supported multiple - irqs.. */ + dev->irq = irq[0]; /* + * grr.. wish comedi dev struct supported + * multiple irqs.. + */ if (irq[0]) { printk("irq: %u ", irq[0]); @@ -604,9 +642,14 @@ #endif if (write_mask_byte) { - /* this byte has some write_bits -- so set the output lines */ - byte &= ~write_mask_byte; /* clear bits for write mask */ - byte |= ~data_byte & write_mask_byte; /* set to inverted data_byte */ + /* + * this byte has some write_bits + * -- so set the output lines + */ + /* clear bits for write mask */ + byte &= ~write_mask_byte; + /* set to inverted data_byte */ + byte |= ~data_byte & write_mask_byte; /* Write out the new digital output state */ outb(byte, ioaddr); } @@ -670,9 +713,11 @@ byte &= ~(1 << bit_no); /**< set input channel to '0' */ - /* write out byte -- this is the only time we actually affect the - hardware as all channels are implicitly output -- but input - channels are set to float-high */ + /* + * write out byte -- this is the only time we actually affect + * the hardware as all channels are implicitly output + * -- but input channels are set to float-high + */ outb(byte, ioaddr); /* save to io_bits */ @@ -726,8 +771,8 @@ outb(0xff, baseaddr + REG_ENAB0); */ /* END DEBUG */ - switch_page(dev, asic, 0); /* switch back to default page 0 */ - + /* switch back to default page 0 */ + switch_page(dev, asic, 0); } } @@ -806,7 +851,10 @@ REG_INT_ID0 + port); if (io_lines_with_edges) - /* clear pending interrupt */ + /* + * clear pending + * interrupt + */ outb(0, iobase + REG_INT_ID0 + port); @@ -825,14 +873,21 @@ if (triggered) { struct comedi_subdevice *s; - /* TODO here: dispatch io lines to subdevs with commands.. */ + /* + * TODO here: dispatch io lines to subdevs + * with commands.. + */ printk ("PCMMIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n", irq, asic, triggered); for (s = dev->subdevices + 2; s < dev->subdevices + dev->n_subdevices; ++s) { - if (subpriv->dio.intr.asic == asic) { /* this is an interrupt subdev, and it matches this asic! */ + /* + * this is an interrupt subdev, + * and it matches this asic! + */ + if (subpriv->dio.intr.asic == asic) { unsigned long flags; unsigned oldevents; @@ -867,9 +922,8 @@ n < len; n++) { ch = CR_CHAN(s->async->cmd.chanlist[n]); - if (mytrig & (1U << ch)) { + if (mytrig & (1U << ch)) val |= (1U << n); - } } /* Write the scan to the buffer. */ if (comedi_buf_put(s->async, ((short *)&val)[0]) @@ -877,8 +931,7 @@ comedi_buf_put (s->async, ((short *) - &val)[1])) - { + &val)[1])) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Overflow! Stop acquisition!! */ @@ -981,9 +1034,16 @@ 1) << subpriv->dio.intr.first_chan; subpriv->dio.intr.enabled_mask = bits; - { /* the below code configures the board to use a specific IRQ from 0-15. */ + { + /* + * the below code configures the board + * to use a specific IRQ from 0-15. + */ unsigned char b; - /* set resource enable register to enable IRQ operation */ + /* + * set resource enable register + * to enable IRQ operation + */ outb(1 << 4, dev->iobase + 3); /* set bits 0-3 of b to the irq number from 0-15 */ b = dev->irq & ((1 << 4) - 1); @@ -1037,14 +1097,12 @@ spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags); s->async->inttrig = 0; - if (subpriv->dio.intr.active) { + if (subpriv->dio.intr.active) event = pcmmio_start_intr(dev, s); - } spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); - if (event) { + if (event) comedi_event(dev, s); - } return 1; } @@ -1086,9 +1144,8 @@ } spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags); - if (event) { + if (event) comedi_event(dev, s); - } return 0; } @@ -1136,17 +1193,32 @@ short sample, adc_adjust = 0; if (chan > 7) - chan -= 8, iooffset = 4; /* use the second dword for channels > 7 */ + chan -= 8, iooffset = 4; /* + * use the second dword + * for channels > 7 + */ if (aref != AREF_DIFF) { aref = AREF_GROUND; - command_byte |= 1 << 7; /* set bit 7 to indicate single-ended */ + command_byte |= 1 << 7; /* + * set bit 7 to indicate + * single-ended + */ } if (range < 2) - adc_adjust = 0x8000; /* bipolar ranges (-5,5 .. -10,10 need to be adjusted -- that is.. they need to wrap around by adding 0x8000 */ + adc_adjust = 0x8000; /* + * bipolar ranges + * (-5,5 .. -10,10 need to be + * adjusted -- that is.. they + * need to wrap around by + * adding 0x8000 + */ if (chan % 2) { - command_byte |= 1 << 6; /* odd-numbered channels have bit 6 set */ + command_byte |= 1 << 6; /* + * odd-numbered channels + * have bit 6 set + */ } /* select the channel, bits 4-5 == chan/2 */ @@ -1156,16 +1228,22 @@ command_byte |= (range & 0x3) << 2; /* need to do this twice to make sure mux settled */ - outb(command_byte, iobase + iooffset + 2); /* chan/range/aref select */ + /* chan/range/aref select */ + outb(command_byte, iobase + iooffset + 2); - adc_wait_ready(iobase + iooffset); /* wait for the adc to say it finised the conversion */ + /* wait for the adc to say it finised the conversion */ + adc_wait_ready(iobase + iooffset); - outb(command_byte, iobase + iooffset + 2); /* select the chan/range/aref AGAIN */ + /* select the chan/range/aref AGAIN */ + outb(command_byte, iobase + iooffset + 2); adc_wait_ready(iobase + iooffset); - sample = inb(iobase + iooffset + 0); /* read data lo byte */ - sample |= inb(iobase + iooffset + 1) << 8; /* read data hi byte */ + /* read data lo byte */ + sample = inb(iobase + iooffset + 0); + + /* read data hi byte */ + sample |= inb(iobase + iooffset + 1) << 8; sample += adc_adjust; /* adjustment .. munge data */ data[n] = sample; } @@ -1227,15 +1305,24 @@ wait_dac_ready(iobase + iooffset); - outb(data[n] & 0xff, iobase + iooffset + 0); /* low order byte */ - outb((data[n] >> 8) & 0xff, iobase + iooffset + 1); /* high order byte */ - command_byte = 0x70 | (chan << 1); /* set bit 4 of command byte to indicate data is loaded and trigger conversion */ + /* low order byte */ + outb(data[n] & 0xff, iobase + iooffset + 0); + + /* high order byte */ + outb((data[n] >> 8) & 0xff, iobase + iooffset + 1); + + /* + * set bit 4 of command byte to indicate + * data is loaded and trigger conversion + */ + command_byte = 0x70 | (chan << 1); /* trigger converion */ outb(command_byte, iobase + iooffset + 2); wait_dac_ready(iobase + iooffset); - subpriv->ao.shadow_samples[chan] = data[n]; /* save to shadow register for ao_rinsn */ + /* save to shadow register for ao_rinsn */ + subpriv->ao.shadow_samples[chan] = data[n]; } } return n; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/quatech_daqp_cs.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/quatech_daqp_cs.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/quatech_daqp_cs.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/quatech_daqp_cs.c 2009-11-06 20:57:47.000000000 -0800 @@ -506,7 +506,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_FOLLOW) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/rtd520.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/rtd520.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/rtd520.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/rtd520.c 2009-11-06 20:57:47.000000000 -0800 @@ -1768,7 +1768,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) { err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/s626.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/s626.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/s626.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/s626.c 2009-11-06 20:57:47.000000000 -0800 @@ -1926,7 +1926,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT && cmd->scan_begin_src != TRIG_FOLLOW) diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/s626.h linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/s626.h --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/s626.h 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/s626.h 2009-11-06 20:57:47.000000000 -0800 @@ -76,14 +76,6 @@ #define FALSE (0) #endif -#if !defined(EXTERN) -#if defined(__cplusplus) -#define EXTERN extern "C" -#else -#define EXTERN extern -#endif -#endif - #if !defined(INLINE) #define INLINE static __inline #endif diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/serial2002.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/serial2002.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/serial2002.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/serial2002.c 2009-11-06 20:57:47.000000000 -0800 @@ -125,14 +125,9 @@ static long tty_ioctl(struct file *f, unsigned op, unsigned long param) { -#ifdef HAVE_UNLOCKED_IOCTL - if (f->f_op->unlocked_ioctl) { + if (f->f_op->unlocked_ioctl) return f->f_op->unlocked_ioctl(f, op, param); - } -#endif - if (f->f_op->ioctl) { - return f->f_op->ioctl(f->f_dentry->d_inode, f, op, param); - } + return -ENOSYS; } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/skel.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/skel.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/skel.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/skel.c 2009-11-06 20:57:47.000000000 -0800 @@ -399,7 +399,7 @@ /* step 2: make sure trigger sources are unique and mutually compatible */ - /* note that mutual compatiblity is not an issue here */ + /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT) err++; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/usbdux.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/usbdux.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/usbdux.c 2009-11-06 20:57:04.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/usbdux.c 2009-11-06 20:57:47.000000000 -0800 @@ -979,7 +979,7 @@ /* * step 2: make sure trigger sources are unique and mutually compatible - * note that mutual compatiblity is not an issue here + * note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->scan_begin_src != TRIG_EXT && @@ -1557,7 +1557,7 @@ /* * step 2: make sure trigger sources are unique and mutually compatible - * note that mutual compatiblity is not an issue here + * note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->scan_begin_src != TRIG_EXT && diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/vmk80xx.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/vmk80xx.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers/vmk80xx.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers/vmk80xx.c 2009-11-06 20:57:47.000000000 -0800 @@ -76,18 +76,18 @@ }; static struct usb_device_id vmk80xx_id_table[] = { - {USB_DEVICE(0x10cf, 0x5500),.driver_info = DEVICE_VMK8055}, - {USB_DEVICE(0x10cf, 0x5501),.driver_info = DEVICE_VMK8055}, - {USB_DEVICE(0x10cf, 0x5502),.driver_info = DEVICE_VMK8055}, - {USB_DEVICE(0x10cf, 0x5503),.driver_info = DEVICE_VMK8055}, - {USB_DEVICE(0x10cf, 0x8061),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8062),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8063),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8064),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8065),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8066),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8067),.driver_info = DEVICE_VMK8061}, - {USB_DEVICE(0x10cf, 0x8068),.driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055}, + {USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055}, + {USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055}, + {USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055}, + {USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061}, + {USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061}, {} /* terminating entry */ }; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers.c linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers.c --- linux-2.6.32-rc6-usb/drivers/staging/comedi/drivers.c 2009-11-04 15:20:34.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/comedi/drivers.c 2009-11-06 20:57:47.000000000 -0800 @@ -387,7 +387,7 @@ return 1; } -static inline unsigned long uvirt_to_kva(pgd_t * pgd, unsigned long adr) +static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr) { unsigned long ret = 0UL; pmd_t *pmd; diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/cx25821/cx25821-core.c linux-2.6.32-rc6-staging/drivers/staging/cx25821/cx25821-core.c --- linux-2.6.32-rc6-usb/drivers/staging/cx25821/cx25821-core.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/cx25821/cx25821-core.c 2009-11-06 20:57:48.000000000 -0800 @@ -1521,7 +1521,7 @@ .resume = NULL, }; -static int cx25821_init(void) +static int __init cx25821_init(void) { INIT_LIST_HEAD(&cx25821_devlist); printk(KERN_INFO "cx25821 driver version %d.%d.%d loaded\n", @@ -1530,7 +1530,7 @@ return pci_register_driver(&cx25821_pci_driver); } -static void cx25821_fini(void) +static void __exit cx25821_fini(void) { pci_unregister_driver(&cx25821_pci_driver); } diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/Kconfig linux-2.6.32-rc6-staging/drivers/staging/dream/camera/Kconfig --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/Kconfig 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/Kconfig 1969-12-31 16:00:00.000000000 -0800 @@ -1,46 +0,0 @@ -comment "Qualcomm MSM Camera And Video" - -menuconfig MSM_CAMERA - bool "Qualcomm MSM camera and video capture support" - depends on ARCH_MSM && VIDEO_V4L2_COMMON - help - Say Y here to enable selecting the video adapters for - Qualcomm msm camera and video encoding - -config MSM_CAMERA_DEBUG - bool "Qualcomm MSM camera debugging with printk" - depends on MSM_CAMERA - help - Enable printk() debug for msm camera - -config MSM_CAMERA_FLASH - bool "Qualcomm MSM camera flash support" - depends on MSM_CAMERA - ---help--- - Enable support for LED flash for msm camera - - -comment "Camera Sensor Selection" -config MT9T013 - bool "Sensor mt9t013 (BAYER 3M)" - depends on MSM_CAMERA - ---help--- - MICRON 3M Bayer Sensor with AutoFocus - -config MT9D112 - bool "Sensor mt9d112 (YUV 2M)" - depends on MSM_CAMERA - ---help--- - MICRON 2M YUV Sensor - -config MT9P012 - bool "Sensor mt9p012 (BAYER 5M)" - depends on MSM_CAMERA - ---help--- - MICRON 5M Bayer Sensor with Autofocus - -config S5K3E2FX - bool "Sensor s5k3e2fx (Samsung 5M)" - depends on MSM_CAMERA - ---help--- - Samsung 5M with Autofocus diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/Makefile linux-2.6.32-rc6-staging/drivers/staging/dream/camera/Makefile --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/Makefile 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/Makefile 1969-12-31 16:00:00.000000000 -0800 @@ -1,7 +0,0 @@ -obj-$(CONFIG_MT9T013) += mt9t013.o mt9t013_reg.o -obj-$(CONFIG_MT9D112) += mt9d112.o mt9d112_reg.o -obj-$(CONFIG_MT9P012) += mt9p012_fox.o mt9p012_reg.o -obj-$(CONFIG_MSM_CAMERA) += msm_camera.o msm_v4l2.o -obj-$(CONFIG_S5K3E2FX) += s5k3e2fx.o -obj-$(CONFIG_ARCH_MSM) += msm_vfe7x.o msm_io7x.o -obj-$(CONFIG_ARCH_QSD) += msm_vfe8x.o msm_vfe8x_proc.o msm_io8x.o diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_camera.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_camera.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_camera.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_camera.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,2181 +0,0 @@ -/* - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - */ - -//FIXME: most allocations need not be GFP_ATOMIC -/* FIXME: management of mutexes */ -/* FIXME: msm_pmem_region_lookup return values */ -/* FIXME: way too many copy to/from user */ -/* FIXME: does region->active mean free */ -/* FIXME: check limits on command lenghts passed from userspace */ -/* FIXME: __msm_release: which queues should we flush when opencnt != 0 */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define MSM_MAX_CAMERA_SENSORS 5 - -#define ERR_USER_COPY(to) pr_err("%s(%d): copy %s user\n", \ - __func__, __LINE__, ((to) ? "to" : "from")) -#define ERR_COPY_FROM_USER() ERR_USER_COPY(0) -#define ERR_COPY_TO_USER() ERR_USER_COPY(1) - -static struct class *msm_class; -static dev_t msm_devno; -static LIST_HEAD(msm_sensors); - -#define __CONTAINS(r, v, l, field) ({ \ - typeof(r) __r = r; \ - typeof(v) __v = v; \ - typeof(v) __e = __v + l; \ - int res = __v >= __r->field && \ - __e <= __r->field + __r->len; \ - res; \ -}) - -#define CONTAINS(r1, r2, field) ({ \ - typeof(r2) __r2 = r2; \ - __CONTAINS(r1, __r2->field, __r2->len, field); \ -}) - -#define IN_RANGE(r, v, field) ({ \ - typeof(r) __r = r; \ - typeof(v) __vv = v; \ - int res = ((__vv >= __r->field) && \ - (__vv < (__r->field + __r->len))); \ - res; \ -}) - -#define OVERLAPS(r1, r2, field) ({ \ - typeof(r1) __r1 = r1; \ - typeof(r2) __r2 = r2; \ - typeof(__r2->field) __v = __r2->field; \ - typeof(__v) __e = __v + __r2->len - 1; \ - int res = (IN_RANGE(__r1, __v, field) || \ - IN_RANGE(__r1, __e, field)); \ - res; \ -}) - -#define MSM_DRAIN_QUEUE_NOSYNC(sync, name) do { \ - struct msm_queue_cmd *qcmd = NULL; \ - CDBG("%s: draining queue "#name"\n", __func__); \ - while (!list_empty(&(sync)->name)) { \ - qcmd = list_first_entry(&(sync)->name, \ - struct msm_queue_cmd, list); \ - list_del_init(&qcmd->list); \ - kfree(qcmd); \ - }; \ -} while(0) - -#define MSM_DRAIN_QUEUE(sync, name) do { \ - unsigned long flags; \ - spin_lock_irqsave(&(sync)->name##_lock, flags); \ - MSM_DRAIN_QUEUE_NOSYNC(sync, name); \ - spin_unlock_irqrestore(&(sync)->name##_lock, flags); \ -} while(0) - -static int check_overlap(struct hlist_head *ptype, - unsigned long paddr, - unsigned long len) -{ - struct msm_pmem_region *region; - struct msm_pmem_region t = { .paddr = paddr, .len = len }; - struct hlist_node *node; - - hlist_for_each_entry(region, node, ptype, list) { - if (CONTAINS(region, &t, paddr) || - CONTAINS(&t, region, paddr) || - OVERLAPS(region, &t, paddr)) { - printk(KERN_ERR - " region (PHYS %p len %ld)" - " clashes with registered region" - " (paddr %p len %ld)\n", - (void *)t.paddr, t.len, - (void *)region->paddr, region->len); - return -1; - } - } - - return 0; -} - -static int msm_pmem_table_add(struct hlist_head *ptype, - struct msm_pmem_info *info) -{ - struct file *file; - unsigned long paddr; - unsigned long vstart; - unsigned long len; - int rc; - struct msm_pmem_region *region; - - rc = get_pmem_file(info->fd, &paddr, &vstart, &len, &file); - if (rc < 0) { - pr_err("msm_pmem_table_add: get_pmem_file fd %d error %d\n", - info->fd, rc); - return rc; - } - - if (check_overlap(ptype, paddr, len) < 0) - return -EINVAL; - - CDBG("%s: type = %d, paddr = 0x%lx, vaddr = 0x%lx\n", - __func__, - info->type, paddr, (unsigned long)info->vaddr); - - region = kmalloc(sizeof(*region), GFP_KERNEL); - if (!region) - return -ENOMEM; - - INIT_HLIST_NODE(®ion->list); - - region->type = info->type; - region->vaddr = info->vaddr; - region->paddr = paddr; - region->len = len; - region->file = file; - region->y_off = info->y_off; - region->cbcr_off = info->cbcr_off; - region->fd = info->fd; - region->active = info->active; - - hlist_add_head(&(region->list), ptype); - - return 0; -} - -/* return of 0 means failure */ -static uint8_t msm_pmem_region_lookup(struct hlist_head *ptype, - int pmem_type, struct msm_pmem_region *reg, uint8_t maxcount) -{ - struct msm_pmem_region *region; - struct msm_pmem_region *regptr; - struct hlist_node *node, *n; - - uint8_t rc = 0; - - regptr = reg; - - hlist_for_each_entry_safe(region, node, n, ptype, list) { - if (region->type == pmem_type && region->active) { - *regptr = *region; - rc += 1; - if (rc >= maxcount) - break; - regptr++; - } - } - - return rc; -} - -static unsigned long msm_pmem_frame_ptov_lookup(struct msm_sync *sync, - unsigned long pyaddr, - unsigned long pcbcraddr, - uint32_t *yoff, uint32_t *cbcroff, int *fd) -{ - struct msm_pmem_region *region; - struct hlist_node *node, *n; - - hlist_for_each_entry_safe(region, node, n, &sync->frame, list) { - if (pyaddr == (region->paddr + region->y_off) && - pcbcraddr == (region->paddr + - region->cbcr_off) && - region->active) { - /* offset since we could pass vaddr inside - * a registerd pmem buffer - */ - *yoff = region->y_off; - *cbcroff = region->cbcr_off; - *fd = region->fd; - region->active = 0; - return (unsigned long)(region->vaddr); - } - } - - return 0; -} - -static unsigned long msm_pmem_stats_ptov_lookup(struct msm_sync *sync, - unsigned long addr, int *fd) -{ - struct msm_pmem_region *region; - struct hlist_node *node, *n; - - hlist_for_each_entry_safe(region, node, n, &sync->stats, list) { - if (addr == region->paddr && region->active) { - /* offset since we could pass vaddr inside a - * registered pmem buffer */ - *fd = region->fd; - region->active = 0; - return (unsigned long)(region->vaddr); - } - } - - return 0; -} - -static unsigned long msm_pmem_frame_vtop_lookup(struct msm_sync *sync, - unsigned long buffer, - uint32_t yoff, uint32_t cbcroff, int fd) -{ - struct msm_pmem_region *region; - struct hlist_node *node, *n; - - hlist_for_each_entry_safe(region, - node, n, &sync->frame, list) { - if (((unsigned long)(region->vaddr) == buffer) && - (region->y_off == yoff) && - (region->cbcr_off == cbcroff) && - (region->fd == fd) && - (region->active == 0)) { - - region->active = 1; - return region->paddr; - } - } - - return 0; -} - -static unsigned long msm_pmem_stats_vtop_lookup( - struct msm_sync *sync, - unsigned long buffer, - int fd) -{ - struct msm_pmem_region *region; - struct hlist_node *node, *n; - - hlist_for_each_entry_safe(region, node, n, &sync->stats, list) { - if (((unsigned long)(region->vaddr) == buffer) && - (region->fd == fd) && region->active == 0) { - region->active = 1; - return region->paddr; - } - } - - return 0; -} - -static int __msm_pmem_table_del(struct msm_sync *sync, - struct msm_pmem_info *pinfo) -{ - int rc = 0; - struct msm_pmem_region *region; - struct hlist_node *node, *n; - - switch (pinfo->type) { - case MSM_PMEM_OUTPUT1: - case MSM_PMEM_OUTPUT2: - case MSM_PMEM_THUMBAIL: - case MSM_PMEM_MAINIMG: - case MSM_PMEM_RAW_MAINIMG: - hlist_for_each_entry_safe(region, node, n, - &sync->frame, list) { - - if (pinfo->type == region->type && - pinfo->vaddr == region->vaddr && - pinfo->fd == region->fd) { - hlist_del(node); - put_pmem_file(region->file); - kfree(region); - } - } - break; - - case MSM_PMEM_AEC_AWB: - case MSM_PMEM_AF: - hlist_for_each_entry_safe(region, node, n, - &sync->stats, list) { - - if (pinfo->type == region->type && - pinfo->vaddr == region->vaddr && - pinfo->fd == region->fd) { - hlist_del(node); - put_pmem_file(region->file); - kfree(region); - } - } - break; - - default: - rc = -EINVAL; - break; - } - - return rc; -} - -static int msm_pmem_table_del(struct msm_sync *sync, void __user *arg) -{ - struct msm_pmem_info info; - - if (copy_from_user(&info, arg, sizeof(info))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - return __msm_pmem_table_del(sync, &info); -} - -static int __msm_get_frame(struct msm_sync *sync, - struct msm_frame *frame) -{ - unsigned long flags; - int rc = 0; - - struct msm_queue_cmd *qcmd = NULL; - struct msm_vfe_phy_info *pphy; - - spin_lock_irqsave(&sync->prev_frame_q_lock, flags); - if (!list_empty(&sync->prev_frame_q)) { - qcmd = list_first_entry(&sync->prev_frame_q, - struct msm_queue_cmd, list); - list_del_init(&qcmd->list); - } - spin_unlock_irqrestore(&sync->prev_frame_q_lock, flags); - - if (!qcmd) { - pr_err("%s: no preview frame.\n", __func__); - return -EAGAIN; - } - - pphy = (struct msm_vfe_phy_info *)(qcmd->command); - - frame->buffer = - msm_pmem_frame_ptov_lookup(sync, - pphy->y_phy, - pphy->cbcr_phy, &(frame->y_off), - &(frame->cbcr_off), &(frame->fd)); - if (!frame->buffer) { - pr_err("%s: cannot get frame, invalid lookup address " - "y=%x cbcr=%x offset=%d\n", - __FUNCTION__, - pphy->y_phy, - pphy->cbcr_phy, - frame->y_off); - rc = -EINVAL; - } - - CDBG("__msm_get_frame: y=0x%x, cbcr=0x%x, qcmd=0x%x, virt_addr=0x%x\n", - pphy->y_phy, pphy->cbcr_phy, (int) qcmd, (int) frame->buffer); - - kfree(qcmd); - return rc; -} - -static int msm_get_frame(struct msm_sync *sync, void __user *arg) -{ - int rc = 0; - struct msm_frame frame; - - if (copy_from_user(&frame, - arg, - sizeof(struct msm_frame))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - rc = __msm_get_frame(sync, &frame); - if (rc < 0) - return rc; - - if (sync->croplen) { - if (frame.croplen > sync->croplen) { - pr_err("msm_get_frame: invalid frame croplen %d\n", - frame.croplen); - return -EINVAL; - } - - if (copy_to_user((void *)frame.cropinfo, - sync->cropinfo, - sync->croplen)) { - ERR_COPY_TO_USER(); - return -EFAULT; - } - } - - if (copy_to_user((void *)arg, - &frame, sizeof(struct msm_frame))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - } - - CDBG("Got frame!!!\n"); - - return rc; -} - -static int msm_enable_vfe(struct msm_sync *sync, void __user *arg) -{ - int rc = -EIO; - struct camera_enable_cmd cfg; - - if (copy_from_user(&cfg, - arg, - sizeof(struct camera_enable_cmd))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - if (sync->vfefn.vfe_enable) - rc = sync->vfefn.vfe_enable(&cfg); - - CDBG("msm_enable_vfe: returned rc = %d\n", rc); - return rc; -} - -static int msm_disable_vfe(struct msm_sync *sync, void __user *arg) -{ - int rc = -EIO; - struct camera_enable_cmd cfg; - - if (copy_from_user(&cfg, - arg, - sizeof(struct camera_enable_cmd))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - if (sync->vfefn.vfe_disable) - rc = sync->vfefn.vfe_disable(&cfg, NULL); - - CDBG("msm_disable_vfe: returned rc = %d\n", rc); - return rc; -} - -static struct msm_queue_cmd* __msm_control(struct msm_sync *sync, - struct msm_control_device_queue *queue, - struct msm_queue_cmd *qcmd, - int timeout) -{ - unsigned long flags; - int rc; - - spin_lock_irqsave(&sync->msg_event_q_lock, flags); - list_add_tail(&qcmd->list, &sync->msg_event_q); - /* wake up config thread */ - wake_up(&sync->msg_event_wait); - spin_unlock_irqrestore(&sync->msg_event_q_lock, flags); - - if (!queue) - return NULL; - - /* wait for config status */ - rc = wait_event_interruptible_timeout( - queue->ctrl_status_wait, - !list_empty_careful(&queue->ctrl_status_q), - timeout); - if (list_empty_careful(&queue->ctrl_status_q)) { - if (!rc) - rc = -ETIMEDOUT; - if (rc < 0) { - pr_err("msm_control: wait_event error %d\n", rc); -#if 0 - /* This is a bit scary. If we time out too early, we - * will free qcmd at the end of this function, and the - * dsp may do the same when it does respond, so we - * remove the message from the source queue. - */ - pr_err("%s: error waiting for ctrl_status_q: %d\n", - __func__, rc); - spin_lock_irqsave(&sync->msg_event_q_lock, flags); - list_del_init(&qcmd->list); - spin_unlock_irqrestore(&sync->msg_event_q_lock, flags); -#endif - return ERR_PTR(rc); - } - } - - /* control command status is ready */ - spin_lock_irqsave(&queue->ctrl_status_q_lock, flags); - BUG_ON(list_empty(&queue->ctrl_status_q)); - qcmd = list_first_entry(&queue->ctrl_status_q, - struct msm_queue_cmd, list); - list_del_init(&qcmd->list); - spin_unlock_irqrestore(&queue->ctrl_status_q_lock, flags); - - return qcmd; -} - -static int msm_control(struct msm_control_device *ctrl_pmsm, - int block, - void __user *arg) -{ - int rc = 0; - - struct msm_sync *sync = ctrl_pmsm->pmsm->sync; - struct msm_ctrl_cmd udata, *ctrlcmd; - struct msm_queue_cmd *qcmd = NULL, *qcmd_temp; - - if (copy_from_user(&udata, arg, sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - goto end; - } - - qcmd = kmalloc(sizeof(struct msm_queue_cmd) + - sizeof(struct msm_ctrl_cmd) + udata.length, - GFP_KERNEL); - if (!qcmd) { - pr_err("msm_control: cannot allocate buffer\n"); - rc = -ENOMEM; - goto end; - } - - qcmd->type = MSM_CAM_Q_CTRL; - qcmd->command = ctrlcmd = (struct msm_ctrl_cmd *)(qcmd + 1); - *ctrlcmd = udata; - ctrlcmd->value = ctrlcmd + 1; - - if (udata.length) { - if (copy_from_user(ctrlcmd->value, - udata.value, udata.length)) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - goto end; - } - } - - if (!block) { - /* qcmd will be set to NULL */ - qcmd = __msm_control(sync, NULL, qcmd, 0); - goto end; - } - - qcmd_temp = __msm_control(sync, - &ctrl_pmsm->ctrl_q, - qcmd, MAX_SCHEDULE_TIMEOUT); - - if (IS_ERR(qcmd_temp)) { - rc = PTR_ERR(qcmd_temp); - goto end; - } - qcmd = qcmd_temp; - - if (qcmd->command) { - void __user *to = udata.value; - udata = *(struct msm_ctrl_cmd *)qcmd->command; - if (udata.length > 0) { - if (copy_to_user(to, - udata.value, - udata.length)) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto end; - } - } - udata.value = to; - - if (copy_to_user((void *)arg, &udata, - sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto end; - } - } - -end: - /* Note: if we get here as a result of an error, we will free the - * qcmd that we kmalloc() in this function. When we come here as - * a result of a successful completion, we are freeing the qcmd that - * we dequeued from queue->ctrl_status_q. - */ - if (qcmd) - kfree(qcmd); - - CDBG("msm_control: end rc = %d\n", rc); - return rc; -} - -static int msm_get_stats(struct msm_sync *sync, void __user *arg) -{ - unsigned long flags; - int timeout; - int rc = 0; - - struct msm_stats_event_ctrl se; - - struct msm_queue_cmd *qcmd = NULL; - struct msm_ctrl_cmd *ctrl = NULL; - struct msm_vfe_resp *data = NULL; - struct msm_stats_buf stats; - - if (copy_from_user(&se, arg, - sizeof(struct msm_stats_event_ctrl))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - timeout = (int)se.timeout_ms; - - CDBG("msm_get_stats timeout %d\n", timeout); - rc = wait_event_interruptible_timeout( - sync->msg_event_wait, - !list_empty_careful(&sync->msg_event_q), - msecs_to_jiffies(timeout)); - if (list_empty_careful(&sync->msg_event_q)) { - if (rc == 0) - rc = -ETIMEDOUT; - if (rc < 0) { - pr_err("msm_get_stats error %d\n", rc); - return rc; - } - } - CDBG("msm_get_stats returned from wait: %d\n", rc); - - spin_lock_irqsave(&sync->msg_event_q_lock, flags); - BUG_ON(list_empty(&sync->msg_event_q)); - qcmd = list_first_entry(&sync->msg_event_q, - struct msm_queue_cmd, list); - list_del_init(&qcmd->list); - spin_unlock_irqrestore(&sync->msg_event_q_lock, flags); - - CDBG("=== received from DSP === %d\n", qcmd->type); - - switch (qcmd->type) { - case MSM_CAM_Q_VFE_EVT: - case MSM_CAM_Q_VFE_MSG: - data = (struct msm_vfe_resp *)(qcmd->command); - - /* adsp event and message */ - se.resptype = MSM_CAM_RESP_STAT_EVT_MSG; - - /* 0 - msg from aDSP, 1 - event from mARM */ - se.stats_event.type = data->evt_msg.type; - se.stats_event.msg_id = data->evt_msg.msg_id; - se.stats_event.len = data->evt_msg.len; - - CDBG("msm_get_stats, qcmd->type = %d\n", qcmd->type); - CDBG("length = %d\n", se.stats_event.len); - CDBG("msg_id = %d\n", se.stats_event.msg_id); - - if ((data->type == VFE_MSG_STATS_AF) || - (data->type == VFE_MSG_STATS_WE)) { - - stats.buffer = - msm_pmem_stats_ptov_lookup(sync, - data->phy.sbuf_phy, - &(stats.fd)); - if (!stats.buffer) { - pr_err("%s: msm_pmem_stats_ptov_lookup error\n", - __FUNCTION__); - rc = -EINVAL; - goto failure; - } - - if (copy_to_user((void *)(se.stats_event.data), - &stats, - sizeof(struct msm_stats_buf))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto failure; - } - } else if ((data->evt_msg.len > 0) && - (data->type == VFE_MSG_GENERAL)) { - if (copy_to_user((void *)(se.stats_event.data), - data->evt_msg.data, - data->evt_msg.len)) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - } - } else if (data->type == VFE_MSG_OUTPUT1 || - data->type == VFE_MSG_OUTPUT2) { - if (copy_to_user((void *)(se.stats_event.data), - data->extdata, - data->extlen)) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - } - } else if (data->type == VFE_MSG_SNAPSHOT && sync->pict_pp) { - struct msm_postproc buf; - struct msm_pmem_region region; - buf.fmnum = msm_pmem_region_lookup(&sync->frame, - MSM_PMEM_MAINIMG, - ®ion, 1); - if (buf.fmnum == 1) { - buf.fmain.buffer = (unsigned long)region.vaddr; - buf.fmain.y_off = region.y_off; - buf.fmain.cbcr_off = region.cbcr_off; - buf.fmain.fd = region.fd; - } else { - buf.fmnum = msm_pmem_region_lookup(&sync->frame, - MSM_PMEM_RAW_MAINIMG, - ®ion, 1); - if (buf.fmnum == 1) { - buf.fmain.path = MSM_FRAME_PREV_2; - buf.fmain.buffer = - (unsigned long)region.vaddr; - buf.fmain.fd = region.fd; - } - else { - pr_err("%s: pmem lookup failed\n", - __func__); - rc = -EINVAL; - } - } - - if (copy_to_user((void *)(se.stats_event.data), &buf, - sizeof(buf))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto failure; - } - CDBG("snapshot copy_to_user!\n"); - } - break; - - case MSM_CAM_Q_CTRL: - /* control command from control thread */ - ctrl = (struct msm_ctrl_cmd *)(qcmd->command); - - CDBG("msm_get_stats, qcmd->type = %d\n", qcmd->type); - CDBG("length = %d\n", ctrl->length); - - if (ctrl->length > 0) { - if (copy_to_user((void *)(se.ctrl_cmd.value), - ctrl->value, - ctrl->length)) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto failure; - } - } - - se.resptype = MSM_CAM_RESP_CTRL; - - /* what to control */ - se.ctrl_cmd.type = ctrl->type; - se.ctrl_cmd.length = ctrl->length; - se.ctrl_cmd.resp_fd = ctrl->resp_fd; - break; - - case MSM_CAM_Q_V4L2_REQ: - /* control command from v4l2 client */ - ctrl = (struct msm_ctrl_cmd *)(qcmd->command); - - CDBG("msm_get_stats, qcmd->type = %d\n", qcmd->type); - CDBG("length = %d\n", ctrl->length); - - if (ctrl->length > 0) { - if (copy_to_user((void *)(se.ctrl_cmd.value), - ctrl->value, ctrl->length)) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - goto failure; - } - } - - /* 2 tells config thread this is v4l2 request */ - se.resptype = MSM_CAM_RESP_V4L2; - - /* what to control */ - se.ctrl_cmd.type = ctrl->type; - se.ctrl_cmd.length = ctrl->length; - break; - - default: - rc = -EFAULT; - goto failure; - } /* switch qcmd->type */ - - if (copy_to_user((void *)arg, &se, sizeof(se))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - } - -failure: - if (qcmd) - kfree(qcmd); - - CDBG("msm_get_stats: %d\n", rc); - return rc; -} - -static int msm_ctrl_cmd_done(struct msm_control_device *ctrl_pmsm, - void __user *arg) -{ - unsigned long flags; - int rc = 0; - - struct msm_ctrl_cmd udata, *ctrlcmd; - struct msm_queue_cmd *qcmd = NULL; - - if (copy_from_user(&udata, arg, sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - goto end; - } - - qcmd = kmalloc(sizeof(struct msm_queue_cmd) + - sizeof(struct msm_ctrl_cmd) + udata.length, - GFP_KERNEL); - if (!qcmd) { - rc = -ENOMEM; - goto end; - } - - qcmd->command = ctrlcmd = (struct msm_ctrl_cmd *)(qcmd + 1); - *ctrlcmd = udata; - if (udata.length > 0) { - ctrlcmd->value = ctrlcmd + 1; - if (copy_from_user(ctrlcmd->value, - (void *)udata.value, - udata.length)) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - kfree(qcmd); - goto end; - } - } - else ctrlcmd->value = NULL; - -end: - CDBG("msm_ctrl_cmd_done: end rc = %d\n", rc); - if (rc == 0) { - /* wake up control thread */ - spin_lock_irqsave(&ctrl_pmsm->ctrl_q.ctrl_status_q_lock, flags); - list_add_tail(&qcmd->list, &ctrl_pmsm->ctrl_q.ctrl_status_q); - wake_up(&ctrl_pmsm->ctrl_q.ctrl_status_wait); - spin_unlock_irqrestore(&ctrl_pmsm->ctrl_q.ctrl_status_q_lock, flags); - } - - return rc; -} - -static int msm_config_vfe(struct msm_sync *sync, void __user *arg) -{ - struct msm_vfe_cfg_cmd cfgcmd; - struct msm_pmem_region region[8]; - struct axidata axi_data; - void *data = NULL; - int rc = -EIO; - - memset(&axi_data, 0, sizeof(axi_data)); - - if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - switch(cfgcmd.cmd_type) { - case CMD_STATS_ENABLE: - axi_data.bufnum1 = - msm_pmem_region_lookup(&sync->stats, - MSM_PMEM_AEC_AWB, ®ion[0], - NUM_WB_EXP_STAT_OUTPUT_BUFFERS); - if (!axi_data.bufnum1) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - axi_data.region = ®ion[0]; - data = &axi_data; - break; - case CMD_STATS_AF_ENABLE: - axi_data.bufnum1 = - msm_pmem_region_lookup(&sync->stats, - MSM_PMEM_AF, ®ion[0], - NUM_AF_STAT_OUTPUT_BUFFERS); - if (!axi_data.bufnum1) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - axi_data.region = ®ion[0]; - data = &axi_data; - break; - case CMD_GENERAL: - case CMD_STATS_DISABLE: - break; - default: - pr_err("%s: unknown command type %d\n", - __FUNCTION__, cfgcmd.cmd_type); - return -EINVAL; - } - - - if (sync->vfefn.vfe_config) - rc = sync->vfefn.vfe_config(&cfgcmd, data); - - return rc; -} - -static int msm_frame_axi_cfg(struct msm_sync *sync, - struct msm_vfe_cfg_cmd *cfgcmd) -{ - int rc = -EIO; - struct axidata axi_data; - void *data = &axi_data; - struct msm_pmem_region region[8]; - int pmem_type; - - memset(&axi_data, 0, sizeof(axi_data)); - - switch (cfgcmd->cmd_type) { - case CMD_AXI_CFG_OUT1: - pmem_type = MSM_PMEM_OUTPUT1; - axi_data.bufnum1 = - msm_pmem_region_lookup(&sync->frame, pmem_type, - ®ion[0], 8); - if (!axi_data.bufnum1) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - break; - - case CMD_AXI_CFG_OUT2: - pmem_type = MSM_PMEM_OUTPUT2; - axi_data.bufnum2 = - msm_pmem_region_lookup(&sync->frame, pmem_type, - ®ion[0], 8); - if (!axi_data.bufnum2) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - break; - - case CMD_AXI_CFG_SNAP_O1_AND_O2: - pmem_type = MSM_PMEM_THUMBAIL; - axi_data.bufnum1 = - msm_pmem_region_lookup(&sync->frame, pmem_type, - ®ion[0], 8); - if (!axi_data.bufnum1) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - - pmem_type = MSM_PMEM_MAINIMG; - axi_data.bufnum2 = - msm_pmem_region_lookup(&sync->frame, pmem_type, - ®ion[axi_data.bufnum1], 8); - if (!axi_data.bufnum2) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - break; - - case CMD_RAW_PICT_AXI_CFG: - pmem_type = MSM_PMEM_RAW_MAINIMG; - axi_data.bufnum2 = - msm_pmem_region_lookup(&sync->frame, pmem_type, - ®ion[0], 8); - if (!axi_data.bufnum2) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - break; - - case CMD_GENERAL: - data = NULL; - break; - - default: - pr_err("%s: unknown command type %d\n", - __FUNCTION__, cfgcmd->cmd_type); - return -EINVAL; - } - - axi_data.region = ®ion[0]; - - /* send the AXI configuration command to driver */ - if (sync->vfefn.vfe_config) - rc = sync->vfefn.vfe_config(cfgcmd, data); - - return rc; -} - -static int msm_get_sensor_info(struct msm_sync *sync, void __user *arg) -{ - int rc = 0; - struct msm_camsensor_info info; - struct msm_camera_sensor_info *sdata; - - if (copy_from_user(&info, - arg, - sizeof(struct msm_camsensor_info))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - sdata = sync->pdev->dev.platform_data; - CDBG("sensor_name %s\n", sdata->sensor_name); - - memcpy(&info.name[0], - sdata->sensor_name, - MAX_SENSOR_NAME); - info.flash_enabled = sdata->flash_type != MSM_CAMERA_FLASH_NONE; - - /* copy back to user space */ - if (copy_to_user((void *)arg, - &info, - sizeof(struct msm_camsensor_info))) { - ERR_COPY_TO_USER(); - rc = -EFAULT; - } - - return rc; -} - -static int __msm_put_frame_buf(struct msm_sync *sync, - struct msm_frame *pb) -{ - unsigned long pphy; - struct msm_vfe_cfg_cmd cfgcmd; - - int rc = -EIO; - - pphy = msm_pmem_frame_vtop_lookup(sync, - pb->buffer, - pb->y_off, pb->cbcr_off, pb->fd); - - if (pphy != 0) { - CDBG("rel: vaddr = 0x%lx, paddr = 0x%lx\n", - pb->buffer, pphy); - cfgcmd.cmd_type = CMD_FRAME_BUF_RELEASE; - cfgcmd.value = (void *)pb; - if (sync->vfefn.vfe_config) - rc = sync->vfefn.vfe_config(&cfgcmd, &pphy); - } else { - pr_err("%s: msm_pmem_frame_vtop_lookup failed\n", - __FUNCTION__); - rc = -EINVAL; - } - - return rc; -} - -static int msm_put_frame_buffer(struct msm_sync *sync, void __user *arg) -{ - struct msm_frame buf_t; - - if (copy_from_user(&buf_t, - arg, - sizeof(struct msm_frame))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - return __msm_put_frame_buf(sync, &buf_t); -} - -static int __msm_register_pmem(struct msm_sync *sync, - struct msm_pmem_info *pinfo) -{ - int rc = 0; - - switch (pinfo->type) { - case MSM_PMEM_OUTPUT1: - case MSM_PMEM_OUTPUT2: - case MSM_PMEM_THUMBAIL: - case MSM_PMEM_MAINIMG: - case MSM_PMEM_RAW_MAINIMG: - rc = msm_pmem_table_add(&sync->frame, pinfo); - break; - - case MSM_PMEM_AEC_AWB: - case MSM_PMEM_AF: - rc = msm_pmem_table_add(&sync->stats, pinfo); - break; - - default: - rc = -EINVAL; - break; - } - - return rc; -} - -static int msm_register_pmem(struct msm_sync *sync, void __user *arg) -{ - struct msm_pmem_info info; - - if (copy_from_user(&info, arg, sizeof(info))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - return __msm_register_pmem(sync, &info); -} - -static int msm_stats_axi_cfg(struct msm_sync *sync, - struct msm_vfe_cfg_cmd *cfgcmd) -{ - int rc = -EIO; - struct axidata axi_data; - void *data = &axi_data; - - struct msm_pmem_region region[3]; - int pmem_type = MSM_PMEM_MAX; - - memset(&axi_data, 0, sizeof(axi_data)); - - switch (cfgcmd->cmd_type) { - case CMD_STATS_AXI_CFG: - pmem_type = MSM_PMEM_AEC_AWB; - break; - case CMD_STATS_AF_AXI_CFG: - pmem_type = MSM_PMEM_AF; - break; - case CMD_GENERAL: - data = NULL; - break; - default: - pr_err("%s: unknown command type %d\n", - __FUNCTION__, cfgcmd->cmd_type); - return -EINVAL; - } - - if (cfgcmd->cmd_type != CMD_GENERAL) { - axi_data.bufnum1 = - msm_pmem_region_lookup(&sync->stats, pmem_type, - ®ion[0], NUM_WB_EXP_STAT_OUTPUT_BUFFERS); - if (!axi_data.bufnum1) { - pr_err("%s: pmem region lookup error\n", __FUNCTION__); - return -EINVAL; - } - axi_data.region = ®ion[0]; - } - - /* send the AEC/AWB STATS configuration command to driver */ - if (sync->vfefn.vfe_config) - rc = sync->vfefn.vfe_config(cfgcmd, &axi_data); - - return rc; -} - -static int msm_put_stats_buffer(struct msm_sync *sync, void __user *arg) -{ - int rc = -EIO; - - struct msm_stats_buf buf; - unsigned long pphy; - struct msm_vfe_cfg_cmd cfgcmd; - - if (copy_from_user(&buf, arg, - sizeof(struct msm_stats_buf))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - CDBG("msm_put_stats_buffer\n"); - pphy = msm_pmem_stats_vtop_lookup(sync, buf.buffer, buf.fd); - - if (pphy != 0) { - if (buf.type == STAT_AEAW) - cfgcmd.cmd_type = CMD_STATS_BUF_RELEASE; - else if (buf.type == STAT_AF) - cfgcmd.cmd_type = CMD_STATS_AF_BUF_RELEASE; - else { - pr_err("%s: invalid buf type %d\n", - __FUNCTION__, - buf.type); - rc = -EINVAL; - goto put_done; - } - - cfgcmd.value = (void *)&buf; - - if (sync->vfefn.vfe_config) { - rc = sync->vfefn.vfe_config(&cfgcmd, &pphy); - if (rc < 0) - pr_err("msm_put_stats_buffer: "\ - "vfe_config err %d\n", rc); - } else - pr_err("msm_put_stats_buffer: vfe_config is NULL\n"); - } else { - pr_err("msm_put_stats_buffer: NULL physical address\n"); - rc = -EINVAL; - } - -put_done: - return rc; -} - -static int msm_axi_config(struct msm_sync *sync, void __user *arg) -{ - struct msm_vfe_cfg_cmd cfgcmd; - - if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - switch (cfgcmd.cmd_type) { - case CMD_AXI_CFG_OUT1: - case CMD_AXI_CFG_OUT2: - case CMD_AXI_CFG_SNAP_O1_AND_O2: - case CMD_RAW_PICT_AXI_CFG: - return msm_frame_axi_cfg(sync, &cfgcmd); - - case CMD_STATS_AXI_CFG: - case CMD_STATS_AF_AXI_CFG: - return msm_stats_axi_cfg(sync, &cfgcmd); - - default: - pr_err("%s: unknown command type %d\n", - __FUNCTION__, - cfgcmd.cmd_type); - return -EINVAL; - } - - return 0; -} - -static int __msm_get_pic(struct msm_sync *sync, struct msm_ctrl_cmd *ctrl) -{ - unsigned long flags; - int rc = 0; - int tm; - - struct msm_queue_cmd *qcmd = NULL; - - tm = (int)ctrl->timeout_ms; - - rc = wait_event_interruptible_timeout( - sync->pict_frame_wait, - !list_empty_careful(&sync->pict_frame_q), - msecs_to_jiffies(tm)); - if (list_empty_careful(&sync->pict_frame_q)) { - if (rc == 0) - return -ETIMEDOUT; - if (rc < 0) { - pr_err("msm_camera_get_picture, rc = %d\n", rc); - return rc; - } - } - - spin_lock_irqsave(&sync->pict_frame_q_lock, flags); - BUG_ON(list_empty(&sync->pict_frame_q)); - qcmd = list_first_entry(&sync->pict_frame_q, - struct msm_queue_cmd, list); - list_del_init(&qcmd->list); - spin_unlock_irqrestore(&sync->pict_frame_q_lock, flags); - - if (qcmd->command != NULL) { - struct msm_ctrl_cmd *q = - (struct msm_ctrl_cmd *)qcmd->command; - ctrl->type = q->type; - ctrl->status = q->status; - } else { - ctrl->type = -1; - ctrl->status = -1; - } - - kfree(qcmd); - return rc; -} - -static int msm_get_pic(struct msm_sync *sync, void __user *arg) -{ - struct msm_ctrl_cmd ctrlcmd_t; - int rc; - - if (copy_from_user(&ctrlcmd_t, - arg, - sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - rc = __msm_get_pic(sync, &ctrlcmd_t); - if (rc < 0) - return rc; - - if (sync->croplen) { - if (ctrlcmd_t.length < sync->croplen) { - pr_err("msm_get_pic: invalid len %d\n", - ctrlcmd_t.length); - return -EINVAL; - } - if (copy_to_user(ctrlcmd_t.value, - sync->cropinfo, - sync->croplen)) { - ERR_COPY_TO_USER(); - return -EFAULT; - } - } - - if (copy_to_user((void *)arg, - &ctrlcmd_t, - sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_TO_USER(); - return -EFAULT; - } - return 0; -} - -static int msm_set_crop(struct msm_sync *sync, void __user *arg) -{ - struct crop_info crop; - - if (copy_from_user(&crop, - arg, - sizeof(struct crop_info))) { - ERR_COPY_FROM_USER(); - return -EFAULT; - } - - if (!sync->croplen) { - sync->cropinfo = kmalloc(crop.len, GFP_KERNEL); - if (!sync->cropinfo) - return -ENOMEM; - } else if (sync->croplen < crop.len) - return -EINVAL; - - if (copy_from_user(sync->cropinfo, - crop.info, - crop.len)) { - ERR_COPY_FROM_USER(); - kfree(sync->cropinfo); - return -EFAULT; - } - - sync->croplen = crop.len; - - return 0; -} - -static int msm_pict_pp_done(struct msm_sync *sync, void __user *arg) -{ - struct msm_ctrl_cmd udata; - struct msm_ctrl_cmd *ctrlcmd = NULL; - struct msm_queue_cmd *qcmd = NULL; - unsigned long flags; - int rc = 0; - - if (!sync->pict_pp) - return -EINVAL; - - if (copy_from_user(&udata, arg, sizeof(struct msm_ctrl_cmd))) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - goto pp_fail; - } - - qcmd = kmalloc(sizeof(struct msm_queue_cmd) + - sizeof(struct msm_ctrl_cmd), - GFP_KERNEL); - if (!qcmd) { - rc = -ENOMEM; - goto pp_fail; - } - - qcmd->type = MSM_CAM_Q_VFE_MSG; - qcmd->command = ctrlcmd = (struct msm_ctrl_cmd *)(qcmd + 1); - memset(ctrlcmd, 0, sizeof(struct msm_ctrl_cmd)); - ctrlcmd->type = udata.type; - ctrlcmd->status = udata.status; - - spin_lock_irqsave(&sync->pict_frame_q_lock, flags); - list_add_tail(&qcmd->list, &sync->pict_frame_q); - spin_unlock_irqrestore(&sync->pict_frame_q_lock, flags); - wake_up(&sync->pict_frame_wait); - -pp_fail: - return rc; -} - -static long msm_ioctl_common(struct msm_device *pmsm, - unsigned int cmd, - void __user *argp) -{ - CDBG("msm_ioctl_common\n"); - switch (cmd) { - case MSM_CAM_IOCTL_REGISTER_PMEM: - return msm_register_pmem(pmsm->sync, argp); - case MSM_CAM_IOCTL_UNREGISTER_PMEM: - return msm_pmem_table_del(pmsm->sync, argp); - default: - return -EINVAL; - } -} - -static long msm_ioctl_config(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - int rc = -EINVAL; - void __user *argp = (void __user *)arg; - struct msm_device *pmsm = filep->private_data; - - CDBG("msm_ioctl_config cmd = %d\n", _IOC_NR(cmd)); - - switch (cmd) { - case MSM_CAM_IOCTL_GET_SENSOR_INFO: - rc = msm_get_sensor_info(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_CONFIG_VFE: - /* Coming from config thread for update */ - rc = msm_config_vfe(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_GET_STATS: - /* Coming from config thread wait - * for vfe statistics and control requests */ - rc = msm_get_stats(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_ENABLE_VFE: - /* This request comes from control thread: - * enable either QCAMTASK or VFETASK */ - rc = msm_enable_vfe(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_DISABLE_VFE: - /* This request comes from control thread: - * disable either QCAMTASK or VFETASK */ - rc = msm_disable_vfe(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_VFE_APPS_RESET: - msm_camio_vfe_blk_reset(); - rc = 0; - break; - - case MSM_CAM_IOCTL_RELEASE_STATS_BUFFER: - rc = msm_put_stats_buffer(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_AXI_CONFIG: - rc = msm_axi_config(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_SET_CROP: - rc = msm_set_crop(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_PICT_PP: { - uint8_t enable; - if (copy_from_user(&enable, argp, sizeof(enable))) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - } else { - pmsm->sync->pict_pp = enable; - rc = 0; - } - break; - } - - case MSM_CAM_IOCTL_PICT_PP_DONE: - rc = msm_pict_pp_done(pmsm->sync, argp); - break; - - case MSM_CAM_IOCTL_SENSOR_IO_CFG: - rc = pmsm->sync->sctrl.s_config(argp); - break; - - case MSM_CAM_IOCTL_FLASH_LED_CFG: { - uint32_t led_state; - if (copy_from_user(&led_state, argp, sizeof(led_state))) { - ERR_COPY_FROM_USER(); - rc = -EFAULT; - } else - rc = msm_camera_flash_set_led_state(led_state); - break; - } - - default: - rc = msm_ioctl_common(pmsm, cmd, argp); - break; - } - - CDBG("msm_ioctl_config cmd = %d DONE\n", _IOC_NR(cmd)); - return rc; -} - -static int msm_unblock_poll_frame(struct msm_sync *); - -static long msm_ioctl_frame(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - int rc = -EINVAL; - void __user *argp = (void __user *)arg; - struct msm_device *pmsm = filep->private_data; - - - switch (cmd) { - case MSM_CAM_IOCTL_GETFRAME: - /* Coming from frame thread to get frame - * after SELECT is done */ - rc = msm_get_frame(pmsm->sync, argp); - break; - case MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER: - rc = msm_put_frame_buffer(pmsm->sync, argp); - break; - case MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME: - rc = msm_unblock_poll_frame(pmsm->sync); - break; - default: - break; - } - - return rc; -} - - -static long msm_ioctl_control(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - int rc = -EINVAL; - void __user *argp = (void __user *)arg; - struct msm_control_device *ctrl_pmsm = filep->private_data; - struct msm_device *pmsm = ctrl_pmsm->pmsm; - - switch (cmd) { - case MSM_CAM_IOCTL_CTRL_COMMAND: - /* Coming from control thread, may need to wait for - * command status */ - rc = msm_control(ctrl_pmsm, 1, argp); - break; - case MSM_CAM_IOCTL_CTRL_COMMAND_2: - /* Sends a message, returns immediately */ - rc = msm_control(ctrl_pmsm, 0, argp); - break; - case MSM_CAM_IOCTL_CTRL_CMD_DONE: - /* Config thread calls the control thread to notify it - * of the result of a MSM_CAM_IOCTL_CTRL_COMMAND. - */ - rc = msm_ctrl_cmd_done(ctrl_pmsm, argp); - break; - case MSM_CAM_IOCTL_GET_PICTURE: - rc = msm_get_pic(pmsm->sync, argp); - break; - default: - rc = msm_ioctl_common(pmsm, cmd, argp); - break; - } - - return rc; -} - -static int __msm_release(struct msm_sync *sync) -{ - struct msm_pmem_region *region; - struct hlist_node *hnode; - struct hlist_node *n; - - mutex_lock(&sync->lock); - if (sync->opencnt) - sync->opencnt--; - - if (!sync->opencnt) { - /* need to clean up system resource */ - if (sync->vfefn.vfe_release) - sync->vfefn.vfe_release(sync->pdev); - - if (sync->cropinfo) { - kfree(sync->cropinfo); - sync->cropinfo = NULL; - sync->croplen = 0; - } - - hlist_for_each_entry_safe(region, hnode, n, - &sync->frame, list) { - hlist_del(hnode); - put_pmem_file(region->file); - kfree(region); - } - - hlist_for_each_entry_safe(region, hnode, n, - &sync->stats, list) { - hlist_del(hnode); - put_pmem_file(region->file); - kfree(region); - } - - MSM_DRAIN_QUEUE(sync, msg_event_q); - MSM_DRAIN_QUEUE(sync, prev_frame_q); - MSM_DRAIN_QUEUE(sync, pict_frame_q); - - sync->sctrl.s_release(); - wake_unlock(&sync->wake_lock); - - sync->apps_id = NULL; - CDBG("msm_release completed!\n"); - } - mutex_unlock(&sync->lock); - - return 0; -} - -static int msm_release_config(struct inode *node, struct file *filep) -{ - int rc; - struct msm_device *pmsm = filep->private_data; - printk("msm_camera: RELEASE %s\n", filep->f_path.dentry->d_name.name); - rc = __msm_release(pmsm->sync); - atomic_set(&pmsm->opened, 0); - return rc; -} - -static int msm_release_control(struct inode *node, struct file *filep) -{ - int rc; - struct msm_control_device *ctrl_pmsm = filep->private_data; - struct msm_device *pmsm = ctrl_pmsm->pmsm; - printk("msm_camera: RELEASE %s\n", filep->f_path.dentry->d_name.name); - rc = __msm_release(pmsm->sync); - if (!rc) { - MSM_DRAIN_QUEUE(&ctrl_pmsm->ctrl_q, ctrl_status_q); - MSM_DRAIN_QUEUE(pmsm->sync, pict_frame_q); - } - kfree(ctrl_pmsm); - return rc; -} - -static int msm_release_frame(struct inode *node, struct file *filep) -{ - int rc; - struct msm_device *pmsm = filep->private_data; - printk("msm_camera: RELEASE %s\n", filep->f_path.dentry->d_name.name); - rc = __msm_release(pmsm->sync); - if (!rc) { - MSM_DRAIN_QUEUE(pmsm->sync, prev_frame_q); - atomic_set(&pmsm->opened, 0); - } - return rc; -} - -static int msm_unblock_poll_frame(struct msm_sync *sync) -{ - unsigned long flags; - CDBG("msm_unblock_poll_frame\n"); - spin_lock_irqsave(&sync->prev_frame_q_lock, flags); - sync->unblock_poll_frame = 1; - wake_up(&sync->prev_frame_wait); - spin_unlock_irqrestore(&sync->prev_frame_q_lock, flags); - return 0; -} - -static unsigned int __msm_poll_frame(struct msm_sync *sync, - struct file *filep, - struct poll_table_struct *pll_table) -{ - int rc = 0; - unsigned long flags; - - poll_wait(filep, &sync->prev_frame_wait, pll_table); - - spin_lock_irqsave(&sync->prev_frame_q_lock, flags); - if (!list_empty_careful(&sync->prev_frame_q)) - /* frame ready */ - rc = POLLIN | POLLRDNORM; - if (sync->unblock_poll_frame) { - CDBG("%s: sync->unblock_poll_frame is true\n", __func__); - rc |= POLLPRI; - sync->unblock_poll_frame = 0; - } - spin_unlock_irqrestore(&sync->prev_frame_q_lock, flags); - - return rc; -} - -static unsigned int msm_poll_frame(struct file *filep, - struct poll_table_struct *pll_table) -{ - struct msm_device *pmsm = filep->private_data; - return __msm_poll_frame(pmsm->sync, filep, pll_table); -} - -/* - * This function executes in interrupt context. - */ - -static void *msm_vfe_sync_alloc(int size, - void *syncdata __attribute__((unused))) -{ - struct msm_queue_cmd *qcmd = - kmalloc(sizeof(struct msm_queue_cmd) + size, GFP_ATOMIC); - return qcmd ? qcmd + 1 : NULL; -} - -/* - * This function executes in interrupt context. - */ - -static void msm_vfe_sync(struct msm_vfe_resp *vdata, - enum msm_queue qtype, void *syncdata) -{ - struct msm_queue_cmd *qcmd = NULL; - struct msm_queue_cmd *qcmd_frame = NULL; - struct msm_vfe_phy_info *fphy; - - unsigned long flags; - struct msm_sync *sync = (struct msm_sync *)syncdata; - if (!sync) { - pr_err("msm_camera: no context in dsp callback.\n"); - return; - } - - qcmd = ((struct msm_queue_cmd *)vdata) - 1; - qcmd->type = qtype; - - if (qtype == MSM_CAM_Q_VFE_MSG) { - switch(vdata->type) { - case VFE_MSG_OUTPUT1: - case VFE_MSG_OUTPUT2: - qcmd_frame = - kmalloc(sizeof(struct msm_queue_cmd) + - sizeof(struct msm_vfe_phy_info), - GFP_ATOMIC); - if (!qcmd_frame) - goto mem_fail; - fphy = (struct msm_vfe_phy_info *)(qcmd_frame + 1); - *fphy = vdata->phy; - - qcmd_frame->type = MSM_CAM_Q_VFE_MSG; - qcmd_frame->command = fphy; - - CDBG("qcmd_frame= 0x%x phy_y= 0x%x, phy_cbcr= 0x%x\n", - (int) qcmd_frame, fphy->y_phy, fphy->cbcr_phy); - - spin_lock_irqsave(&sync->prev_frame_q_lock, flags); - list_add_tail(&qcmd_frame->list, &sync->prev_frame_q); - wake_up(&sync->prev_frame_wait); - spin_unlock_irqrestore(&sync->prev_frame_q_lock, flags); - CDBG("woke up frame thread\n"); - break; - case VFE_MSG_SNAPSHOT: - if (sync->pict_pp) - break; - - CDBG("snapshot pp = %d\n", sync->pict_pp); - qcmd_frame = - kmalloc(sizeof(struct msm_queue_cmd), - GFP_ATOMIC); - if (!qcmd_frame) - goto mem_fail; - qcmd_frame->type = MSM_CAM_Q_VFE_MSG; - qcmd_frame->command = NULL; - spin_lock_irqsave(&sync->pict_frame_q_lock, - flags); - list_add_tail(&qcmd_frame->list, &sync->pict_frame_q); - wake_up(&sync->pict_frame_wait); - spin_unlock_irqrestore(&sync->pict_frame_q_lock, flags); - CDBG("woke up picture thread\n"); - break; - default: - CDBG("%s: qtype = %d not handled\n", - __func__, vdata->type); - break; - } - } - - qcmd->command = (void *)vdata; - CDBG("vdata->type = %d\n", vdata->type); - - spin_lock_irqsave(&sync->msg_event_q_lock, flags); - list_add_tail(&qcmd->list, &sync->msg_event_q); - wake_up(&sync->msg_event_wait); - spin_unlock_irqrestore(&sync->msg_event_q_lock, flags); - CDBG("woke up config thread\n"); - return; - -mem_fail: - kfree(qcmd); -} - -static struct msm_vfe_callback msm_vfe_s = { - .vfe_resp = msm_vfe_sync, - .vfe_alloc = msm_vfe_sync_alloc, -}; - -static int __msm_open(struct msm_sync *sync, const char *const apps_id) -{ - int rc = 0; - - mutex_lock(&sync->lock); - if (sync->apps_id && strcmp(sync->apps_id, apps_id)) { - pr_err("msm_camera(%s): sensor %s is already opened for %s\n", - apps_id, - sync->sdata->sensor_name, - sync->apps_id); - rc = -EBUSY; - goto msm_open_done; - } - - sync->apps_id = apps_id; - - if (!sync->opencnt) { - wake_lock(&sync->wake_lock); - - msm_camvfe_fn_init(&sync->vfefn, sync); - if (sync->vfefn.vfe_init) { - rc = sync->vfefn.vfe_init(&msm_vfe_s, - sync->pdev); - if (rc < 0) { - pr_err("vfe_init failed at %d\n", rc); - goto msm_open_done; - } - rc = sync->sctrl.s_init(sync->sdata); - if (rc < 0) { - pr_err("sensor init failed: %d\n", rc); - goto msm_open_done; - } - } else { - pr_err("no sensor init func\n"); - rc = -ENODEV; - goto msm_open_done; - } - - if (rc >= 0) { - INIT_HLIST_HEAD(&sync->frame); - INIT_HLIST_HEAD(&sync->stats); - sync->unblock_poll_frame = 0; - } - } - sync->opencnt++; - -msm_open_done: - mutex_unlock(&sync->lock); - return rc; -} - -static int msm_open_common(struct inode *inode, struct file *filep, - int once) -{ - int rc; - struct msm_device *pmsm = - container_of(inode->i_cdev, struct msm_device, cdev); - - CDBG("msm_camera: open %s\n", filep->f_path.dentry->d_name.name); - - if (atomic_cmpxchg(&pmsm->opened, 0, 1) && once) { - pr_err("msm_camera: %s is already opened.\n", - filep->f_path.dentry->d_name.name); - return -EBUSY; - } - - rc = nonseekable_open(inode, filep); - if (rc < 0) { - pr_err("msm_open: nonseekable_open error %d\n", rc); - return rc; - } - - rc = __msm_open(pmsm->sync, MSM_APPS_ID_PROP); - if (rc < 0) - return rc; - - filep->private_data = pmsm; - - CDBG("msm_open() open: rc = %d\n", rc); - return rc; -} - -static int msm_open(struct inode *inode, struct file *filep) -{ - return msm_open_common(inode, filep, 1); -} - -static int msm_open_control(struct inode *inode, struct file *filep) -{ - int rc; - - struct msm_control_device *ctrl_pmsm = - kmalloc(sizeof(struct msm_control_device), GFP_KERNEL); - if (!ctrl_pmsm) - return -ENOMEM; - - rc = msm_open_common(inode, filep, 0); - if (rc < 0) - return rc; - - ctrl_pmsm->pmsm = filep->private_data; - filep->private_data = ctrl_pmsm; - spin_lock_init(&ctrl_pmsm->ctrl_q.ctrl_status_q_lock); - INIT_LIST_HEAD(&ctrl_pmsm->ctrl_q.ctrl_status_q); - init_waitqueue_head(&ctrl_pmsm->ctrl_q.ctrl_status_wait); - - CDBG("msm_open() open: rc = %d\n", rc); - return rc; -} - -static int __msm_v4l2_control(struct msm_sync *sync, - struct msm_ctrl_cmd *out) -{ - int rc = 0; - - struct msm_queue_cmd *qcmd = NULL, *rcmd = NULL; - struct msm_ctrl_cmd *ctrl; - struct msm_control_device_queue FIXME; - - /* wake up config thread, 4 is for V4L2 application */ - qcmd = kmalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL); - if (!qcmd) { - pr_err("msm_control: cannot allocate buffer\n"); - rc = -ENOMEM; - goto end; - } - qcmd->type = MSM_CAM_Q_V4L2_REQ; - qcmd->command = out; - - rcmd = __msm_control(sync, &FIXME, qcmd, out->timeout_ms); - if (IS_ERR(rcmd)) { - rc = PTR_ERR(rcmd); - goto end; - } - - ctrl = (struct msm_ctrl_cmd *)(rcmd->command); - /* FIXME: we should just set out->length = ctrl->length; */ - BUG_ON(out->length < ctrl->length); - memcpy(out->value, ctrl->value, ctrl->length); - -end: - if (rcmd) kfree(rcmd); - CDBG("__msm_v4l2_control: end rc = %d\n", rc); - return rc; -} - -static const struct file_operations msm_fops_config = { - .owner = THIS_MODULE, - .open = msm_open, - .unlocked_ioctl = msm_ioctl_config, - .release = msm_release_config, -}; - -static const struct file_operations msm_fops_control = { - .owner = THIS_MODULE, - .open = msm_open_control, - .unlocked_ioctl = msm_ioctl_control, - .release = msm_release_control, -}; - -static const struct file_operations msm_fops_frame = { - .owner = THIS_MODULE, - .open = msm_open, - .unlocked_ioctl = msm_ioctl_frame, - .release = msm_release_frame, - .poll = msm_poll_frame, -}; - -static int msm_setup_cdev(struct msm_device *msm, - int node, - dev_t devno, - const char *suffix, - const struct file_operations *fops) -{ - int rc = -ENODEV; - - struct device *device = - device_create(msm_class, NULL, - devno, NULL, - "%s%d", suffix, node); - - if (IS_ERR(device)) { - rc = PTR_ERR(device); - pr_err("msm_camera: error creating device: %d\n", rc); - return rc; - } - - cdev_init(&msm->cdev, fops); - msm->cdev.owner = THIS_MODULE; - - rc = cdev_add(&msm->cdev, devno, 1); - if (rc < 0) { - pr_err("msm_camera: error adding cdev: %d\n", rc); - device_destroy(msm_class, devno); - return rc; - } - - return rc; -} - -static int msm_tear_down_cdev(struct msm_device *msm, dev_t devno) -{ - cdev_del(&msm->cdev); - device_destroy(msm_class, devno); - return 0; -} - -int msm_v4l2_register(struct msm_v4l2_driver *drv) -{ - /* FIXME: support multiple sensors */ - if (list_empty(&msm_sensors)) - return -ENODEV; - - drv->sync = list_first_entry(&msm_sensors, struct msm_sync, list); - drv->open = __msm_open; - drv->release = __msm_release; - drv->ctrl = __msm_v4l2_control; - drv->reg_pmem = __msm_register_pmem; - drv->get_frame = __msm_get_frame; - drv->put_frame = __msm_put_frame_buf; - drv->get_pict = __msm_get_pic; - drv->drv_poll = __msm_poll_frame; - - return 0; -} -EXPORT_SYMBOL(msm_v4l2_register); - -int msm_v4l2_unregister(struct msm_v4l2_driver *drv) -{ - drv->sync = NULL; - return 0; -} -EXPORT_SYMBOL(msm_v4l2_unregister); - -static int msm_sync_init(struct msm_sync *sync, - struct platform_device *pdev, - int (*sensor_probe)(const struct msm_camera_sensor_info *, - struct msm_sensor_ctrl *)) -{ - int rc = 0; - struct msm_sensor_ctrl sctrl; - sync->sdata = pdev->dev.platform_data; - - spin_lock_init(&sync->msg_event_q_lock); - INIT_LIST_HEAD(&sync->msg_event_q); - init_waitqueue_head(&sync->msg_event_wait); - - spin_lock_init(&sync->prev_frame_q_lock); - INIT_LIST_HEAD(&sync->prev_frame_q); - init_waitqueue_head(&sync->prev_frame_wait); - - spin_lock_init(&sync->pict_frame_q_lock); - INIT_LIST_HEAD(&sync->pict_frame_q); - init_waitqueue_head(&sync->pict_frame_wait); - - wake_lock_init(&sync->wake_lock, WAKE_LOCK_IDLE, "msm_camera"); - - rc = msm_camio_probe_on(pdev); - if (rc < 0) - return rc; - rc = sensor_probe(sync->sdata, &sctrl); - if (rc >= 0) { - sync->pdev = pdev; - sync->sctrl = sctrl; - } - msm_camio_probe_off(pdev); - if (rc < 0) { - pr_err("msm_camera: failed to initialize %s\n", - sync->sdata->sensor_name); - wake_lock_destroy(&sync->wake_lock); - return rc; - } - - sync->opencnt = 0; - mutex_init(&sync->lock); - CDBG("initialized %s\n", sync->sdata->sensor_name); - return rc; -} - -static int msm_sync_destroy(struct msm_sync *sync) -{ - wake_lock_destroy(&sync->wake_lock); - return 0; -} - -static int msm_device_init(struct msm_device *pmsm, - struct msm_sync *sync, - int node) -{ - int dev_num = 3 * node; - int rc = msm_setup_cdev(pmsm, node, - MKDEV(MAJOR(msm_devno), dev_num), - "control", &msm_fops_control); - if (rc < 0) { - pr_err("error creating control node: %d\n", rc); - return rc; - } - - rc = msm_setup_cdev(pmsm + 1, node, - MKDEV(MAJOR(msm_devno), dev_num + 1), - "config", &msm_fops_config); - if (rc < 0) { - pr_err("error creating config node: %d\n", rc); - msm_tear_down_cdev(pmsm, MKDEV(MAJOR(msm_devno), - dev_num)); - return rc; - } - - rc = msm_setup_cdev(pmsm + 2, node, - MKDEV(MAJOR(msm_devno), dev_num + 2), - "frame", &msm_fops_frame); - if (rc < 0) { - pr_err("error creating frame node: %d\n", rc); - msm_tear_down_cdev(pmsm, - MKDEV(MAJOR(msm_devno), dev_num)); - msm_tear_down_cdev(pmsm + 1, - MKDEV(MAJOR(msm_devno), dev_num + 1)); - return rc; - } - - atomic_set(&pmsm[0].opened, 0); - atomic_set(&pmsm[1].opened, 0); - atomic_set(&pmsm[2].opened, 0); - - pmsm[0].sync = sync; - pmsm[1].sync = sync; - pmsm[2].sync = sync; - - return rc; -} - -int msm_camera_drv_start(struct platform_device *dev, - int (*sensor_probe)(const struct msm_camera_sensor_info *, - struct msm_sensor_ctrl *)) -{ - struct msm_device *pmsm = NULL; - struct msm_sync *sync; - int rc = -ENODEV; - static int camera_node; - - if (camera_node >= MSM_MAX_CAMERA_SENSORS) { - pr_err("msm_camera: too many camera sensors\n"); - return rc; - } - - if (!msm_class) { - /* There are three device nodes per sensor */ - rc = alloc_chrdev_region(&msm_devno, 0, - 3 * MSM_MAX_CAMERA_SENSORS, - "msm_camera"); - if (rc < 0) { - pr_err("msm_camera: failed to allocate chrdev: %d\n", - rc); - return rc; - } - - msm_class = class_create(THIS_MODULE, "msm_camera"); - if (IS_ERR(msm_class)) { - rc = PTR_ERR(msm_class); - pr_err("msm_camera: create device class failed: %d\n", - rc); - return rc; - } - } - - pmsm = kzalloc(sizeof(struct msm_device) * 3 + - sizeof(struct msm_sync), GFP_ATOMIC); - if (!pmsm) - return -ENOMEM; - sync = (struct msm_sync *)(pmsm + 3); - - rc = msm_sync_init(sync, dev, sensor_probe); - if (rc < 0) { - kfree(pmsm); - return rc; - } - - CDBG("setting camera node %d\n", camera_node); - rc = msm_device_init(pmsm, sync, camera_node); - if (rc < 0) { - msm_sync_destroy(sync); - kfree(pmsm); - return rc; - } - - camera_node++; - list_add(&sync->list, &msm_sensors); - return rc; -} -EXPORT_SYMBOL(msm_camera_drv_start); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_io7x.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_io7x.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_io7x.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_io7x.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2008-2009 QUALCOMM Incorporated - */ - -#include -#include -#include -#include -#include -#include - -#define CAMIF_CFG_RMSK 0x1fffff -#define CAM_SEL_BMSK 0x2 -#define CAM_PCLK_SRC_SEL_BMSK 0x60000 -#define CAM_PCLK_INVERT_BMSK 0x80000 -#define CAM_PAD_REG_SW_RESET_BMSK 0x100000 - -#define EXT_CAM_HSYNC_POL_SEL_BMSK 0x10000 -#define EXT_CAM_VSYNC_POL_SEL_BMSK 0x8000 -#define MDDI_CLK_CHICKEN_BIT_BMSK 0x80 - -#define CAM_SEL_SHFT 0x1 -#define CAM_PCLK_SRC_SEL_SHFT 0x11 -#define CAM_PCLK_INVERT_SHFT 0x13 -#define CAM_PAD_REG_SW_RESET_SHFT 0x14 - -#define EXT_CAM_HSYNC_POL_SEL_SHFT 0x10 -#define EXT_CAM_VSYNC_POL_SEL_SHFT 0xF -#define MDDI_CLK_CHICKEN_BIT_SHFT 0x7 -#define APPS_RESET_OFFSET 0x00000210 - -static struct clk *camio_vfe_mdc_clk; -static struct clk *camio_mdc_clk; -static struct clk *camio_vfe_clk; - -static struct msm_camera_io_ext camio_ext; -static struct resource *appio, *mdcio; -void __iomem *appbase, *mdcbase; - -static struct msm_camera_io_ext camio_ext; -static struct resource *appio, *mdcio; -void __iomem *appbase, *mdcbase; - -extern int clk_set_flags(struct clk *clk, unsigned long flags); - -int msm_camio_clk_enable(enum msm_camio_clk_type clktype) -{ - int rc = -1; - struct clk *clk = NULL; - - switch (clktype) { - case CAMIO_VFE_MDC_CLK: - clk = camio_vfe_mdc_clk = clk_get(NULL, "vfe_mdc_clk"); - break; - - case CAMIO_MDC_CLK: - clk = camio_mdc_clk = clk_get(NULL, "mdc_clk"); - break; - - case CAMIO_VFE_CLK: - clk = camio_vfe_clk = clk_get(NULL, "vfe_clk"); - break; - - default: - break; - } - - if (!IS_ERR(clk)) { - clk_enable(clk); - rc = 0; - } - - return rc; -} - -int msm_camio_clk_disable(enum msm_camio_clk_type clktype) -{ - int rc = -1; - struct clk *clk = NULL; - - switch (clktype) { - case CAMIO_VFE_MDC_CLK: - clk = camio_vfe_mdc_clk; - break; - - case CAMIO_MDC_CLK: - clk = camio_mdc_clk; - break; - - case CAMIO_VFE_CLK: - clk = camio_vfe_clk; - break; - - default: - break; - } - - if (!IS_ERR(clk)) { - clk_disable(clk); - clk_put(clk); - rc = 0; - } - - return rc; -} - -void msm_camio_clk_rate_set(int rate) -{ - struct clk *clk = camio_vfe_clk; - - if (clk != ERR_PTR(-ENOENT)) - clk_set_rate(clk, rate); -} - -int msm_camio_enable(struct platform_device *pdev) -{ - int rc = 0; - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - camio_ext = camdev->ioext; - - appio = request_mem_region(camio_ext.appphy, - camio_ext.appsz, pdev->name); - if (!appio) { - rc = -EBUSY; - goto enable_fail; - } - - appbase = ioremap(camio_ext.appphy, - camio_ext.appsz); - if (!appbase) { - rc = -ENOMEM; - goto apps_no_mem; - } - - mdcio = request_mem_region(camio_ext.mdcphy, - camio_ext.mdcsz, pdev->name); - if (!mdcio) { - rc = -EBUSY; - goto mdc_busy; - } - - mdcbase = ioremap(camio_ext.mdcphy, - camio_ext.mdcsz); - if (!mdcbase) { - rc = -ENOMEM; - goto mdc_no_mem; - } - - camdev->camera_gpio_on(); - - msm_camio_clk_enable(CAMIO_VFE_CLK); - msm_camio_clk_enable(CAMIO_MDC_CLK); - msm_camio_clk_enable(CAMIO_VFE_MDC_CLK); - return 0; - -mdc_no_mem: - release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz); -mdc_busy: - iounmap(appbase); -apps_no_mem: - release_mem_region(camio_ext.appphy, camio_ext.appsz); -enable_fail: - return rc; -} - -void msm_camio_disable(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - iounmap(mdcbase); - release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz); - iounmap(appbase); - release_mem_region(camio_ext.appphy, camio_ext.appsz); - - camdev->camera_gpio_off(); - - msm_camio_clk_disable(CAMIO_VFE_CLK); - msm_camio_clk_disable(CAMIO_MDC_CLK); - msm_camio_clk_disable(CAMIO_VFE_MDC_CLK); -} - -void msm_camio_camif_pad_reg_reset(void) -{ - uint32_t reg; - uint32_t mask, value; - - /* select CLKRGM_VFE_SRC_CAM_VFE_SRC: internal source */ - msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - - mask = CAM_SEL_BMSK | - CAM_PCLK_SRC_SEL_BMSK | - CAM_PCLK_INVERT_BMSK; - - value = 1 << CAM_SEL_SHFT | - 3 << CAM_PCLK_SRC_SEL_SHFT | - 0 << CAM_PCLK_INVERT_SHFT; - - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 1 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 0 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_EXTERNAL); - mdelay(10); -} - -void msm_camio_vfe_blk_reset(void) -{ - uint32_t val; - - val = readl(appbase + 0x00000210); - val |= 0x1; - writel(val, appbase + 0x00000210); - mdelay(10); - - val = readl(appbase + 0x00000210); - val &= ~0x1; - writel(val, appbase + 0x00000210); - mdelay(10); -} - -void msm_camio_camif_pad_reg_reset_2(void) -{ - uint32_t reg; - uint32_t mask, value; - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 1 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 0 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); -} - -void msm_camio_clk_sel(enum msm_camio_clk_src_type srctype) -{ - struct clk *clk = NULL; - - clk = camio_vfe_clk; - - if (clk != NULL && clk != ERR_PTR(-ENOENT)) { - switch (srctype) { - case MSM_CAMIO_CLK_SRC_INTERNAL: - clk_set_flags(clk, 0x00000100 << 1); - break; - - case MSM_CAMIO_CLK_SRC_EXTERNAL: - clk_set_flags(clk, 0x00000100); - break; - - default: - break; - } - } -} - -int msm_camio_probe_on(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - camdev->camera_gpio_on(); - return msm_camio_clk_enable(CAMIO_VFE_CLK); -} - -int msm_camio_probe_off(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - camdev->camera_gpio_off(); - return msm_camio_clk_disable(CAMIO_VFE_CLK); -} diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_io8x.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_io8x.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_io8x.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_io8x.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,320 +0,0 @@ -/* - * Copyright (c) 2008-2009 QUALCOMM Incorporated - */ - -#include -#include -#include -#include -#include -#include - -#define CAMIF_CFG_RMSK 0x1fffff -#define CAM_SEL_BMSK 0x2 -#define CAM_PCLK_SRC_SEL_BMSK 0x60000 -#define CAM_PCLK_INVERT_BMSK 0x80000 -#define CAM_PAD_REG_SW_RESET_BMSK 0x100000 - -#define EXT_CAM_HSYNC_POL_SEL_BMSK 0x10000 -#define EXT_CAM_VSYNC_POL_SEL_BMSK 0x8000 -#define MDDI_CLK_CHICKEN_BIT_BMSK 0x80 - -#define CAM_SEL_SHFT 0x1 -#define CAM_PCLK_SRC_SEL_SHFT 0x11 -#define CAM_PCLK_INVERT_SHFT 0x13 -#define CAM_PAD_REG_SW_RESET_SHFT 0x14 - -#define EXT_CAM_HSYNC_POL_SEL_SHFT 0x10 -#define EXT_CAM_VSYNC_POL_SEL_SHFT 0xF -#define MDDI_CLK_CHICKEN_BIT_SHFT 0x7 -#define APPS_RESET_OFFSET 0x00000210 - -static struct clk *camio_vfe_mdc_clk; -static struct clk *camio_mdc_clk; -static struct clk *camio_vfe_clk; -static struct clk *camio_vfe_axi_clk; -static struct msm_camera_io_ext camio_ext; -static struct resource *appio, *mdcio; -void __iomem *appbase, *mdcbase; - -extern int clk_set_flags(struct clk *clk, unsigned long flags); - -int msm_camio_clk_enable(enum msm_camio_clk_type clktype) -{ - int rc = 0; - struct clk *clk = NULL; - - switch (clktype) { - case CAMIO_VFE_MDC_CLK: - camio_vfe_mdc_clk = - clk = clk_get(NULL, "vfe_mdc_clk"); - break; - - case CAMIO_MDC_CLK: - camio_mdc_clk = - clk = clk_get(NULL, "mdc_clk"); - break; - - case CAMIO_VFE_CLK: - camio_vfe_clk = - clk = clk_get(NULL, "vfe_clk"); - break; - - case CAMIO_VFE_AXI_CLK: - camio_vfe_axi_clk = - clk = clk_get(NULL, "vfe_axi_clk"); - break; - - default: - break; - } - - if (!IS_ERR(clk)) - clk_enable(clk); - else - rc = -1; - - return rc; -} - -int msm_camio_clk_disable(enum msm_camio_clk_type clktype) -{ - int rc = 0; - struct clk *clk = NULL; - - switch (clktype) { - case CAMIO_VFE_MDC_CLK: - clk = camio_vfe_mdc_clk; - break; - - case CAMIO_MDC_CLK: - clk = camio_mdc_clk; - break; - - case CAMIO_VFE_CLK: - clk = camio_vfe_clk; - break; - - case CAMIO_VFE_AXI_CLK: - clk = camio_vfe_axi_clk; - break; - - default: - break; - } - - if (!IS_ERR(clk)) { - clk_disable(clk); - clk_put(clk); - } else - rc = -1; - - return rc; -} - -void msm_camio_clk_rate_set(int rate) -{ - struct clk *clk = camio_vfe_mdc_clk; - - /* TODO: check return */ - clk_set_rate(clk, rate); -} - -int msm_camio_enable(struct platform_device *pdev) -{ - int rc = 0; - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - camio_ext = camdev->ioext; - - appio = request_mem_region(camio_ext.appphy, - camio_ext.appsz, pdev->name); - if (!appio) { - rc = -EBUSY; - goto enable_fail; - } - - appbase = ioremap(camio_ext.appphy, - camio_ext.appsz); - if (!appbase) { - rc = -ENOMEM; - goto apps_no_mem; - } - - mdcio = request_mem_region(camio_ext.mdcphy, - camio_ext.mdcsz, pdev->name); - if (!mdcio) { - rc = -EBUSY; - goto mdc_busy; - } - - mdcbase = ioremap(camio_ext.mdcphy, - camio_ext.mdcsz); - if (!mdcbase) { - rc = -ENOMEM; - goto mdc_no_mem; - } - - camdev->camera_gpio_on(); - - msm_camio_clk_enable(CAMIO_VFE_CLK); - msm_camio_clk_enable(CAMIO_MDC_CLK); - msm_camio_clk_enable(CAMIO_VFE_MDC_CLK); - msm_camio_clk_enable(CAMIO_VFE_AXI_CLK); - return 0; - -mdc_no_mem: - release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz); -mdc_busy: - iounmap(appbase); -apps_no_mem: - release_mem_region(camio_ext.appphy, camio_ext.appsz); -enable_fail: - return rc; -} - -void msm_camio_disable(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - iounmap(mdcbase); - release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz); - iounmap(appbase); - release_mem_region(camio_ext.appphy, camio_ext.appsz); - - camdev->camera_gpio_off(); - - msm_camio_clk_disable(CAMIO_VFE_MDC_CLK); - msm_camio_clk_disable(CAMIO_MDC_CLK); - msm_camio_clk_disable(CAMIO_VFE_CLK); - msm_camio_clk_disable(CAMIO_VFE_AXI_CLK); -} - -void msm_camio_camif_pad_reg_reset(void) -{ - uint32_t reg; - uint32_t mask, value; - - /* select CLKRGM_VFE_SRC_CAM_VFE_SRC: internal source */ - msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - - mask = CAM_SEL_BMSK | - CAM_PCLK_SRC_SEL_BMSK | - CAM_PCLK_INVERT_BMSK | - EXT_CAM_HSYNC_POL_SEL_BMSK | - EXT_CAM_VSYNC_POL_SEL_BMSK | - MDDI_CLK_CHICKEN_BIT_BMSK; - - value = 1 << CAM_SEL_SHFT | - 3 << CAM_PCLK_SRC_SEL_SHFT | - 0 << CAM_PCLK_INVERT_SHFT | - 0 << EXT_CAM_HSYNC_POL_SEL_SHFT | - 0 << EXT_CAM_VSYNC_POL_SEL_SHFT | - 0 << MDDI_CLK_CHICKEN_BIT_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 1 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 0 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_EXTERNAL); - - mdelay(10); - - /* todo: check return */ - if (camio_vfe_clk) - clk_set_rate(camio_vfe_clk, 96000000); -} - -void msm_camio_vfe_blk_reset(void) -{ - uint32_t val; - - val = readl(appbase + 0x00000210); - val |= 0x1; - writel(val, appbase + 0x00000210); - mdelay(10); - - val = readl(appbase + 0x00000210); - val &= ~0x1; - writel(val, appbase + 0x00000210); - mdelay(10); -} - -void msm_camio_camif_pad_reg_reset_2(void) -{ - uint32_t reg; - uint32_t mask, value; - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 1 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); - - reg = (readl(mdcbase)) & CAMIF_CFG_RMSK; - mask = CAM_PAD_REG_SW_RESET_BMSK; - value = 0 << CAM_PAD_REG_SW_RESET_SHFT; - writel((reg & (~mask)) | (value & mask), mdcbase); - mdelay(10); -} - -void msm_camio_clk_sel(enum msm_camio_clk_src_type srctype) -{ - struct clk *clk = NULL; - - clk = camio_vfe_clk; - - if (clk != NULL) { - switch (srctype) { - case MSM_CAMIO_CLK_SRC_INTERNAL: - clk_set_flags(clk, 0x00000100 << 1); - break; - - case MSM_CAMIO_CLK_SRC_EXTERNAL: - clk_set_flags(clk, 0x00000100); - break; - - default: - break; - } - } -} - -void msm_camio_clk_axi_rate_set(int rate) -{ - struct clk *clk = camio_vfe_axi_clk; - /* todo: check return */ - clk_set_rate(clk, rate); -} - -int msm_camio_probe_on(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - camdev->camera_gpio_on(); - return msm_camio_clk_enable(CAMIO_VFE_MDC_CLK); -} - -int msm_camio_probe_off(struct platform_device *pdev) -{ - struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; - struct msm_camera_device_platform_data *camdev = sinfo->pdata; - - camdev->camera_gpio_off(); - return msm_camio_clk_disable(CAMIO_VFE_MDC_CLK); -} diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_v4l2.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_v4l2.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_v4l2.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_v4l2.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,797 +0,0 @@ -/* - * - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/*#include */ - -#define MSM_V4L2_START_SNAPSHOT _IOWR('V', BASE_VIDIOC_PRIVATE+1, \ - struct v4l2_buffer) - -#define MSM_V4L2_GET_PICTURE _IOWR('V', BASE_VIDIOC_PRIVATE+2, \ - struct v4l2_buffer) - -#define MSM_V4L2_DEVICE_NAME "msm_v4l2" - -#define MSM_V4L2_PROC_NAME "msm_v4l2" - -#define MSM_V4L2_DEVNUM_MPEG2 0 -#define MSM_V4L2_DEVNUM_YUV 20 - -/* HVGA-P (portrait) and HVGA-L (landscape) */ -#define MSM_V4L2_WIDTH 480 -#define MSM_V4L2_HEIGHT 320 - -#if 1 -#define D(fmt, args...) printk(KERN_INFO "msm_v4l2: " fmt, ##args) -#else -#define D(fmt, args...) do {} while (0) -#endif - -#define PREVIEW_FRAMES_NUM 4 - -struct msm_v4l2_device { - struct list_head read_queue; - struct v4l2_format current_cap_format; - struct v4l2_format current_pix_format; - struct video_device *pvdev; - struct msm_v4l2_driver *drv; - uint8_t opencnt; - - spinlock_t read_queue_lock; -}; - -static struct msm_v4l2_device *g_pmsm_v4l2_dev; - - -static DEFINE_MUTEX(msm_v4l2_opencnt_lock); - -static int msm_v4l2_open(struct file *f) -{ - int rc = 0; - D("%s\n", __func__); - mutex_lock(&msm_v4l2_opencnt_lock); - if (!g_pmsm_v4l2_dev->opencnt) { - rc = g_pmsm_v4l2_dev->drv->open( - g_pmsm_v4l2_dev->drv->sync, - MSM_APPS_ID_V4L2); - } - g_pmsm_v4l2_dev->opencnt++; - mutex_unlock(&msm_v4l2_opencnt_lock); - return rc; -} - -static int msm_v4l2_release(struct file *f) -{ - int rc = 0; - D("%s\n", __func__); - mutex_lock(&msm_v4l2_opencnt_lock); - if (!g_pmsm_v4l2_dev->opencnt) { - g_pmsm_v4l2_dev->opencnt--; - if (!g_pmsm_v4l2_dev->opencnt) { - rc = g_pmsm_v4l2_dev->drv->release( - g_pmsm_v4l2_dev->drv->sync); - } - } - mutex_unlock(&msm_v4l2_opencnt_lock); - return rc; -} - -static unsigned int msm_v4l2_poll(struct file *f, struct poll_table_struct *w) -{ - return g_pmsm_v4l2_dev->drv->drv_poll(g_pmsm_v4l2_dev->drv->sync, f, w); -} - -static long msm_v4l2_ioctl(struct file *filep, - unsigned int cmd, unsigned long arg) -{ - struct msm_ctrl_cmd *ctrlcmd; - - D("msm_v4l2_ioctl, cmd = %d, %d\n", cmd, __LINE__); - - switch (cmd) { - case MSM_V4L2_START_SNAPSHOT: - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_ioctl: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->length = 0; - ctrlcmd->value = NULL; - ctrlcmd->timeout_ms = 10000; - - D("msm_v4l2_ioctl, MSM_V4L2_START_SNAPSHOT v4l2 ioctl %d\n", - cmd); - ctrlcmd->type = MSM_V4L2_SNAPSHOT; - return g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync, - ctrlcmd); - - case MSM_V4L2_GET_PICTURE: - D("msm_v4l2_ioctl, MSM_V4L2_GET_PICTURE v4l2 ioctl %d\n", cmd); - ctrlcmd = (struct msm_ctrl_cmd *)arg; - return g_pmsm_v4l2_dev->drv->get_pict( - g_pmsm_v4l2_dev->drv->sync, ctrlcmd); - - default: - D("msm_v4l2_ioctl, standard v4l2 ioctl %d\n", cmd); - return video_ioctl2(filep, cmd, arg); - } -} - -static void msm_v4l2_release_dev(struct video_device *d) -{ - D("%s\n", __func__); -} - -static int msm_v4l2_querycap(struct file *f, - void *pctx, struct v4l2_capability *pcaps) -{ - D("%s\n", __func__); - strncpy(pcaps->driver, MSM_APPS_ID_V4L2, sizeof(pcaps->driver)); - strncpy(pcaps->card, - MSM_V4L2_DEVICE_NAME, sizeof(pcaps->card)); - pcaps->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; - return 0; -} - -static int msm_v4l2_s_std(struct file *f, void *pctx, v4l2_std_id *pnorm) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_queryctrl(struct file *f, - void *pctx, struct v4l2_queryctrl *pqctrl) -{ - int rc = 0; - struct msm_ctrl_cmd *ctrlcmd; - - D("%s\n", __func__); - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_queryctrl: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_QUERY_CTRL; - ctrlcmd->length = sizeof(struct v4l2_queryctrl); - ctrlcmd->value = pqctrl; - ctrlcmd->timeout_ms = 10000; - - rc = g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync, ctrlcmd); - if (rc < 0) - return -1; - - return ctrlcmd->status; -} - -static int msm_v4l2_g_ctrl(struct file *f, void *pctx, struct v4l2_control *c) -{ - int rc = 0; - struct msm_ctrl_cmd *ctrlcmd; - - D("%s\n", __func__); - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_g_ctrl: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_GET_CTRL; - ctrlcmd->length = sizeof(struct v4l2_control); - ctrlcmd->value = c; - ctrlcmd->timeout_ms = 10000; - - rc = g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync, ctrlcmd); - if (rc < 0) - return -1; - - return ctrlcmd->status; -} - -static int msm_v4l2_s_ctrl(struct file *f, void *pctx, struct v4l2_control *c) -{ - int rc = 0; - struct msm_ctrl_cmd *ctrlcmd; - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_s_ctrl: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_SET_CTRL; - ctrlcmd->length = sizeof(struct v4l2_control); - ctrlcmd->value = c; - ctrlcmd->timeout_ms = 10000; - - D("%s\n", __func__); - - rc = g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync, ctrlcmd); - if (rc < 0) - return -1; - - return ctrlcmd->status; -} - -static int msm_v4l2_reqbufs(struct file *f, - void *pctx, struct v4l2_requestbuffers *b) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_querybuf(struct file *f, void *pctx, struct v4l2_buffer *pb) -{ - struct msm_pmem_info pmem_buf; -#if 0 - __u32 width = 0; - __u32 height = 0; - __u32 y_size = 0; - __u32 y_pad = 0; - - /* FIXME: g_pmsm_v4l2_dev->current_pix_format.fmt.pix.width; */ - width = 640; - /* FIXME: g_pmsm_v4l2_dev->current_pix_format.fmt.pix.height; */ - height = 480; - - D("%s: width = %d, height = %d\n", __func__, width, height); - - y_size = width * height; - y_pad = y_size % 4; -#endif - - __u32 y_pad = pb->bytesused % 4; - - /* V4L2 videodev will do the copy_from_user. */ - - memset(&pmem_buf, 0, sizeof(struct msm_pmem_info)); - pmem_buf.type = MSM_PMEM_OUTPUT2; - pmem_buf.vaddr = (void *)pb->m.userptr; - pmem_buf.y_off = 0; - pmem_buf.fd = (int)pb->reserved; - /* pmem_buf.cbcr_off = (y_size + y_pad); */ - pmem_buf.cbcr_off = (pb->bytesused + y_pad); - - g_pmsm_v4l2_dev->drv->reg_pmem(g_pmsm_v4l2_dev->drv->sync, &pmem_buf); - - return 0; -} - -static int msm_v4l2_qbuf(struct file *f, void *pctx, struct v4l2_buffer *pb) -{ - /* - __u32 y_size = 0; - __u32 y_pad = 0; - __u32 width = 0; - __u32 height = 0; - */ - - __u32 y_pad = 0; - - struct msm_pmem_info meminfo; - struct msm_frame frame; - static int cnt; - - if ((pb->flags >> 16) & 0x0001) { - /* this is for previwe */ -#if 0 - width = 640; - height = 480; - - /* V4L2 videodev will do the copy_from_user. */ - D("%s: width = %d, height = %d\n", __func__, width, height); - y_size = width * height; - y_pad = y_size % 4; -#endif - - y_pad = pb->bytesused % 4; - - if (pb->type == V4L2_BUF_TYPE_PRIVATE) { - /* this qbuf is actually for releasing */ - - frame.buffer = pb->m.userptr; - frame.y_off = 0; - /* frame.cbcr_off = (y_size + y_pad); */ - frame.cbcr_off = (pb->bytesused + y_pad); - frame.fd = pb->reserved; - - D("V4L2_BUF_TYPE_PRIVATE: pb->bytesused = %d \n", - pb->bytesused); - - g_pmsm_v4l2_dev->drv->put_frame( - g_pmsm_v4l2_dev->drv->sync, - &frame); - - return 0; - } - - D("V4L2_BUF_TYPE_VIDEO_CAPTURE: pb->bytesused = %d \n", - pb->bytesused); - - meminfo.type = MSM_PMEM_OUTPUT2; - meminfo.fd = (int)pb->reserved; - meminfo.vaddr = (void *)pb->m.userptr; - meminfo.y_off = 0; - /* meminfo.cbcr_off = (y_size + y_pad); */ - meminfo.cbcr_off = (pb->bytesused + y_pad); - if (cnt == PREVIEW_FRAMES_NUM - 1) - meminfo.active = 0; - else - meminfo.active = 1; - cnt++; - g_pmsm_v4l2_dev->drv->reg_pmem(g_pmsm_v4l2_dev->drv->sync, - &meminfo); - } else if ((pb->flags) & 0x0001) { - /* this is for snapshot */ - - __u32 y_size = 0; - - if ((pb->flags >> 8) & 0x01) { - - y_size = pb->bytesused; - - meminfo.type = MSM_PMEM_THUMBAIL; - } else if ((pb->flags >> 9) & 0x01) { - - y_size = pb->bytesused; - - meminfo.type = MSM_PMEM_MAINIMG; - } - - y_pad = y_size % 4; - - meminfo.fd = (int)pb->reserved; - meminfo.vaddr = (void *)pb->m.userptr; - meminfo.y_off = 0; - /* meminfo.cbcr_off = (y_size + y_pad); */ - meminfo.cbcr_off = (y_size + y_pad); - meminfo.active = 1; - g_pmsm_v4l2_dev->drv->reg_pmem(g_pmsm_v4l2_dev->drv->sync, - &meminfo); - } - - return 0; -} - -static int msm_v4l2_dqbuf(struct file *f, void *pctx, struct v4l2_buffer *pb) -{ - struct msm_frame frame; - D("%s\n", __func__); - - /* V4L2 videodev will do the copy_to_user. */ - if (pb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { - - D("%s, %d\n", __func__, __LINE__); - - g_pmsm_v4l2_dev->drv->get_frame( - g_pmsm_v4l2_dev->drv->sync, - &frame); - - pb->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - pb->m.userptr = (unsigned long)frame.buffer; /* FIXME */ - pb->reserved = (int)frame.fd; - /* pb->length = (int)frame.cbcr_off; */ - - pb->bytesused = frame.cbcr_off; - - } else if (pb->type == V4L2_BUF_TYPE_PRIVATE) { - __u32 y_pad = pb->bytesused % 4; - - frame.buffer = pb->m.userptr; - frame.y_off = 0; - /* frame.cbcr_off = (y_size + y_pad); */ - frame.cbcr_off = (pb->bytesused + y_pad); - frame.fd = pb->reserved; - - g_pmsm_v4l2_dev->drv->put_frame( - g_pmsm_v4l2_dev->drv->sync, - &frame); - } - - return 0; -} - -static int msm_v4l2_streamon(struct file *f, void *pctx, enum v4l2_buf_type i) -{ - struct msm_ctrl_cmd *ctrlcmd; - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_s_fmt_cap: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_STREAM_ON; - ctrlcmd->timeout_ms = 10000; - ctrlcmd->length = 0; - ctrlcmd->value = NULL; - - D("%s\n", __func__); - - g_pmsm_v4l2_dev->drv->ctrl( - g_pmsm_v4l2_dev->drv->sync, - ctrlcmd); - - D("%s after drv->ctrl \n", __func__); - - return 0; -} - -static int msm_v4l2_streamoff(struct file *f, void *pctx, enum v4l2_buf_type i) -{ - struct msm_ctrl_cmd *ctrlcmd; - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_s_fmt_cap: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_STREAM_OFF; - ctrlcmd->timeout_ms = 10000; - ctrlcmd->length = 0; - ctrlcmd->value = NULL; - - - D("%s\n", __func__); - - g_pmsm_v4l2_dev->drv->ctrl( - g_pmsm_v4l2_dev->drv->sync, - ctrlcmd); - - return 0; -} - -static int msm_v4l2_enum_fmt_overlay(struct file *f, - void *pctx, struct v4l2_fmtdesc *pfmtdesc) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_enum_fmt_cap(struct file *f, - void *pctx, struct v4l2_fmtdesc *pfmtdesc) -{ - D("%s\n", __func__); - - switch (pfmtdesc->index) { - case 0: - pfmtdesc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - pfmtdesc->flags = 0; - strncpy(pfmtdesc->description, "YUV 4:2:0", - sizeof(pfmtdesc->description)); - pfmtdesc->pixelformat = V4L2_PIX_FMT_YVU420; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int msm_v4l2_g_fmt_cap(struct file *f, - void *pctx, struct v4l2_format *pfmt) -{ - D("%s\n", __func__); - pfmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - pfmt->fmt.pix.width = MSM_V4L2_WIDTH; - pfmt->fmt.pix.height = MSM_V4L2_HEIGHT; - pfmt->fmt.pix.pixelformat = V4L2_PIX_FMT_YVU420; - pfmt->fmt.pix.field = V4L2_FIELD_ANY; - pfmt->fmt.pix.bytesperline = 0; - pfmt->fmt.pix.sizeimage = 0; - pfmt->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; - pfmt->fmt.pix.priv = 0; - return 0; -} - -static int msm_v4l2_s_fmt_cap(struct file *f, - void *pctx, struct v4l2_format *pfmt) -{ - struct msm_ctrl_cmd *ctrlcmd; - - D("%s\n", __func__); - - ctrlcmd = kmalloc(sizeof(struct msm_ctrl_cmd), GFP_ATOMIC); - if (!ctrlcmd) { - CDBG("msm_v4l2_s_fmt_cap: cannot allocate buffer\n"); - return -ENOMEM; - } - - ctrlcmd->type = MSM_V4L2_VID_CAP_TYPE; - ctrlcmd->length = sizeof(struct v4l2_format); - ctrlcmd->value = pfmt; - ctrlcmd->timeout_ms = 10000; - - if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - kfree(ctrlcmd); - return -1; - } - -#if 0 - /* FIXEME */ - if (pfmt->fmt.pix.pixelformat != V4L2_PIX_FMT_YVU420) { - kfree(ctrlcmd); - return -EINVAL; - } -#endif - - /* Ok, but check other params, too. */ - -#if 0 - memcpy(&g_pmsm_v4l2_dev->current_pix_format.fmt.pix, pfmt, - sizeof(struct v4l2_format)); -#endif - - g_pmsm_v4l2_dev->drv->ctrl(g_pmsm_v4l2_dev->drv->sync, ctrlcmd); - - return 0; -} - -static int msm_v4l2_g_fmt_overlay(struct file *f, - void *pctx, struct v4l2_format *pfmt) -{ - D("%s\n", __func__); - pfmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - pfmt->fmt.pix.width = MSM_V4L2_WIDTH; - pfmt->fmt.pix.height = MSM_V4L2_HEIGHT; - pfmt->fmt.pix.pixelformat = V4L2_PIX_FMT_YVU420; - pfmt->fmt.pix.field = V4L2_FIELD_ANY; - pfmt->fmt.pix.bytesperline = 0; - pfmt->fmt.pix.sizeimage = 0; - pfmt->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; - pfmt->fmt.pix.priv = 0; - return 0; -} - -static int msm_v4l2_s_fmt_overlay(struct file *f, - void *pctx, struct v4l2_format *pfmt) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_overlay(struct file *f, void *pctx, unsigned int i) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_g_jpegcomp(struct file *f, - void *pctx, struct v4l2_jpegcompression *pcomp) -{ - D("%s\n", __func__); - return 0; -} - -static int msm_v4l2_s_jpegcomp(struct file *f, - void *pctx, struct v4l2_jpegcompression *pcomp) -{ - D("%s\n", __func__); - return 0; -} - -#ifdef CONFIG_PROC_FS -int msm_v4l2_read_proc(char *pbuf, char **start, off_t offset, - int count, int *eof, void *data) -{ - int len = 0; - len += snprintf(pbuf, strlen("stats\n") + 1, "stats\n"); - - if (g_pmsm_v4l2_dev) { - len += snprintf(pbuf, strlen("mode: ") + 1, "mode: "); - - if (g_pmsm_v4l2_dev->current_cap_format.type - == V4L2_BUF_TYPE_VIDEO_CAPTURE) - len += snprintf(pbuf, strlen("capture\n") + 1, - "capture\n"); - else - len += snprintf(pbuf, strlen("unknown\n") + 1, - "unknown\n"); - - len += snprintf(pbuf, 21, "resolution: %dx%d\n", - g_pmsm_v4l2_dev->current_cap_format.fmt.pix. - width, - g_pmsm_v4l2_dev->current_cap_format.fmt.pix. - height); - - len += snprintf(pbuf, - strlen("pixel format: ") + 1, "pixel format: "); - if (g_pmsm_v4l2_dev->current_cap_format.fmt.pix.pixelformat - == V4L2_PIX_FMT_YVU420) - len += snprintf(pbuf, strlen("yvu420\n") + 1, - "yvu420\n"); - else - len += snprintf(pbuf, strlen("unknown\n") + 1, - "unknown\n"); - - len += snprintf(pbuf, strlen("colorspace: ") + 1, - "colorspace: "); - if (g_pmsm_v4l2_dev->current_cap_format.fmt.pix.colorspace - == V4L2_COLORSPACE_JPEG) - len += snprintf(pbuf, strlen("jpeg\n") + 1, "jpeg\n"); - else - len += snprintf(pbuf, strlen("unknown\n") + 1, - "unknown\n"); - } - - *eof = 1; - return len; -} -#endif - -static const struct v4l2_file_operations msm_v4l2_fops = { - .owner = THIS_MODULE, - .open = msm_v4l2_open, - .poll = msm_v4l2_poll, - .release = msm_v4l2_release, - .ioctl = msm_v4l2_ioctl, -}; - -static void msm_v4l2_dev_init(struct msm_v4l2_device *pmsm_v4l2_dev) -{ - pmsm_v4l2_dev->read_queue_lock = - __SPIN_LOCK_UNLOCKED(pmsm_v4l2_dev->read_queue_lock); - INIT_LIST_HEAD(&pmsm_v4l2_dev->read_queue); -} - -static int msm_v4l2_try_fmt_cap(struct file *file, - void *fh, struct v4l2_format *f) -{ - /* FIXME */ - return 0; -} - -static int mm_v4l2_try_fmt_type_private(struct file *file, - void *fh, struct v4l2_format *f) -{ - /* FIXME */ - return 0; -} - -/* - * should the following structure be used instead of the code in the function? - * static const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = { - * .vidioc_querycap = .... - * } - */ -static const struct v4l2_ioctl_ops msm_ioctl_ops = { - .vidioc_querycap = msm_v4l2_querycap, - .vidioc_s_std = msm_v4l2_s_std, - - .vidioc_queryctrl = msm_v4l2_queryctrl, - .vidioc_g_ctrl = msm_v4l2_g_ctrl, - .vidioc_s_ctrl = msm_v4l2_s_ctrl, - - .vidioc_reqbufs = msm_v4l2_reqbufs, - .vidioc_querybuf = msm_v4l2_querybuf, - .vidioc_qbuf = msm_v4l2_qbuf, - .vidioc_dqbuf = msm_v4l2_dqbuf, - - .vidioc_streamon = msm_v4l2_streamon, - .vidioc_streamoff = msm_v4l2_streamoff, - - .vidioc_enum_fmt_vid_overlay = msm_v4l2_enum_fmt_overlay, - .vidioc_enum_fmt_vid_cap = msm_v4l2_enum_fmt_cap, - - .vidioc_try_fmt_vid_cap = msm_v4l2_try_fmt_cap, - .vidioc_try_fmt_type_private = mm_v4l2_try_fmt_type_private, - - .vidioc_g_fmt_vid_cap = msm_v4l2_g_fmt_cap, - .vidioc_s_fmt_vid_cap = msm_v4l2_s_fmt_cap, - .vidioc_g_fmt_vid_overlay = msm_v4l2_g_fmt_overlay, - .vidioc_s_fmt_vid_overlay = msm_v4l2_s_fmt_overlay, - .vidioc_overlay = msm_v4l2_overlay, - - .vidioc_g_jpegcomp = msm_v4l2_g_jpegcomp, - .vidioc_s_jpegcomp = msm_v4l2_s_jpegcomp, -}; - -static int msm_v4l2_video_dev_init(struct video_device *pvd) -{ - strncpy(pvd->name, MSM_APPS_ID_V4L2, sizeof(pvd->name)); - pvd->vfl_type = 1; - pvd->fops = &msm_v4l2_fops; - pvd->release = msm_v4l2_release_dev; - pvd->minor = -1; - pvd->ioctl_ops = &msm_ioctl_ops; - return msm_v4l2_register(g_pmsm_v4l2_dev->drv); -} - -static int __init msm_v4l2_init(void) -{ - int rc = -ENOMEM; - struct video_device *pvdev = NULL; - struct msm_v4l2_device *pmsm_v4l2_dev = NULL; - D("%s\n", __func__); - - pvdev = video_device_alloc(); - if (pvdev == NULL) - return rc; - - pmsm_v4l2_dev = - kzalloc(sizeof(struct msm_v4l2_device), GFP_KERNEL); - if (pmsm_v4l2_dev == NULL) { - video_device_release(pvdev); - return rc; - } - - msm_v4l2_dev_init(pmsm_v4l2_dev); - - g_pmsm_v4l2_dev = pmsm_v4l2_dev; - g_pmsm_v4l2_dev->pvdev = pvdev; - - g_pmsm_v4l2_dev->drv = - kzalloc(sizeof(struct msm_v4l2_driver), GFP_KERNEL); - if (!g_pmsm_v4l2_dev->drv) { - video_device_release(pvdev); - kfree(pmsm_v4l2_dev); - return rc; - } - - rc = msm_v4l2_video_dev_init(pvdev); - if (rc < 0) { - video_device_release(pvdev); - kfree(g_pmsm_v4l2_dev->drv); - kfree(pmsm_v4l2_dev); - return rc; - } - - if (video_register_device(pvdev, VFL_TYPE_GRABBER, - MSM_V4L2_DEVNUM_YUV)) { - D("failed to register device\n"); - video_device_release(pvdev); - kfree(g_pmsm_v4l2_dev); - g_pmsm_v4l2_dev = NULL; - return -ENOENT; - } -#ifdef CONFIG_PROC_FS - create_proc_read_entry(MSM_V4L2_PROC_NAME, - 0, NULL, msm_v4l2_read_proc, NULL); -#endif - - return 0; -} - -static void __exit msm_v4l2_exit(void) -{ - struct video_device *pvdev = g_pmsm_v4l2_dev->pvdev; - D("%s\n", __func__); -#ifdef CONFIG_PROC_FS - remove_proc_entry(MSM_V4L2_PROC_NAME, NULL); -#endif - video_unregister_device(pvdev); - video_device_release(pvdev); - - msm_v4l2_unregister(g_pmsm_v4l2_dev->drv); - - kfree(g_pmsm_v4l2_dev->drv); - g_pmsm_v4l2_dev->drv = NULL; - - kfree(g_pmsm_v4l2_dev); - g_pmsm_v4l2_dev = NULL; -} - -module_init(msm_v4l2_init); -module_exit(msm_v4l2_exit); - -MODULE_DESCRIPTION("MSM V4L2 driver"); -MODULE_LICENSE("GPL v2"); diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe7x.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe7x.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe7x.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe7x.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,701 +0,0 @@ -/* - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "msm_vfe7x.h" - -#define QDSP_CMDQUEUE QDSP_vfeCommandQueue - -#define VFE_RESET_CMD 0 -#define VFE_START_CMD 1 -#define VFE_STOP_CMD 2 -#define VFE_FRAME_ACK 20 -#define STATS_AF_ACK 21 -#define STATS_WE_ACK 22 - -#define MSG_STOP_ACK 1 -#define MSG_SNAPSHOT 2 -#define MSG_OUTPUT1 6 -#define MSG_OUTPUT2 7 -#define MSG_STATS_AF 8 -#define MSG_STATS_WE 9 - -static struct msm_adsp_module *qcam_mod; -static struct msm_adsp_module *vfe_mod; -static struct msm_vfe_callback *resp; -static void *extdata; -static uint32_t extlen; - -struct mutex vfe_lock; -static void *vfe_syncdata; -static uint8_t vfestopped; - -static struct stop_event stopevent; - -static void vfe_7x_convert(struct msm_vfe_phy_info *pinfo, - enum vfe_resp_msg type, - void *data, void **ext, int32_t *elen) -{ - switch (type) { - case VFE_MSG_OUTPUT1: - case VFE_MSG_OUTPUT2: { - pinfo->y_phy = ((struct vfe_endframe *)data)->y_address; - pinfo->cbcr_phy = - ((struct vfe_endframe *)data)->cbcr_address; - - CDBG("vfe_7x_convert, y_phy = 0x%x, cbcr_phy = 0x%x\n", - pinfo->y_phy, pinfo->cbcr_phy); - - ((struct vfe_frame_extra *)extdata)->bl_evencol = - ((struct vfe_endframe *)data)->blacklevelevencolumn; - - ((struct vfe_frame_extra *)extdata)->bl_oddcol = - ((struct vfe_endframe *)data)->blackleveloddcolumn; - - ((struct vfe_frame_extra *)extdata)->g_def_p_cnt = - ((struct vfe_endframe *)data)->greendefectpixelcount; - - ((struct vfe_frame_extra *)extdata)->r_b_def_p_cnt = - ((struct vfe_endframe *)data)->redbluedefectpixelcount; - - *ext = extdata; - *elen = extlen; - } - break; - - case VFE_MSG_STATS_AF: - case VFE_MSG_STATS_WE: - pinfo->sbuf_phy = *(uint32_t *)data; - break; - - default: - break; - } /* switch */ -} - -static void vfe_7x_ops(void *driver_data, unsigned id, size_t len, - void (*getevent)(void *ptr, size_t len)) -{ - uint32_t evt_buf[3]; - struct msm_vfe_resp *rp; - void *data; - - len = (id == (uint16_t)-1) ? 0 : len; - data = resp->vfe_alloc(sizeof(struct msm_vfe_resp) + len, vfe_syncdata); - - if (!data) { - pr_err("rp: cannot allocate buffer\n"); - return; - } - rp = (struct msm_vfe_resp *)data; - rp->evt_msg.len = len; - - if (id == ((uint16_t)-1)) { - /* event */ - rp->type = VFE_EVENT; - rp->evt_msg.type = MSM_CAMERA_EVT; - getevent(evt_buf, sizeof(evt_buf)); - rp->evt_msg.msg_id = evt_buf[0]; - resp->vfe_resp(rp, MSM_CAM_Q_VFE_EVT, vfe_syncdata); - } else { - /* messages */ - rp->evt_msg.type = MSM_CAMERA_MSG; - rp->evt_msg.msg_id = id; - rp->evt_msg.data = rp + 1; - getevent(rp->evt_msg.data, len); - - switch (rp->evt_msg.msg_id) { - case MSG_SNAPSHOT: - rp->type = VFE_MSG_SNAPSHOT; - break; - - case MSG_OUTPUT1: - rp->type = VFE_MSG_OUTPUT1; - vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT1, - rp->evt_msg.data, &(rp->extdata), - &(rp->extlen)); - break; - - case MSG_OUTPUT2: - rp->type = VFE_MSG_OUTPUT2; - vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT2, - rp->evt_msg.data, &(rp->extdata), - &(rp->extlen)); - break; - - case MSG_STATS_AF: - rp->type = VFE_MSG_STATS_AF; - vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_AF, - rp->evt_msg.data, NULL, NULL); - break; - - case MSG_STATS_WE: - rp->type = VFE_MSG_STATS_WE; - vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_WE, - rp->evt_msg.data, NULL, NULL); - - CDBG("MSG_STATS_WE: phy = 0x%x\n", rp->phy.sbuf_phy); - break; - - case MSG_STOP_ACK: - rp->type = VFE_MSG_GENERAL; - stopevent.state = 1; - wake_up(&stopevent.wait); - break; - - - default: - rp->type = VFE_MSG_GENERAL; - break; - } - resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, vfe_syncdata); - } -} - -static struct msm_adsp_ops vfe_7x_sync = { - .event = vfe_7x_ops, -}; - -static int vfe_7x_enable(struct camera_enable_cmd *enable) -{ - int rc = -EFAULT; - - if (!strcmp(enable->name, "QCAMTASK")) - rc = msm_adsp_enable(qcam_mod); - else if (!strcmp(enable->name, "VFETASK")) - rc = msm_adsp_enable(vfe_mod); - - return rc; -} - -static int vfe_7x_disable(struct camera_enable_cmd *enable, - struct platform_device *dev __attribute__((unused))) -{ - int rc = -EFAULT; - - if (!strcmp(enable->name, "QCAMTASK")) - rc = msm_adsp_disable(qcam_mod); - else if (!strcmp(enable->name, "VFETASK")) - rc = msm_adsp_disable(vfe_mod); - - return rc; -} - -static int vfe_7x_stop(void) -{ - int rc = 0; - uint32_t stopcmd = VFE_STOP_CMD; - rc = msm_adsp_write(vfe_mod, QDSP_CMDQUEUE, - &stopcmd, sizeof(uint32_t)); - if (rc < 0) { - CDBG("%s:%d: failed rc = %d \n", __func__, __LINE__, rc); - return rc; - } - - stopevent.state = 0; - rc = wait_event_timeout(stopevent.wait, - stopevent.state != 0, - msecs_to_jiffies(stopevent.timeout)); - - return rc; -} - -static void vfe_7x_release(struct platform_device *pdev) -{ - mutex_lock(&vfe_lock); - vfe_syncdata = NULL; - mutex_unlock(&vfe_lock); - - if (!vfestopped) { - CDBG("%s:%d:Calling vfe_7x_stop()\n", __func__, __LINE__); - vfe_7x_stop(); - } else - vfestopped = 0; - - msm_adsp_disable(qcam_mod); - msm_adsp_disable(vfe_mod); - - msm_adsp_put(qcam_mod); - msm_adsp_put(vfe_mod); - - msm_camio_disable(pdev); - - kfree(extdata); - extlen = 0; -} - -static int vfe_7x_init(struct msm_vfe_callback *presp, - struct platform_device *dev) -{ - int rc = 0; - - init_waitqueue_head(&stopevent.wait); - stopevent.timeout = 200; - stopevent.state = 0; - - if (presp && presp->vfe_resp) - resp = presp; - else - return -EFAULT; - - /* Bring up all the required GPIOs and Clocks */ - rc = msm_camio_enable(dev); - if (rc < 0) - return rc; - - msm_camio_camif_pad_reg_reset(); - - extlen = sizeof(struct vfe_frame_extra); - - extdata = - kmalloc(sizeof(extlen), GFP_ATOMIC); - if (!extdata) { - rc = -ENOMEM; - goto init_fail; - } - - rc = msm_adsp_get("QCAMTASK", &qcam_mod, &vfe_7x_sync, NULL); - if (rc) { - rc = -EBUSY; - goto get_qcam_fail; - } - - rc = msm_adsp_get("VFETASK", &vfe_mod, &vfe_7x_sync, NULL); - if (rc) { - rc = -EBUSY; - goto get_vfe_fail; - } - - return 0; - -get_vfe_fail: - msm_adsp_put(qcam_mod); -get_qcam_fail: - kfree(extdata); -init_fail: - extlen = 0; - return rc; -} - -static int vfe_7x_config_axi(int mode, - struct axidata *ad, struct axiout *ao) -{ - struct msm_pmem_region *regptr; - unsigned long *bptr; - int cnt; - - int rc = 0; - - if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) { - regptr = ad->region; - - CDBG("bufnum1 = %d\n", ad->bufnum1); - CDBG("config_axi1: O1, phy = 0x%lx, y_off = %d, cbcr_off =%d\n", - regptr->paddr, regptr->y_off, regptr->cbcr_off); - - bptr = &ao->output1buffer1_y_phy; - for (cnt = 0; cnt < ad->bufnum1; cnt++) { - *bptr = regptr->paddr + regptr->y_off; - bptr++; - *bptr = regptr->paddr + regptr->cbcr_off; - - bptr++; - regptr++; - } - - regptr--; - for (cnt = 0; cnt < (8 - ad->bufnum1); cnt++) { - *bptr = regptr->paddr + regptr->y_off; - bptr++; - *bptr = regptr->paddr + regptr->cbcr_off; - bptr++; - } - } /* if OUTPUT1 or Both */ - - if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) { - regptr = &(ad->region[ad->bufnum1]); - - CDBG("bufnum2 = %d\n", ad->bufnum2); - CDBG("config_axi2: O2, phy = 0x%lx, y_off = %d, cbcr_off =%d\n", - regptr->paddr, regptr->y_off, regptr->cbcr_off); - - bptr = &ao->output2buffer1_y_phy; - for (cnt = 0; cnt < ad->bufnum2; cnt++) { - *bptr = regptr->paddr + regptr->y_off; - bptr++; - *bptr = regptr->paddr + regptr->cbcr_off; - - bptr++; - regptr++; - } - - regptr--; - for (cnt = 0; cnt < (8 - ad->bufnum2); cnt++) { - *bptr = regptr->paddr + regptr->y_off; - bptr++; - *bptr = regptr->paddr + regptr->cbcr_off; - bptr++; - } - } - - return rc; -} - -static int vfe_7x_config(struct msm_vfe_cfg_cmd *cmd, void *data) -{ - struct msm_pmem_region *regptr; - unsigned char buf[256]; - - struct vfe_stats_ack sack; - struct axidata *axid; - uint32_t i; - - struct vfe_stats_we_cfg *scfg = NULL; - struct vfe_stats_af_cfg *sfcfg = NULL; - - struct axiout *axio = NULL; - void *cmd_data = NULL; - void *cmd_data_alloc = NULL; - long rc = 0; - struct msm_vfe_command_7k *vfecmd; - - vfecmd = - kmalloc(sizeof(struct msm_vfe_command_7k), - GFP_ATOMIC); - if (!vfecmd) { - pr_err("vfecmd alloc failed!\n"); - return -ENOMEM; - } - - if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE && - cmd->cmd_type != CMD_STATS_BUF_RELEASE && - cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) { - if (copy_from_user(vfecmd, - (void __user *)(cmd->value), - sizeof(struct msm_vfe_command_7k))) { - rc = -EFAULT; - goto config_failure; - } - } - - switch (cmd->cmd_type) { - case CMD_STATS_ENABLE: - case CMD_STATS_AXI_CFG: { - axid = data; - if (!axid) { - rc = -EFAULT; - goto config_failure; - } - - scfg = - kmalloc(sizeof(struct vfe_stats_we_cfg), - GFP_ATOMIC); - if (!scfg) { - rc = -ENOMEM; - goto config_failure; - } - - if (copy_from_user(scfg, - (void __user *)(vfecmd->value), - vfecmd->length)) { - - rc = -EFAULT; - goto config_done; - } - - CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n", - axid->bufnum1, scfg->wb_expstatsenable); - - if (axid->bufnum1 > 0) { - regptr = axid->region; - - for (i = 0; i < axid->bufnum1; i++) { - - CDBG("STATS_ENABLE, phy = 0x%lx\n", - regptr->paddr); - - scfg->wb_expstatoutputbuffer[i] = - (void *)regptr->paddr; - regptr++; - } - - cmd_data = scfg; - - } else { - rc = -EINVAL; - goto config_done; - } - } - break; - - case CMD_STATS_AF_ENABLE: - case CMD_STATS_AF_AXI_CFG: { - axid = data; - if (!axid) { - rc = -EFAULT; - goto config_failure; - } - - sfcfg = - kmalloc(sizeof(struct vfe_stats_af_cfg), - GFP_ATOMIC); - - if (!sfcfg) { - rc = -ENOMEM; - goto config_failure; - } - - if (copy_from_user(sfcfg, - (void __user *)(vfecmd->value), - vfecmd->length)) { - - rc = -EFAULT; - goto config_done; - } - - CDBG("AF_ENABLE: bufnum = %d, enabling = %d\n", - axid->bufnum1, sfcfg->af_enable); - - if (axid->bufnum1 > 0) { - regptr = axid->region; - - for (i = 0; i < axid->bufnum1; i++) { - - CDBG("STATS_ENABLE, phy = 0x%lx\n", - regptr->paddr); - - sfcfg->af_outbuf[i] = - (void *)regptr->paddr; - - regptr++; - } - - cmd_data = sfcfg; - - } else { - rc = -EINVAL; - goto config_done; - } - } - break; - - case CMD_FRAME_BUF_RELEASE: { - struct msm_frame *b; - unsigned long p; - struct vfe_outputack fack; - if (!data) { - rc = -EFAULT; - goto config_failure; - } - - b = (struct msm_frame *)(cmd->value); - p = *(unsigned long *)data; - - fack.header = VFE_FRAME_ACK; - - fack.output2newybufferaddress = - (void *)(p + b->y_off); - - fack.output2newcbcrbufferaddress = - (void *)(p + b->cbcr_off); - - vfecmd->queue = QDSP_CMDQUEUE; - vfecmd->length = sizeof(struct vfe_outputack); - cmd_data = &fack; - } - break; - - case CMD_SNAP_BUF_RELEASE: - break; - - case CMD_STATS_BUF_RELEASE: { - CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n"); - if (!data) { - rc = -EFAULT; - goto config_failure; - } - - sack.header = STATS_WE_ACK; - sack.bufaddr = (void *)*(uint32_t *)data; - - vfecmd->queue = QDSP_CMDQUEUE; - vfecmd->length = sizeof(struct vfe_stats_ack); - cmd_data = &sack; - } - break; - - case CMD_STATS_AF_BUF_RELEASE: { - CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n"); - if (!data) { - rc = -EFAULT; - goto config_failure; - } - - sack.header = STATS_AF_ACK; - sack.bufaddr = (void *)*(uint32_t *)data; - - vfecmd->queue = QDSP_CMDQUEUE; - vfecmd->length = sizeof(struct vfe_stats_ack); - cmd_data = &sack; - } - break; - - case CMD_GENERAL: - case CMD_STATS_DISABLE: { - if (vfecmd->length > 256) { - cmd_data_alloc = - cmd_data = kmalloc(vfecmd->length, GFP_ATOMIC); - if (!cmd_data) { - rc = -ENOMEM; - goto config_failure; - } - } else - cmd_data = buf; - - if (copy_from_user(cmd_data, - (void __user *)(vfecmd->value), - vfecmd->length)) { - - rc = -EFAULT; - goto config_done; - } - - if (vfecmd->queue == QDSP_CMDQUEUE) { - switch (*(uint32_t *)cmd_data) { - case VFE_RESET_CMD: - msm_camio_vfe_blk_reset(); - msm_camio_camif_pad_reg_reset_2(); - vfestopped = 0; - break; - - case VFE_START_CMD: - msm_camio_camif_pad_reg_reset_2(); - vfestopped = 0; - break; - - case VFE_STOP_CMD: - vfestopped = 1; - goto config_send; - - default: - break; - } - } /* QDSP_CMDQUEUE */ - } - break; - - case CMD_AXI_CFG_OUT1: { - axid = data; - if (!axid) { - rc = -EFAULT; - goto config_failure; - } - - axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC); - if (!axio) { - rc = -ENOMEM; - goto config_failure; - } - - if (copy_from_user(axio, (void *)(vfecmd->value), - sizeof(struct axiout))) { - rc = -EFAULT; - goto config_done; - } - - vfe_7x_config_axi(OUTPUT_1, axid, axio); - - cmd_data = axio; - } - break; - - case CMD_AXI_CFG_OUT2: - case CMD_RAW_PICT_AXI_CFG: { - axid = data; - if (!axid) { - rc = -EFAULT; - goto config_failure; - } - - axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC); - if (!axio) { - rc = -ENOMEM; - goto config_failure; - } - - if (copy_from_user(axio, (void __user *)(vfecmd->value), - sizeof(struct axiout))) { - rc = -EFAULT; - goto config_done; - } - - vfe_7x_config_axi(OUTPUT_2, axid, axio); - cmd_data = axio; - } - break; - - case CMD_AXI_CFG_SNAP_O1_AND_O2: { - axid = data; - if (!axid) { - rc = -EFAULT; - goto config_failure; - } - - axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC); - if (!axio) { - rc = -ENOMEM; - goto config_failure; - } - - if (copy_from_user(axio, (void __user *)(vfecmd->value), - sizeof(struct axiout))) { - rc = -EFAULT; - goto config_done; - } - - vfe_7x_config_axi(OUTPUT_1_AND_2, axid, axio); - - cmd_data = axio; - } - break; - - default: - break; - } /* switch */ - - if (vfestopped) - goto config_done; - -config_send: - CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data); - rc = msm_adsp_write(vfe_mod, vfecmd->queue, - cmd_data, vfecmd->length); - -config_done: - if (cmd_data_alloc != NULL) - kfree(cmd_data_alloc); - -config_failure: - kfree(scfg); - kfree(axio); - kfree(vfecmd); - return rc; -} - -void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data) -{ - mutex_init(&vfe_lock); - fptr->vfe_init = vfe_7x_init; - fptr->vfe_enable = vfe_7x_enable; - fptr->vfe_config = vfe_7x_config; - fptr->vfe_disable = vfe_7x_disable; - fptr->vfe_release = vfe_7x_release; - vfe_syncdata = data; -} diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe7x.h linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe7x.h --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe7x.h 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe7x.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,255 +0,0 @@ -/* - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - */ -#ifndef __MSM_VFE7X_H__ -#define __MSM_VFE7X_H__ -#include -#include - -struct vfe_frame_extra { - uint32_t bl_evencol; - uint32_t bl_oddcol; - uint16_t g_def_p_cnt; - uint16_t r_b_def_p_cnt; -}; - -struct vfe_endframe { - uint32_t y_address; - uint32_t cbcr_address; - - unsigned int blacklevelevencolumn:23; - uint16_t reserved1:9; - unsigned int blackleveloddcolumn:23; - uint16_t reserved2:9; - - uint16_t greendefectpixelcount:8; - uint16_t reserved3:8; - uint16_t redbluedefectpixelcount:8; - uint16_t reserved4:8; -} __attribute__((packed, aligned(4))); - -struct vfe_outputack { - uint32_t header; - void *output2newybufferaddress; - void *output2newcbcrbufferaddress; -} __attribute__((packed, aligned(4))); - -struct vfe_stats_ack { - uint32_t header; - /* MUST BE 64 bit ALIGNED */ - void *bufaddr; -} __attribute__((packed, aligned(4))); - -/* AXI Output Config Command sent to DSP */ -struct axiout { - uint32_t cmdheader:32; - int outputmode:3; - uint8_t format:2; - uint32_t /* reserved */ : 27; - - /* AXI Output 1 Y Configuration, Part 1 */ - uint32_t out1yimageheight:12; - uint32_t /* reserved */ : 4; - uint32_t out1yimagewidthin64bitwords:10; - uint32_t /* reserved */ : 6; - - /* AXI Output 1 Y Configuration, Part 2 */ - uint8_t out1yburstlen:2; - uint32_t out1ynumrows:12; - uint32_t out1yrowincin64bitincs:12; - uint32_t /* reserved */ : 6; - - /* AXI Output 1 CbCr Configuration, Part 1 */ - uint32_t out1cbcrimageheight:12; - uint32_t /* reserved */ : 4; - uint32_t out1cbcrimagewidthin64bitwords:10; - uint32_t /* reserved */ : 6; - - /* AXI Output 1 CbCr Configuration, Part 2 */ - uint8_t out1cbcrburstlen:2; - uint32_t out1cbcrnumrows:12; - uint32_t out1cbcrrowincin64bitincs:12; - uint32_t /* reserved */ : 6; - - /* AXI Output 2 Y Configuration, Part 1 */ - uint32_t out2yimageheight:12; - uint32_t /* reserved */ : 4; - uint32_t out2yimagewidthin64bitwords:10; - uint32_t /* reserved */ : 6; - - /* AXI Output 2 Y Configuration, Part 2 */ - uint8_t out2yburstlen:2; - uint32_t out2ynumrows:12; - uint32_t out2yrowincin64bitincs:12; - uint32_t /* reserved */ : 6; - - /* AXI Output 2 CbCr Configuration, Part 1 */ - uint32_t out2cbcrimageheight:12; - uint32_t /* reserved */ : 4; - uint32_t out2cbcrimagewidtein64bitwords:10; - uint32_t /* reserved */ : 6; - - /* AXI Output 2 CbCr Configuration, Part 2 */ - uint8_t out2cbcrburstlen:2; - uint32_t out2cbcrnumrows:12; - uint32_t out2cbcrrowincin64bitincs:12; - uint32_t /* reserved */ : 6; - - /* Address configuration: - * output1 phisycal address */ - unsigned long output1buffer1_y_phy; - unsigned long output1buffer1_cbcr_phy; - unsigned long output1buffer2_y_phy; - unsigned long output1buffer2_cbcr_phy; - unsigned long output1buffer3_y_phy; - unsigned long output1buffer3_cbcr_phy; - unsigned long output1buffer4_y_phy; - unsigned long output1buffer4_cbcr_phy; - unsigned long output1buffer5_y_phy; - unsigned long output1buffer5_cbcr_phy; - unsigned long output1buffer6_y_phy; - unsigned long output1buffer6_cbcr_phy; - unsigned long output1buffer7_y_phy; - unsigned long output1buffer7_cbcr_phy; - unsigned long output1buffer8_y_phy; - unsigned long output1buffer8_cbcr_phy; - - /* output2 phisycal address */ - unsigned long output2buffer1_y_phy; - unsigned long output2buffer1_cbcr_phy; - unsigned long output2buffer2_y_phy; - unsigned long output2buffer2_cbcr_phy; - unsigned long output2buffer3_y_phy; - unsigned long output2buffer3_cbcr_phy; - unsigned long output2buffer4_y_phy; - unsigned long output2buffer4_cbcr_phy; - unsigned long output2buffer5_y_phy; - unsigned long output2buffer5_cbcr_phy; - unsigned long output2buffer6_y_phy; - unsigned long output2buffer6_cbcr_phy; - unsigned long output2buffer7_y_phy; - unsigned long output2buffer7_cbcr_phy; - unsigned long output2buffer8_y_phy; - unsigned long output2buffer8_cbcr_phy; -} __attribute__((packed, aligned(4))); - -struct vfe_stats_we_cfg { - uint32_t header; - - /* White Balance/Exposure Statistic Selection */ - uint8_t wb_expstatsenable:1; - uint8_t wb_expstatbuspriorityselection:1; - unsigned int wb_expstatbuspriorityvalue:4; - unsigned int /* reserved */ : 26; - - /* White Balance/Exposure Statistic Configuration, Part 1 */ - uint8_t exposurestatregions:1; - uint8_t exposurestatsubregions:1; - unsigned int /* reserved */ : 14; - - unsigned int whitebalanceminimumy:8; - unsigned int whitebalancemaximumy:8; - - /* White Balance/Exposure Statistic Configuration, Part 2 */ - uint8_t wb_expstatslopeofneutralregionline[ - NUM_WB_EXP_NEUTRAL_REGION_LINES]; - - /* White Balance/Exposure Statistic Configuration, Part 3 */ - unsigned int wb_expstatcrinterceptofneutralregionline2:12; - unsigned int /* reserved */ : 4; - unsigned int wb_expstatcbinterceptofneutralreginnline1:12; - unsigned int /* reserved */ : 4; - - /* White Balance/Exposure Statistic Configuration, Part 4 */ - unsigned int wb_expstatcrinterceptofneutralregionline4:12; - unsigned int /* reserved */ : 4; - unsigned int wb_expstatcbinterceptofneutralregionline3:12; - unsigned int /* reserved */ : 4; - - /* White Balance/Exposure Statistic Output Buffer Header */ - unsigned int wb_expmetricheaderpattern:8; - unsigned int /* reserved */ : 24; - - /* White Balance/Exposure Statistic Output Buffers-MUST - * BE 64 bit ALIGNED */ - void *wb_expstatoutputbuffer[NUM_WB_EXP_STAT_OUTPUT_BUFFERS]; -} __attribute__((packed, aligned(4))); - -struct vfe_stats_af_cfg { - uint32_t header; - - /* Autofocus Statistic Selection */ - uint8_t af_enable:1; - uint8_t af_busprioritysel:1; - unsigned int af_buspriorityval:4; - unsigned int /* reserved */ : 26; - - /* Autofocus Statistic Configuration, Part 1 */ - unsigned int af_singlewinvoffset:12; - unsigned int /* reserved */ : 4; - unsigned int af_singlewinhoffset:12; - unsigned int /* reserved */ : 3; - uint8_t af_winmode:1; - - /* Autofocus Statistic Configuration, Part 2 */ - unsigned int af_singglewinvh:11; - unsigned int /* reserved */ : 5; - unsigned int af_singlewinhw:11; - unsigned int /* reserved */ : 5; - - /* Autofocus Statistic Configuration, Parts 3-6 */ - uint8_t af_multiwingrid[NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS]; - - /* Autofocus Statistic Configuration, Part 7 */ - signed int af_metrichpfcoefa00:5; - signed int af_metrichpfcoefa04:5; - unsigned int af_metricmaxval:11; - uint8_t af_metricsel:1; - unsigned int /* reserved */ : 10; - - /* Autofocus Statistic Configuration, Part 8 */ - signed int af_metrichpfcoefa20:5; - signed int af_metrichpfcoefa21:5; - signed int af_metrichpfcoefa22:5; - signed int af_metrichpfcoefa23:5; - signed int af_metrichpfcoefa24:5; - unsigned int /* reserved */ : 7; - - /* Autofocus Statistic Output Buffer Header */ - unsigned int af_metrichp:8; - unsigned int /* reserved */ : 24; - - /* Autofocus Statistic Output Buffers - MUST BE 64 bit ALIGNED!!! */ - void *af_outbuf[NUM_AF_STAT_OUTPUT_BUFFERS]; -} __attribute__((packed, aligned(4))); /* VFE_StatsAutofocusConfigCmdType */ - -struct msm_camera_frame_msg { - unsigned long output_y_address; - unsigned long output_cbcr_address; - - unsigned int blacklevelevenColumn:23; - uint16_t reserved1:9; - unsigned int blackleveloddColumn:23; - uint16_t reserved2:9; - - uint16_t greendefectpixelcount:8; - uint16_t reserved3:8; - uint16_t redbluedefectpixelcount:8; - uint16_t reserved4:8; -} __attribute__((packed, aligned(4))); - -/* New one for 7k */ -struct msm_vfe_command_7k { - uint16_t queue; - uint16_t length; - void *value; -}; - -struct stop_event { - wait_queue_head_t wait; - int state; - int timeout; -}; - - -#endif /* __MSM_VFE7X_H__ */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,756 +0,0 @@ -/* - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - */ -#include -#include -#include -#include "msm_vfe8x_proc.h" - -#define ON 1 -#define OFF 0 - -struct mutex vfe_lock; -static void *vfe_syncdata; - -static int vfe_enable(struct camera_enable_cmd *enable) -{ - int rc = 0; - return rc; -} - -static int vfe_disable(struct camera_enable_cmd *enable, - struct platform_device *dev) -{ - int rc = 0; - - vfe_stop(); - - msm_camio_disable(dev); - return rc; -} - -static void vfe_release(struct platform_device *dev) -{ - msm_camio_disable(dev); - vfe_cmd_release(dev); - - mutex_lock(&vfe_lock); - vfe_syncdata = NULL; - mutex_unlock(&vfe_lock); -} - -static void vfe_config_axi(int mode, - struct axidata *ad, struct vfe_cmd_axi_output_config *ao) -{ - struct msm_pmem_region *regptr; - int i, j; - uint32_t *p1, *p2; - - if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) { - regptr = ad->region; - for (i = 0; - i < ad->bufnum1; i++) { - - p1 = &(ao->output1.outputY.outFragments[i][0]); - p2 = &(ao->output1.outputCbcr.outFragments[i][0]); - - for (j = 0; - j < ao->output1.fragmentCount; j++) { - - *p1 = regptr->paddr + regptr->y_off; - p1++; - - *p2 = regptr->paddr + regptr->cbcr_off; - p2++; - } - regptr++; - } - } /* if OUTPUT1 or Both */ - - if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) { - - regptr = &(ad->region[ad->bufnum1]); - CDBG("bufnum2 = %d\n", ad->bufnum2); - - for (i = 0; - i < ad->bufnum2; i++) { - - p1 = &(ao->output2.outputY.outFragments[i][0]); - p2 = &(ao->output2.outputCbcr.outFragments[i][0]); - - CDBG("config_axi: O2, phy = 0x%lx, y_off = %d, cbcr_off = %d\n", - regptr->paddr, regptr->y_off, regptr->cbcr_off); - - for (j = 0; - j < ao->output2.fragmentCount; j++) { - - *p1 = regptr->paddr + regptr->y_off; - CDBG("vfe_config_axi: p1 = 0x%x\n", *p1); - p1++; - - *p2 = regptr->paddr + regptr->cbcr_off; - CDBG("vfe_config_axi: p2 = 0x%x\n", *p2); - p2++; - } - regptr++; - } - } -} - -static int vfe_proc_general(struct msm_vfe_command_8k *cmd) -{ - int rc = 0; - - CDBG("vfe_proc_general: cmdID = %d\n", cmd->id); - - switch (cmd->id) { - case VFE_CMD_ID_RESET: - msm_camio_vfe_blk_reset(); - msm_camio_camif_pad_reg_reset_2(); - vfe_reset(); - break; - - case VFE_CMD_ID_START: { - struct vfe_cmd_start start; - if (copy_from_user(&start, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - /* msm_camio_camif_pad_reg_reset_2(); */ - msm_camio_camif_pad_reg_reset(); - vfe_start(&start); - } - break; - - case VFE_CMD_ID_CAMIF_CONFIG: { - struct vfe_cmd_camif_config camif; - if (copy_from_user(&camif, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_camif_config(&camif); - } - break; - - case VFE_CMD_ID_BLACK_LEVEL_CONFIG: { - struct vfe_cmd_black_level_config bl; - if (copy_from_user(&bl, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_black_level_config(&bl); - } - break; - - case VFE_CMD_ID_ROLL_OFF_CONFIG: { - struct vfe_cmd_roll_off_config rolloff; - if (copy_from_user(&rolloff, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_roll_off_config(&rolloff); - } - break; - - case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG: { - struct vfe_cmd_demux_channel_gain_config demuxc; - if (copy_from_user(&demuxc, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - /* demux is always enabled. */ - vfe_demux_channel_gain_config(&demuxc); - } - break; - - case VFE_CMD_ID_DEMOSAIC_CONFIG: { - struct vfe_cmd_demosaic_config demosaic; - if (copy_from_user(&demosaic, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_demosaic_config(&demosaic); - } - break; - - case VFE_CMD_ID_FOV_CROP_CONFIG: - case VFE_CMD_ID_FOV_CROP_UPDATE: { - struct vfe_cmd_fov_crop_config fov; - if (copy_from_user(&fov, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_fov_crop_config(&fov); - } - break; - - case VFE_CMD_ID_MAIN_SCALER_CONFIG: - case VFE_CMD_ID_MAIN_SCALER_UPDATE: { - struct vfe_cmd_main_scaler_config mainds; - if (copy_from_user(&mainds, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_main_scaler_config(&mainds); - } - break; - - case VFE_CMD_ID_WHITE_BALANCE_CONFIG: - case VFE_CMD_ID_WHITE_BALANCE_UPDATE: { - struct vfe_cmd_white_balance_config wb; - if (copy_from_user(&wb, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_white_balance_config(&wb); - } - break; - - case VFE_CMD_ID_COLOR_CORRECTION_CONFIG: - case VFE_CMD_ID_COLOR_CORRECTION_UPDATE: { - struct vfe_cmd_color_correction_config cc; - if (copy_from_user(&cc, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_color_correction_config(&cc); - } - break; - - case VFE_CMD_ID_LA_CONFIG: { - struct vfe_cmd_la_config la; - if (copy_from_user(&la, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_la_config(&la); - } - break; - - case VFE_CMD_ID_RGB_GAMMA_CONFIG: { - struct vfe_cmd_rgb_gamma_config rgb; - if (copy_from_user(&rgb, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - rc = vfe_rgb_gamma_config(&rgb); - } - break; - - case VFE_CMD_ID_CHROMA_ENHAN_CONFIG: - case VFE_CMD_ID_CHROMA_ENHAN_UPDATE: { - struct vfe_cmd_chroma_enhan_config chrom; - if (copy_from_user(&chrom, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_chroma_enhan_config(&chrom); - } - break; - - case VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG: - case VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE: { - struct vfe_cmd_chroma_suppression_config chromsup; - if (copy_from_user(&chromsup, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_chroma_sup_config(&chromsup); - } - break; - - case VFE_CMD_ID_ASF_CONFIG: { - struct vfe_cmd_asf_config asf; - if (copy_from_user(&asf, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_asf_config(&asf); - } - break; - - case VFE_CMD_ID_SCALER2Y_CONFIG: - case VFE_CMD_ID_SCALER2Y_UPDATE: { - struct vfe_cmd_scaler2_config ds2y; - if (copy_from_user(&ds2y, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_scaler2y_config(&ds2y); - } - break; - - case VFE_CMD_ID_SCALER2CbCr_CONFIG: - case VFE_CMD_ID_SCALER2CbCr_UPDATE: { - struct vfe_cmd_scaler2_config ds2cbcr; - if (copy_from_user(&ds2cbcr, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_scaler2cbcr_config(&ds2cbcr); - } - break; - - case VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG: { - struct vfe_cmd_chroma_subsample_config sub; - if (copy_from_user(&sub, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_chroma_subsample_config(&sub); - } - break; - - case VFE_CMD_ID_FRAME_SKIP_CONFIG: { - struct vfe_cmd_frame_skip_config fskip; - if (copy_from_user(&fskip, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_frame_skip_config(&fskip); - } - break; - - case VFE_CMD_ID_OUTPUT_CLAMP_CONFIG: { - struct vfe_cmd_output_clamp_config clamp; - if (copy_from_user(&clamp, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_output_clamp_config(&clamp); - } - break; - - /* module update commands */ - case VFE_CMD_ID_BLACK_LEVEL_UPDATE: { - struct vfe_cmd_black_level_config blk; - if (copy_from_user(&blk, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_black_level_update(&blk); - } - break; - - case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE: { - struct vfe_cmd_demux_channel_gain_config dmu; - if (copy_from_user(&dmu, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_demux_channel_gain_update(&dmu); - } - break; - - case VFE_CMD_ID_DEMOSAIC_BPC_UPDATE: { - struct vfe_cmd_demosaic_bpc_update demo_bpc; - if (copy_from_user(&demo_bpc, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_demosaic_bpc_update(&demo_bpc); - } - break; - - case VFE_CMD_ID_DEMOSAIC_ABF_UPDATE: { - struct vfe_cmd_demosaic_abf_update demo_abf; - if (copy_from_user(&demo_abf, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_demosaic_abf_update(&demo_abf); - } - break; - - case VFE_CMD_ID_LA_UPDATE: { - struct vfe_cmd_la_config la; - if (copy_from_user(&la, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_la_update(&la); - } - break; - - case VFE_CMD_ID_RGB_GAMMA_UPDATE: { - struct vfe_cmd_rgb_gamma_config rgb; - if (copy_from_user(&rgb, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - rc = vfe_rgb_gamma_update(&rgb); - } - break; - - case VFE_CMD_ID_ASF_UPDATE: { - struct vfe_cmd_asf_update asf; - if (copy_from_user(&asf, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_asf_update(&asf); - } - break; - - case VFE_CMD_ID_FRAME_SKIP_UPDATE: { - struct vfe_cmd_frame_skip_update fskip; - if (copy_from_user(&fskip, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_frame_skip_update(&fskip); - } - break; - - case VFE_CMD_ID_CAMIF_FRAME_UPDATE: { - struct vfe_cmds_camif_frame fup; - if (copy_from_user(&fup, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_camif_frame_update(&fup); - } - break; - - /* stats update commands */ - case VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE: { - struct vfe_cmd_stats_af_update afup; - if (copy_from_user(&afup, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_stats_update_af(&afup); - } - break; - - case VFE_CMD_ID_STATS_WB_EXP_UPDATE: { - struct vfe_cmd_stats_wb_exp_update wbexp; - if (copy_from_user(&wbexp, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_stats_update_wb_exp(&wbexp); - } - break; - - /* control of start, stop, update, etc... */ - case VFE_CMD_ID_STOP: - vfe_stop(); - break; - - case VFE_CMD_ID_GET_HW_VERSION: - break; - - /* stats */ - case VFE_CMD_ID_STATS_SETTING: { - struct vfe_cmd_stats_setting stats; - if (copy_from_user(&stats, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_stats_setting(&stats); - } - break; - - case VFE_CMD_ID_STATS_AUTOFOCUS_START: { - struct vfe_cmd_stats_af_start af; - if (copy_from_user(&af, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_stats_start_af(&af); - } - break; - - case VFE_CMD_ID_STATS_AUTOFOCUS_STOP: - vfe_stats_af_stop(); - break; - - case VFE_CMD_ID_STATS_WB_EXP_START: { - struct vfe_cmd_stats_wb_exp_start awexp; - if (copy_from_user(&awexp, - (void __user *) cmd->value, cmd->length)) - rc = -EFAULT; - - vfe_stats_start_wb_exp(&awexp); - } - break; - - case VFE_CMD_ID_STATS_WB_EXP_STOP: - vfe_stats_wb_exp_stop(); - break; - - case VFE_CMD_ID_ASYNC_TIMER_SETTING: - break; - - case VFE_CMD_ID_UPDATE: - vfe_update(); - break; - - /* test gen */ - case VFE_CMD_ID_TEST_GEN_START: - break; - -/* - acknowledge from upper layer - these are not in general command. - - case VFE_CMD_ID_OUTPUT1_ACK: - break; - case VFE_CMD_ID_OUTPUT2_ACK: - break; - case VFE_CMD_ID_EPOCH1_ACK: - break; - case VFE_CMD_ID_EPOCH2_ACK: - break; - case VFE_CMD_ID_STATS_AUTOFOCUS_ACK: - break; - case VFE_CMD_ID_STATS_WB_EXP_ACK: - break; -*/ - - default: - break; - } /* switch */ - - return rc; -} - -static int vfe_config(struct msm_vfe_cfg_cmd *cmd, void *data) -{ - struct msm_pmem_region *regptr; - struct msm_vfe_command_8k vfecmd; - - uint32_t i; - - void *cmd_data = NULL; - long rc = 0; - - struct vfe_cmd_axi_output_config *axio = NULL; - struct vfe_cmd_stats_setting *scfg = NULL; - - if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE && - cmd->cmd_type != CMD_STATS_BUF_RELEASE) { - - if (copy_from_user(&vfecmd, - (void __user *)(cmd->value), - sizeof(struct msm_vfe_command_8k))) - return -EFAULT; - } - - CDBG("vfe_config: cmdType = %d\n", cmd->cmd_type); - - switch (cmd->cmd_type) { - case CMD_GENERAL: - rc = vfe_proc_general(&vfecmd); - break; - - case CMD_STATS_ENABLE: - case CMD_STATS_AXI_CFG: { - struct axidata *axid; - - axid = data; - if (!axid) - return -EFAULT; - - scfg = - kmalloc(sizeof(struct vfe_cmd_stats_setting), - GFP_ATOMIC); - if (!scfg) - return -ENOMEM; - - if (copy_from_user(scfg, - (void __user *)(vfecmd.value), - vfecmd.length)) { - - kfree(scfg); - return -EFAULT; - } - - regptr = axid->region; - if (axid->bufnum1 > 0) { - for (i = 0; i < axid->bufnum1; i++) { - scfg->awbBuffer[i] = - (uint32_t)(regptr->paddr); - regptr++; - } - } - - if (axid->bufnum2 > 0) { - for (i = 0; i < axid->bufnum2; i++) { - scfg->afBuffer[i] = - (uint32_t)(regptr->paddr); - regptr++; - } - } - - vfe_stats_config(scfg); - } - break; - - case CMD_STATS_AF_AXI_CFG: { - } - break; - - case CMD_FRAME_BUF_RELEASE: { - /* preview buffer release */ - struct msm_frame *b; - unsigned long p; - struct vfe_cmd_output_ack fack; - - if (!data) - return -EFAULT; - - b = (struct msm_frame *)(cmd->value); - p = *(unsigned long *)data; - - b->path = MSM_FRAME_ENC; - - fack.ybufaddr[0] = - (uint32_t)(p + b->y_off); - - fack.chromabufaddr[0] = - (uint32_t)(p + b->cbcr_off); - - if (b->path == MSM_FRAME_PREV_1) - vfe_output1_ack(&fack); - - if (b->path == MSM_FRAME_ENC || - b->path == MSM_FRAME_PREV_2) - vfe_output2_ack(&fack); - } - break; - - case CMD_SNAP_BUF_RELEASE: { - } - break; - - case CMD_STATS_BUF_RELEASE: { - struct vfe_cmd_stats_wb_exp_ack sack; - - if (!data) - return -EFAULT; - - sack.nextWbExpOutputBufferAddr = *(uint32_t *)data; - vfe_stats_wb_exp_ack(&sack); - } - break; - - case CMD_AXI_CFG_OUT1: { - struct axidata *axid; - - axid = data; - if (!axid) - return -EFAULT; - - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } - - vfe_config_axi(OUTPUT_1, axid, axio); - vfe_axi_output_config(axio); - } - break; - - case CMD_AXI_CFG_OUT2: - case CMD_RAW_PICT_AXI_CFG: { - struct axidata *axid; - - axid = data; - if (!axid) - return -EFAULT; - - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } - - vfe_config_axi(OUTPUT_2, axid, axio); - - axio->outputDataSize = 0; - vfe_axi_output_config(axio); - } - break; - - case CMD_AXI_CFG_SNAP_O1_AND_O2: { - struct axidata *axid; - axid = data; - if (!axid) - return -EFAULT; - - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } - - vfe_config_axi(OUTPUT_1_AND_2, - axid, axio); - vfe_axi_output_config(axio); - cmd_data = axio; - } - break; - - default: - break; - } /* switch */ - - kfree(scfg); - - kfree(axio); - -/* - if (cmd->length > 256 && - cmd_data && - (cmd->cmd_type == CMD_GENERAL || - cmd->cmd_type == CMD_STATS_DISABLE)) { - kfree(cmd_data); - } -*/ - return rc; -} - -static int vfe_init(struct msm_vfe_callback *presp, - struct platform_device *dev) -{ - int rc = 0; - - rc = vfe_cmd_init(presp, dev, vfe_syncdata); - if (rc < 0) - return rc; - - /* Bring up all the required GPIOs and Clocks */ - return msm_camio_enable(dev); -} - -void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data) -{ - mutex_init(&vfe_lock); - fptr->vfe_init = vfe_init; - fptr->vfe_enable = vfe_enable; - fptr->vfe_config = vfe_config; - fptr->vfe_disable = vfe_disable; - fptr->vfe_release = vfe_release; - vfe_syncdata = data; -} diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x.h linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x.h --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x.h 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,895 +0,0 @@ -/* - * Copyright (C) 2008-2009 QUALCOMM Incorporated. - */ -#ifndef __MSM_VFE8X_H__ -#define __MSM_VFE8X_H__ - -#define TRUE 1 -#define FALSE 0 -#define boolean uint8_t - -enum VFE_STATE { - VFE_STATE_IDLE, - VFE_STATE_ACTIVE -}; - -enum vfe_cmd_id { - /* - *Important! Command_ID are arranged in order. - *Don't change!*/ - VFE_CMD_ID_START, - VFE_CMD_ID_RESET, - - /* bus and camif config */ - VFE_CMD_ID_AXI_INPUT_CONFIG, - VFE_CMD_ID_CAMIF_CONFIG, - VFE_CMD_ID_AXI_OUTPUT_CONFIG, - - /* module config */ - VFE_CMD_ID_BLACK_LEVEL_CONFIG, - VFE_CMD_ID_ROLL_OFF_CONFIG, - VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG, - VFE_CMD_ID_DEMOSAIC_CONFIG, - VFE_CMD_ID_FOV_CROP_CONFIG, - VFE_CMD_ID_MAIN_SCALER_CONFIG, - VFE_CMD_ID_WHITE_BALANCE_CONFIG, - VFE_CMD_ID_COLOR_CORRECTION_CONFIG, - VFE_CMD_ID_LA_CONFIG, - VFE_CMD_ID_RGB_GAMMA_CONFIG, - VFE_CMD_ID_CHROMA_ENHAN_CONFIG, - VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG, - VFE_CMD_ID_ASF_CONFIG, - VFE_CMD_ID_SCALER2Y_CONFIG, - VFE_CMD_ID_SCALER2CbCr_CONFIG, - VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG, - VFE_CMD_ID_FRAME_SKIP_CONFIG, - VFE_CMD_ID_OUTPUT_CLAMP_CONFIG, - - /* test gen */ - VFE_CMD_ID_TEST_GEN_START, - - VFE_CMD_ID_UPDATE, - - /* ackownledge from upper layer */ - VFE_CMD_ID_OUTPUT1_ACK, - VFE_CMD_ID_OUTPUT2_ACK, - VFE_CMD_ID_EPOCH1_ACK, - VFE_CMD_ID_EPOCH2_ACK, - VFE_CMD_ID_STATS_AUTOFOCUS_ACK, - VFE_CMD_ID_STATS_WB_EXP_ACK, - - /* module update commands */ - VFE_CMD_ID_BLACK_LEVEL_UPDATE, - VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE, - VFE_CMD_ID_DEMOSAIC_BPC_UPDATE, - VFE_CMD_ID_DEMOSAIC_ABF_UPDATE, - VFE_CMD_ID_FOV_CROP_UPDATE, - VFE_CMD_ID_WHITE_BALANCE_UPDATE, - VFE_CMD_ID_COLOR_CORRECTION_UPDATE, - VFE_CMD_ID_LA_UPDATE, - VFE_CMD_ID_RGB_GAMMA_UPDATE, - VFE_CMD_ID_CHROMA_ENHAN_UPDATE, - VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE, - VFE_CMD_ID_MAIN_SCALER_UPDATE, - VFE_CMD_ID_SCALER2CbCr_UPDATE, - VFE_CMD_ID_SCALER2Y_UPDATE, - VFE_CMD_ID_ASF_UPDATE, - VFE_CMD_ID_FRAME_SKIP_UPDATE, - VFE_CMD_ID_CAMIF_FRAME_UPDATE, - - /* stats update commands */ - VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE, - VFE_CMD_ID_STATS_WB_EXP_UPDATE, - - /* control of start, stop, update, etc... */ - VFE_CMD_ID_STOP, - VFE_CMD_ID_GET_HW_VERSION, - - /* stats */ - VFE_CMD_ID_STATS_SETTING, - VFE_CMD_ID_STATS_AUTOFOCUS_START, - VFE_CMD_ID_STATS_AUTOFOCUS_STOP, - VFE_CMD_ID_STATS_WB_EXP_START, - VFE_CMD_ID_STATS_WB_EXP_STOP, - - VFE_CMD_ID_ASYNC_TIMER_SETTING, - - /* max id */ - VFE_CMD_ID_MAX -}; - -struct vfe_cmd_hw_version { - uint32_t minorVersion; - uint32_t majorVersion; - uint32_t coreVersion; -}; - -enum VFE_CAMIF_SYNC_EDGE { - VFE_CAMIF_SYNC_EDGE_ActiveHigh, - VFE_CAMIF_SYNC_EDGE_ActiveLow -}; - -enum VFE_CAMIF_SYNC_MODE { - VFE_CAMIF_SYNC_MODE_APS, - VFE_CAMIF_SYNC_MODE_EFS, - VFE_CAMIF_SYNC_MODE_ELS, - VFE_CAMIF_SYNC_MODE_ILLEGAL -}; - -struct vfe_cmds_camif_efs { - uint8_t efsendofline; - uint8_t efsstartofline; - uint8_t efsendofframe; - uint8_t efsstartofframe; -}; - -struct vfe_cmds_camif_frame { - uint16_t pixelsPerLine; - uint16_t linesPerFrame; -}; - -struct vfe_cmds_camif_window { - uint16_t firstpixel; - uint16_t lastpixel; - uint16_t firstline; - uint16_t lastline; -}; - -enum CAMIF_SUBSAMPLE_FRAME_SKIP { - CAMIF_SUBSAMPLE_FRAME_SKIP_0, - CAMIF_SUBSAMPLE_FRAME_SKIP_AllFrames, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_2Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_3Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_4Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_5Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_6Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_7Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_8Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_9Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_10Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_11Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_12Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_13Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_14Frame, - CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_15Frame -}; - -struct vfe_cmds_camif_subsample { - uint16_t pixelskipmask; - uint16_t lineskipmask; - enum CAMIF_SUBSAMPLE_FRAME_SKIP frameskip; - uint8_t frameskipmode; - uint8_t pixelskipwrap; -}; - -struct vfe_cmds_camif_epoch { - uint8_t enable; - uint16_t lineindex; -}; - -struct vfe_cmds_camif_cfg { - enum VFE_CAMIF_SYNC_EDGE vSyncEdge; - enum VFE_CAMIF_SYNC_EDGE hSyncEdge; - enum VFE_CAMIF_SYNC_MODE syncMode; - uint8_t vfeSubSampleEnable; - uint8_t busSubSampleEnable; - uint8_t irqSubSampleEnable; - uint8_t binningEnable; - uint8_t misrEnable; -}; - -struct vfe_cmd_camif_config { - struct vfe_cmds_camif_cfg camifConfig; - struct vfe_cmds_camif_efs EFS; - struct vfe_cmds_camif_frame frame; - struct vfe_cmds_camif_window window; - struct vfe_cmds_camif_subsample subsample; - struct vfe_cmds_camif_epoch epoch1; - struct vfe_cmds_camif_epoch epoch2; -}; - -enum VFE_AXI_OUTPUT_MODE { - VFE_AXI_OUTPUT_MODE_Output1, - VFE_AXI_OUTPUT_MODE_Output2, - VFE_AXI_OUTPUT_MODE_Output1AndOutput2, - VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2, - VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1, - VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2, - VFE_AXI_LAST_OUTPUT_MODE_ENUM -}; - -enum VFE_RAW_WR_PATH_SEL { - VFE_RAW_OUTPUT_DISABLED, - VFE_RAW_OUTPUT_ENC_CBCR_PATH, - VFE_RAW_OUTPUT_VIEW_CBCR_PATH, - VFE_RAW_OUTPUT_PATH_INVALID -}; - -enum VFE_RAW_PIXEL_DATA_SIZE { - VFE_RAW_PIXEL_DATA_SIZE_8BIT, - VFE_RAW_PIXEL_DATA_SIZE_10BIT, - VFE_RAW_PIXEL_DATA_SIZE_12BIT, -}; - -#define VFE_AXI_OUTPUT_BURST_LENGTH 4 -#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4 -#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT 3 - -struct vfe_cmds_axi_out_per_component { - uint16_t imageWidth; - uint16_t imageHeight; - uint16_t outRowCount; - uint16_t outRowIncrement; - uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT] - [VFE_MAX_NUM_FRAGMENTS_PER_FRAME]; -}; - -struct vfe_cmds_axi_per_output_path { - uint8_t fragmentCount; - struct vfe_cmds_axi_out_per_component outputY; - struct vfe_cmds_axi_out_per_component outputCbcr; -}; - -enum VFE_AXI_BURST_LENGTH { - VFE_AXI_BURST_LENGTH_IS_2 = 2, - VFE_AXI_BURST_LENGTH_IS_4 = 4, - VFE_AXI_BURST_LENGTH_IS_8 = 8, - VFE_AXI_BURST_LENGTH_IS_16 = 16 -}; - -struct vfe_cmd_axi_output_config { - enum VFE_AXI_BURST_LENGTH burstLength; - enum VFE_AXI_OUTPUT_MODE outputMode; - enum VFE_RAW_PIXEL_DATA_SIZE outputDataSize; - struct vfe_cmds_axi_per_output_path output1; - struct vfe_cmds_axi_per_output_path output2; -}; - -struct vfe_cmd_fov_crop_config { - uint8_t enable; - uint16_t firstPixel; - uint16_t lastPixel; - uint16_t firstLine; - uint16_t lastLine; -}; - -struct vfe_cmds_main_scaler_stripe_init { - uint16_t MNCounterInit; - uint16_t phaseInit; -}; - -struct vfe_cmds_scaler_one_dimension { - uint8_t enable; - uint16_t inputSize; - uint16_t outputSize; - uint32_t phaseMultiplicationFactor; - uint8_t interpolationResolution; -}; - -struct vfe_cmd_main_scaler_config { - uint8_t enable; - struct vfe_cmds_scaler_one_dimension hconfig; - struct vfe_cmds_scaler_one_dimension vconfig; - struct vfe_cmds_main_scaler_stripe_init MNInitH; - struct vfe_cmds_main_scaler_stripe_init MNInitV; -}; - -struct vfe_cmd_scaler2_config { - uint8_t enable; - struct vfe_cmds_scaler_one_dimension hconfig; - struct vfe_cmds_scaler_one_dimension vconfig; -}; - -struct vfe_cmd_frame_skip_config { - uint8_t output1Period; - uint32_t output1Pattern; - uint8_t output2Period; - uint32_t output2Pattern; -}; - -struct vfe_cmd_frame_skip_update { - uint32_t output1Pattern; - uint32_t output2Pattern; -}; - -struct vfe_cmd_output_clamp_config { - uint8_t minCh0; - uint8_t minCh1; - uint8_t minCh2; - uint8_t maxCh0; - uint8_t maxCh1; - uint8_t maxCh2; -}; - -struct vfe_cmd_chroma_subsample_config { - uint8_t enable; - uint8_t cropEnable; - uint8_t vsubSampleEnable; - uint8_t hsubSampleEnable; - uint8_t vCosited; - uint8_t hCosited; - uint8_t vCositedPhase; - uint8_t hCositedPhase; - uint16_t cropWidthFirstPixel; - uint16_t cropWidthLastPixel; - uint16_t cropHeightFirstLine; - uint16_t cropHeightLastLine; -}; - -enum VFE_START_INPUT_SOURCE { - VFE_START_INPUT_SOURCE_CAMIF, - VFE_START_INPUT_SOURCE_TESTGEN, - VFE_START_INPUT_SOURCE_AXI, - VFE_START_INPUT_SOURCE_INVALID -}; - -enum VFE_START_OPERATION_MODE { - VFE_START_OPERATION_MODE_CONTINUOUS, - VFE_START_OPERATION_MODE_SNAPSHOT -}; - -enum VFE_START_PIXEL_PATTERN { - VFE_BAYER_RGRGRG, - VFE_BAYER_GRGRGR, - VFE_BAYER_BGBGBG, - VFE_BAYER_GBGBGB, - VFE_YUV_YCbYCr, - VFE_YUV_YCrYCb, - VFE_YUV_CbYCrY, - VFE_YUV_CrYCbY -}; - -enum VFE_BUS_RD_INPUT_PIXEL_PATTERN { - VFE_BAYER_RAW, - VFE_YUV_INTERLEAVED, - VFE_YUV_PSEUDO_PLANAR_Y, - VFE_YUV_PSEUDO_PLANAR_CBCR -}; - -enum VFE_YUV_INPUT_COSITING_MODE { - VFE_YUV_COSITED, - VFE_YUV_INTERPOLATED -}; - -struct vfe_cmd_start { - enum VFE_START_INPUT_SOURCE inputSource; - enum VFE_START_OPERATION_MODE operationMode; - uint8_t snapshotCount; - enum VFE_START_PIXEL_PATTERN pixel; - enum VFE_YUV_INPUT_COSITING_MODE yuvInputCositingMode; -}; - -struct vfe_cmd_output_ack { - uint32_t ybufaddr[VFE_MAX_NUM_FRAGMENTS_PER_FRAME]; - uint32_t chromabufaddr[VFE_MAX_NUM_FRAGMENTS_PER_FRAME]; -}; - -#define VFE_STATS_BUFFER_COUNT 3 - -struct vfe_cmd_stats_setting { - uint16_t frameHDimension; - uint16_t frameVDimension; - uint8_t afBusPrioritySelection; - uint8_t afBusPriority; - uint8_t awbBusPrioritySelection; - uint8_t awbBusPriority; - uint8_t histBusPrioritySelection; - uint8_t histBusPriority; - uint32_t afBuffer[VFE_STATS_BUFFER_COUNT]; - uint32_t awbBuffer[VFE_STATS_BUFFER_COUNT]; - uint32_t histBuffer[VFE_STATS_BUFFER_COUNT]; -}; - -struct vfe_cmd_stats_af_start { - uint8_t enable; - uint8_t windowMode; - uint16_t windowHOffset; - uint16_t windowVOffset; - uint16_t windowWidth; - uint16_t windowHeight; - uint8_t gridForMultiWindows[16]; - uint8_t metricSelection; - int16_t metricMax; - int8_t highPassCoef[7]; - int8_t bufferHeader; -}; - -struct vfe_cmd_stats_af_update { - uint8_t windowMode; - uint16_t windowHOffset; - uint16_t windowVOffset; - uint16_t windowWidth; - uint16_t windowHeight; -}; - -struct vfe_cmd_stats_wb_exp_start { - uint8_t enable; - uint8_t wbExpRegions; - uint8_t wbExpSubRegion; - uint8_t awbYMin; - uint8_t awbYMax; - int8_t awbMCFG[4]; - int16_t awbCCFG[4]; - int8_t axwHeader; -}; - -struct vfe_cmd_stats_wb_exp_update { - uint8_t wbExpRegions; - uint8_t wbExpSubRegion; - int8_t awbYMin; - int8_t awbYMax; - int8_t awbMCFG[4]; - int16_t awbCCFG[4]; -}; - -struct vfe_cmd_stats_af_ack { - uint32_t nextAFOutputBufferAddr; -}; - -struct vfe_cmd_stats_wb_exp_ack { - uint32_t nextWbExpOutputBufferAddr; -}; - -struct vfe_cmd_black_level_config { - uint8_t enable; - uint16_t evenEvenAdjustment; - uint16_t evenOddAdjustment; - uint16_t oddEvenAdjustment; - uint16_t oddOddAdjustment; -}; - -/* 13*1 */ -#define VFE_ROLL_OFF_INIT_TABLE_SIZE 13 -/* 13*16 */ -#define VFE_ROLL_OFF_DELTA_TABLE_SIZE 208 - -struct vfe_cmd_roll_off_config { - uint8_t enable; - uint16_t gridWidth; - uint16_t gridHeight; - uint16_t yDelta; - uint8_t gridXIndex; - uint8_t gridYIndex; - uint16_t gridPixelXIndex; - uint16_t gridPixelYIndex; - uint16_t yDeltaAccum; - uint16_t initTableR[VFE_ROLL_OFF_INIT_TABLE_SIZE]; - uint16_t initTableGr[VFE_ROLL_OFF_INIT_TABLE_SIZE]; - uint16_t initTableB[VFE_ROLL_OFF_INIT_TABLE_SIZE]; - uint16_t initTableGb[VFE_ROLL_OFF_INIT_TABLE_SIZE]; - int16_t deltaTableR[VFE_ROLL_OFF_DELTA_TABLE_SIZE]; - int16_t deltaTableGr[VFE_ROLL_OFF_DELTA_TABLE_SIZE]; - int16_t deltaTableB[VFE_ROLL_OFF_DELTA_TABLE_SIZE]; - int16_t deltaTableGb[VFE_ROLL_OFF_DELTA_TABLE_SIZE]; -}; - -struct vfe_cmd_demux_channel_gain_config { - uint16_t ch0EvenGain; - uint16_t ch0OddGain; - uint16_t ch1Gain; - uint16_t ch2Gain; -}; - -struct vfe_cmds_demosaic_abf { - uint8_t enable; - uint8_t forceOn; - uint8_t shift; - uint16_t lpThreshold; - uint16_t max; - uint16_t min; - uint8_t ratio; -}; - -struct vfe_cmds_demosaic_bpc { - uint8_t enable; - uint16_t fmaxThreshold; - uint16_t fminThreshold; - uint16_t redDiffThreshold; - uint16_t blueDiffThreshold; - uint16_t greenDiffThreshold; -}; - -struct vfe_cmd_demosaic_config { - uint8_t enable; - uint8_t slopeShift; - struct vfe_cmds_demosaic_abf abfConfig; - struct vfe_cmds_demosaic_bpc bpcConfig; -}; - -struct vfe_cmd_demosaic_bpc_update { - struct vfe_cmds_demosaic_bpc bpcUpdate; -}; - -struct vfe_cmd_demosaic_abf_update { - struct vfe_cmds_demosaic_abf abfUpdate; -}; - -struct vfe_cmd_white_balance_config { - uint8_t enable; - uint16_t ch2Gain; - uint16_t ch1Gain; - uint16_t ch0Gain; -}; - -enum VFE_COLOR_CORRECTION_COEF_QFACTOR { - COEF_IS_Q7_SIGNED, - COEF_IS_Q8_SIGNED, - COEF_IS_Q9_SIGNED, - COEF_IS_Q10_SIGNED -}; - -struct vfe_cmd_color_correction_config { - uint8_t enable; - enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor; - int16_t C0; - int16_t C1; - int16_t C2; - int16_t C3; - int16_t C4; - int16_t C5; - int16_t C6; - int16_t C7; - int16_t C8; - int16_t K0; - int16_t K1; - int16_t K2; -}; - -#define VFE_LA_TABLE_LENGTH 256 -struct vfe_cmd_la_config { - uint8_t enable; - int16_t table[VFE_LA_TABLE_LENGTH]; -}; - -#define VFE_GAMMA_TABLE_LENGTH 256 -enum VFE_RGB_GAMMA_TABLE_SELECT { - RGB_GAMMA_CH0_SELECTED, - RGB_GAMMA_CH1_SELECTED, - RGB_GAMMA_CH2_SELECTED, - RGB_GAMMA_CH0_CH1_SELECTED, - RGB_GAMMA_CH0_CH2_SELECTED, - RGB_GAMMA_CH1_CH2_SELECTED, - RGB_GAMMA_CH0_CH1_CH2_SELECTED -}; - -struct vfe_cmd_rgb_gamma_config { - uint8_t enable; - enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect; - int16_t table[VFE_GAMMA_TABLE_LENGTH]; -}; - -struct vfe_cmd_chroma_enhan_config { - uint8_t enable; - int16_t am; - int16_t ap; - int16_t bm; - int16_t bp; - int16_t cm; - int16_t cp; - int16_t dm; - int16_t dp; - int16_t kcr; - int16_t kcb; - int16_t RGBtoYConversionV0; - int16_t RGBtoYConversionV1; - int16_t RGBtoYConversionV2; - uint8_t RGBtoYConversionOffset; -}; - -struct vfe_cmd_chroma_suppression_config { - uint8_t enable; - uint8_t m1; - uint8_t m3; - uint8_t n1; - uint8_t n3; - uint8_t nn1; - uint8_t mm1; -}; - -struct vfe_cmd_asf_config { - uint8_t enable; - uint8_t smoothFilterEnabled; - uint8_t sharpMode; - uint8_t smoothCoefCenter; - uint8_t smoothCoefSurr; - uint8_t normalizeFactor; - uint8_t sharpK1; - uint8_t sharpK2; - uint8_t sharpThreshE1; - int8_t sharpThreshE2; - int8_t sharpThreshE3; - int8_t sharpThreshE4; - int8_t sharpThreshE5; - int8_t filter1Coefficients[9]; - int8_t filter2Coefficients[9]; - uint8_t cropEnable; - uint16_t cropFirstPixel; - uint16_t cropLastPixel; - uint16_t cropFirstLine; - uint16_t cropLastLine; -}; - -struct vfe_cmd_asf_update { - uint8_t enable; - uint8_t smoothFilterEnabled; - uint8_t sharpMode; - uint8_t smoothCoefCenter; - uint8_t smoothCoefSurr; - uint8_t normalizeFactor; - uint8_t sharpK1; - uint8_t sharpK2; - uint8_t sharpThreshE1; - int8_t sharpThreshE2; - int8_t sharpThreshE3; - int8_t sharpThreshE4; - int8_t sharpThreshE5; - int8_t filter1Coefficients[9]; - int8_t filter2Coefficients[9]; - uint8_t cropEnable; -}; - -enum VFE_TEST_GEN_SYNC_EDGE { - VFE_TEST_GEN_SYNC_EDGE_ActiveHigh, - VFE_TEST_GEN_SYNC_EDGE_ActiveLow -}; - -struct vfe_cmd_test_gen_start { - uint8_t pixelDataSelect; - uint8_t systematicDataSelect; - enum VFE_TEST_GEN_SYNC_EDGE hsyncEdge; - enum VFE_TEST_GEN_SYNC_EDGE vsyncEdge; - uint16_t numFrame; - enum VFE_RAW_PIXEL_DATA_SIZE pixelDataSize; - uint16_t imageWidth; - uint16_t imageHeight; - uint32_t startOfFrameOffset; - uint32_t endOfFrameNOffset; - uint16_t startOfLineOffset; - uint16_t endOfLineNOffset; - uint16_t hbi; - uint8_t vblEnable; - uint16_t vbl; - uint8_t startOfFrameDummyLine; - uint8_t endOfFrameDummyLine; - uint8_t unicolorBarEnable; - uint8_t colorBarsSplitEnable; - uint8_t unicolorBarSelect; - enum VFE_START_PIXEL_PATTERN colorBarsPixelPattern; - uint8_t colorBarsRotatePeriod; - uint16_t testGenRandomSeed; -}; - -struct vfe_cmd_bus_pm_start { - uint8_t output2YWrPmEnable; - uint8_t output2CbcrWrPmEnable; - uint8_t output1YWrPmEnable; - uint8_t output1CbcrWrPmEnable; -}; - -struct vfe_cmd_camif_frame_update { - struct vfe_cmds_camif_frame camifFrame; -}; - -struct vfe_cmd_sync_timer_setting { - uint8_t whichSyncTimer; - uint8_t operation; - uint8_t polarity; - uint16_t repeatCount; - uint16_t hsyncCount; - uint32_t pclkCount; - uint32_t outputDuration; -}; - -struct vfe_cmd_async_timer_setting { - uint8_t whichAsyncTimer; - uint8_t operation; - uint8_t polarity; - uint16_t repeatCount; - uint16_t inactiveCount; - uint32_t activeCount; -}; - -struct vfe_frame_skip_counts { - uint32_t totalFrameCount; - uint32_t output1Count; - uint32_t output2Count; -}; - -enum VFE_AXI_RD_UNPACK_HBI_SEL { - VFE_AXI_RD_HBI_32_CLOCK_CYCLES, - VFE_AXI_RD_HBI_64_CLOCK_CYCLES, - VFE_AXI_RD_HBI_128_CLOCK_CYCLES, - VFE_AXI_RD_HBI_256_CLOCK_CYCLES, - VFE_AXI_RD_HBI_512_CLOCK_CYCLES, - VFE_AXI_RD_HBI_1024_CLOCK_CYCLES, - VFE_AXI_RD_HBI_2048_CLOCK_CYCLES, - VFE_AXI_RD_HBI_4096_CLOCK_CYCLES -}; - -struct vfe_cmd_axi_input_config { - uint32_t fragAddr[4]; - uint8_t totalFragmentCount; - uint16_t ySize; - uint16_t xOffset; - uint16_t xSize; - uint16_t rowIncrement; - uint16_t numOfRows; - enum VFE_AXI_BURST_LENGTH burstLength; - uint8_t unpackPhase; - enum VFE_AXI_RD_UNPACK_HBI_SEL unpackHbi; - enum VFE_RAW_PIXEL_DATA_SIZE pixelSize; - uint8_t padRepeatCountLeft; - uint8_t padRepeatCountRight; - uint8_t padRepeatCountTop; - uint8_t padRepeatCountBottom; - uint8_t padLeftComponentSelectCycle0; - uint8_t padLeftComponentSelectCycle1; - uint8_t padLeftComponentSelectCycle2; - uint8_t padLeftComponentSelectCycle3; - uint8_t padLeftStopCycle0; - uint8_t padLeftStopCycle1; - uint8_t padLeftStopCycle2; - uint8_t padLeftStopCycle3; - uint8_t padRightComponentSelectCycle0; - uint8_t padRightComponentSelectCycle1; - uint8_t padRightComponentSelectCycle2; - uint8_t padRightComponentSelectCycle3; - uint8_t padRightStopCycle0; - uint8_t padRightStopCycle1; - uint8_t padRightStopCycle2; - uint8_t padRightStopCycle3; - uint8_t padTopLineCount; - uint8_t padBottomLineCount; -}; - -struct vfe_interrupt_status { - uint8_t camifErrorIrq; - uint8_t camifSofIrq; - uint8_t camifEolIrq; - uint8_t camifEofIrq; - uint8_t camifEpoch1Irq; - uint8_t camifEpoch2Irq; - uint8_t camifOverflowIrq; - uint8_t ceIrq; - uint8_t regUpdateIrq; - uint8_t resetAckIrq; - uint8_t encYPingpongIrq; - uint8_t encCbcrPingpongIrq; - uint8_t viewYPingpongIrq; - uint8_t viewCbcrPingpongIrq; - uint8_t rdPingpongIrq; - uint8_t afPingpongIrq; - uint8_t awbPingpongIrq; - uint8_t histPingpongIrq; - uint8_t encIrq; - uint8_t viewIrq; - uint8_t busOverflowIrq; - uint8_t afOverflowIrq; - uint8_t awbOverflowIrq; - uint8_t syncTimer0Irq; - uint8_t syncTimer1Irq; - uint8_t syncTimer2Irq; - uint8_t asyncTimer0Irq; - uint8_t asyncTimer1Irq; - uint8_t asyncTimer2Irq; - uint8_t asyncTimer3Irq; - uint8_t axiErrorIrq; - uint8_t violationIrq; - uint8_t anyErrorIrqs; - uint8_t anyOutput1PathIrqs; - uint8_t anyOutput2PathIrqs; - uint8_t anyOutputPathIrqs; - uint8_t anyAsyncTimerIrqs; - uint8_t anySyncTimerIrqs; - uint8_t anyIrqForActiveStatesOnly; -}; - -enum VFE_MESSAGE_ID { - VFE_MSG_ID_RESET_ACK, - VFE_MSG_ID_START_ACK, - VFE_MSG_ID_STOP_ACK, - VFE_MSG_ID_UPDATE_ACK, - VFE_MSG_ID_OUTPUT1, - VFE_MSG_ID_OUTPUT2, - VFE_MSG_ID_SNAPSHOT_DONE, - VFE_MSG_ID_STATS_AUTOFOCUS, - VFE_MSG_ID_STATS_WB_EXP, - VFE_MSG_ID_EPOCH1, - VFE_MSG_ID_EPOCH2, - VFE_MSG_ID_SYNC_TIMER0_DONE, - VFE_MSG_ID_SYNC_TIMER1_DONE, - VFE_MSG_ID_SYNC_TIMER2_DONE, - VFE_MSG_ID_ASYNC_TIMER0_DONE, - VFE_MSG_ID_ASYNC_TIMER1_DONE, - VFE_MSG_ID_ASYNC_TIMER2_DONE, - VFE_MSG_ID_ASYNC_TIMER3_DONE, - VFE_MSG_ID_AF_OVERFLOW, - VFE_MSG_ID_AWB_OVERFLOW, - VFE_MSG_ID_AXI_ERROR, - VFE_MSG_ID_CAMIF_OVERFLOW, - VFE_MSG_ID_VIOLATION, - VFE_MSG_ID_CAMIF_ERROR, - VFE_MSG_ID_BUS_OVERFLOW, -}; - -struct vfe_msg_stats_autofocus { - uint32_t afBuffer; - uint32_t frameCounter; -}; - -struct vfe_msg_stats_wb_exp { - uint32_t awbBuffer; - uint32_t frameCounter; -}; - -struct vfe_frame_bpc_info { - uint32_t greenDefectPixelCount; - uint32_t redBlueDefectPixelCount; -}; - -struct vfe_frame_asf_info { - uint32_t asfMaxEdge; - uint32_t asfHbiCount; -}; - -struct vfe_msg_camif_status { - uint8_t camifState; - uint32_t pixelCount; - uint32_t lineCount; -}; - -struct vfe_bus_pm_per_path { - uint32_t yWrPmStats0; - uint32_t yWrPmStats1; - uint32_t cbcrWrPmStats0; - uint32_t cbcrWrPmStats1; -}; - -struct vfe_bus_performance_monitor { - struct vfe_bus_pm_per_path encPathPmInfo; - struct vfe_bus_pm_per_path viewPathPmInfo; -}; - -struct vfe_irq_thread_msg { - uint32_t vfeIrqStatus; - uint32_t camifStatus; - uint32_t demosaicStatus; - uint32_t asfMaxEdge; - struct vfe_bus_performance_monitor pmInfo; -}; - -struct vfe_msg_output { - uint32_t yBuffer; - uint32_t cbcrBuffer; - struct vfe_frame_bpc_info bpcInfo; - struct vfe_frame_asf_info asfInfo; - uint32_t frameCounter; - struct vfe_bus_pm_per_path pmData; -}; - -struct vfe_message { - enum VFE_MESSAGE_ID _d; - union { - struct vfe_msg_output msgOutput1; - struct vfe_msg_output msgOutput2; - struct vfe_msg_stats_autofocus msgStatsAf; - struct vfe_msg_stats_wb_exp msgStatsWbExp; - struct vfe_msg_camif_status msgCamifError; - struct vfe_bus_performance_monitor msgBusOverflow; - } _u; -}; - -/* New one for 8k */ -struct msm_vfe_command_8k { - int32_t id; - uint16_t length; - void *value; -}; - -struct vfe_frame_extra { - struct vfe_frame_bpc_info bpcInfo; - struct vfe_frame_asf_info asfInfo; - uint32_t frameCounter; - struct vfe_bus_pm_per_path pmData; -}; -#endif /* __MSM_VFE8X_H__ */ diff -Naur -X linux-2.6.32-rc6-usb/Documentation/dontdiff linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x_proc.c linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x_proc.c --- linux-2.6.32-rc6-usb/drivers/staging/dream/camera/msm_vfe8x_proc.c 2009-11-04 15:20:36.000000000 -0800 +++ linux-2.6.32-rc6-staging/drivers/staging/dream/camera/msm_vfe8x_proc.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,4003 +0,0 @@ -/* -* Copyright (C) 2008-2009 QUALCOMM Incorporated. -*/ -#include -#include -#include -#include -#include -#include -#include -#include "msm_vfe8x_proc.h" -#include - -struct msm_vfe8x_ctrl { - /* bit 1:0 ENC_IRQ_MASK = 0x11: - * generate IRQ when both y and cbcr frame is ready. */ - - /* bit 1:0 VIEW_IRQ_MASK= 0x11: - * generate IRQ when both y and cbcr frame is ready. */ - struct vfe_irq_composite_mask_config vfeIrqCompositeMaskLocal; - struct vfe_module_enable vfeModuleEnableLocal; - struct vfe_camif_cfg_data vfeCamifConfigLocal; - struct vfe_interrupt_mask vfeImaskLocal; - struct vfe_stats_cmd_data vfeStatsCmdLocal; - struct vfe_bus_cfg_data vfeBusConfigLocal; - struct vfe_cmd_bus_pm_start vfeBusPmConfigLocal; - struct vfe_bus_cmd_data vfeBusCmdLocal; - enum vfe_interrupt_name vfeInterruptNameLocal; - uint32_t vfeLaBankSel; - struct vfe_gamma_lut_sel vfeGammaLutSel; - - boolean vfeStartAckPendingFlag; - boolean vfeStopAckPending; - boolean vfeResetAckPending; - boolean vfeUpdateAckPending; - - enum VFE_AXI_OUTPUT_MODE axiOutputMode; - enum VFE_START_OPERATION_MODE vfeOperationMode; - - uint32_t vfeSnapShotCount; - uint32_t vfeRequestedSnapShotCount; - boolean vfeStatsPingPongReloadFlag; - uint32_t vfeFrameId; - - struct vfe_cmd_frame_skip_config vfeFrameSkip; - uint32_t vfeFrameSkipPattern; - uint8_t vfeFrameSkipCount; - uint8_t vfeFrameSkipPeriod; - - boolean vfeTestGenStartFlag; - uint32_t vfeImaskPacked; - uint32_t vfeImaskCompositePacked; - enum VFE_RAW_PIXEL_DATA_SIZE axiInputDataSize; - struct vfe_irq_thread_msg vfeIrqThreadMsgLocal; - - struct vfe_output_path_combo viewPath; - struct vfe_output_path_combo encPath; - struct vfe_frame_skip_counts vfeDroppedFrameCounts; - struct vfe_stats_control afStatsControl; - struct vfe_stats_control awbStatsControl; - - enum VFE_STATE vstate; - - spinlock_t ack_lock; - spinlock_t state_lock; - spinlock_t io_lock; - - struct msm_vfe_callback *resp; - uint32_t extlen; - void *extdata; - - spinlock_t tasklet_lock; - struct list_head tasklet_q; - - int vfeirq; - void __iomem *vfebase; - - void *syncdata; -}; -static struct msm_vfe8x_ctrl *ctrl; -static irqreturn_t vfe_parse_irq(int irq_num, void *data); - -struct isr_queue_cmd { - struct list_head list; - struct vfe_interrupt_status vfeInterruptStatus; - struct vfe_frame_asf_info vfeAsfFrameInfo; - struct vfe_frame_bpc_info vfeBpcFrameInfo; - struct vfe_msg_camif_status vfeCamifStatusLocal; - struct vfe_bus_performance_monitor vfePmData; -}; - -static void vfe_prog_hw(uint8_t *hwreg, - uint32_t *inptr, uint32_t regcnt) -{ - /* unsigned long flags; */ - uint32_t i; - uint32_t *p; - - /* @todo This is causing issues, need further investigate */ - /* spin_lock_irqsave(&ctrl->io_lock, flags); */ - - p = (uint32_t *)(hwreg); - for (i = 0; i < (regcnt >> 2); i++) - writel(*inptr++, p++); - /* *p++ = *inptr++; */ - - /* spin_unlock_irqrestore(&ctrl->io_lock, flags); */ -} - -static void vfe_read_reg_values(uint8_t *hwreg, - uint32_t *dest, uint32_t count) -{ - /* unsigned long flags; */ - uint32_t *temp; - uint32_t i; - - /* @todo This is causing issues, need further investigate */ - /* spin_lock_irqsave(&ctrl->io_lock, flags); */ - - temp = (uint32_t *)(hwreg); - for (i = 0; i < count; i++) - *dest++ = *temp++; - - /* spin_unlock_irqrestore(&ctrl->io_lock, flags); */ -} - -static struct vfe_irqenable vfe_read_irq_mask(void) -{ - /* unsigned long flags; */ - uint32_t *temp; - struct vfe_irqenable rc; - - memset(&rc, 0, sizeof(rc)); - - /* @todo This is causing issues, need further investigate */ - /* spin_lock_irqsave(&ctrl->io_lock, flags); */ - temp = (uint32_t *)(ctrl->vfebase + VFE_IRQ_MASK); - - rc = *((struct vfe_irqenable *)temp); - /* spin_unlock_irqrestore(&ctrl->io_lock, flags); */ - - return rc; -} - -static void -vfe_set_bus_pipo_addr(struct vfe_output_path_combo *vpath, - struct vfe_output_path_combo *epath) -{ - vpath->yPath.hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_VIEW_Y_WR_PING_ADDR); - vpath->yPath.hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_VIEW_Y_WR_PONG_ADDR); - vpath->cbcrPath.hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_VIEW_CBCR_WR_PING_ADDR); - vpath->cbcrPath.hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_VIEW_CBCR_WR_PONG_ADDR); - - epath->yPath.hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_ENC_Y_WR_PING_ADDR); - epath->yPath.hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_ENC_Y_WR_PONG_ADDR); - epath->cbcrPath.hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_ENC_CBCR_WR_PING_ADDR); - epath->cbcrPath.hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_ENC_CBCR_WR_PONG_ADDR); -} - -static void vfe_axi_output(struct vfe_cmd_axi_output_config *in, - struct vfe_output_path_combo *out1, - struct vfe_output_path_combo *out2, uint16_t out) -{ - struct vfe_axi_out_cfg cmd; - - uint16_t temp; - uint32_t burstLength; - - /* force it to burst length 4, hardware does not support it. */ - burstLength = 1; - - /* AXI Output 2 Y Configuration*/ - /* VFE_BUS_ENC_Y_WR_PING_ADDR */ - cmd.out2YPingAddr = out2->yPath.addressBuffer[0]; - - /* VFE_BUS_ENC_Y_WR_PONG_ADDR */ - cmd.out2YPongAddr = out2->yPath.addressBuffer[1]; - - /* VFE_BUS_ENC_Y_WR_IMAGE_SIZE */ - cmd.out2YImageHeight = in->output2.outputY.imageHeight; - /* convert the image width and row increment to be in - * unit of 64bit (8 bytes) */ - temp = (in->output2.outputY.imageWidth + (out - 1)) / - out; - cmd.out2YImageWidthin64bit = temp; - - /* VFE_BUS_ENC_Y_WR_BUFFER_CFG */ - cmd.out2YBurstLength = burstLength; - cmd.out2YNumRows = in->output2.outputY.outRowCount; - temp = (in->output2.outputY.outRowIncrement + (out - 1)) / - out; - cmd.out2YRowIncrementIn64bit = temp; - - /* AXI Output 2 Cbcr Configuration*/ - /* VFE_BUS_ENC_Cbcr_WR_PING_ADDR */ - cmd.out2CbcrPingAddr = out2->cbcrPath.addressBuffer[0]; - - /* VFE_BUS_ENC_Cbcr_WR_PONG_ADDR */ - cmd.out2CbcrPongAddr = out2->cbcrPath.addressBuffer[1]; - - /* VFE_BUS_ENC_Cbcr_WR_IMAGE_SIZE */ - cmd.out2CbcrImageHeight = in->output2.outputCbcr.imageHeight; - temp = (in->output2.outputCbcr.imageWidth + (out - 1)) / - out; - cmd.out2CbcrImageWidthIn64bit = temp; - - /* VFE_BUS_ENC_Cbcr_WR_BUFFER_CFG */ - cmd.out2CbcrBurstLength = burstLength; - cmd.out2CbcrNumRows = in->output2.outputCbcr.outRowCount; - temp = (in->output2.outputCbcr.outRowIncrement + (out - 1)) / - out; - cmd.out2CbcrRowIncrementIn64bit = temp; - - /* AXI Output 1 Y Configuration */ - /* VFE_BUS_VIEW_Y_WR_PING_ADDR */ - cmd.out1YPingAddr = out1->yPath.addressBuffer[0]; - - /* VFE_BUS_VIEW_Y_WR_PONG_ADDR */ - cmd.out1YPongAddr = out1->yPath.addressBuffer[1]; - - /* VFE_BUS_VIEW_Y_WR_IMAGE_SIZE */ - cmd.out1YImageHeight = in->output1.outputY.imageHeight; - temp = (in->output1.outputY.imageWidth + (out - 1)) / - out; - cmd.out1YImageWidthin64bit = temp; - - /* VFE_BUS_VIEW_Y_WR_BUFFER_CFG */ - cmd.out1YBurstLength = burstLength; - cmd.out1YNumRows = in->output1.outputY.outRowCount; - - temp = - (in->output1.outputY.outRowIncrement + - (out - 1)) / out; - cmd.out1YRowIncrementIn64bit = temp; - - /* AXI Output 1 Cbcr Configuration*/ - cmd.out1CbcrPingAddr = out1->cbcrPath.addressBuffer[0]; - - /* VFE_BUS_VIEW_Cbcr_WR_PONG_ADDR */ - cmd.out1CbcrPongAddr = - out1->cbcrPath.addressBuffer[1]; - - /* VFE_BUS_VIEW_Cbcr_WR_IMAGE_SIZE */ - cmd.out1CbcrImageHeight = in->output1.outputCbcr.imageHeight; - temp = (in->output1.outputCbcr.imageWidth + - (out - 1)) / out; - cmd.out1CbcrImageWidthIn64bit = temp; - - cmd.out1CbcrBurstLength = burstLength; - cmd.out1CbcrNumRows = in->output1.outputCbcr.outRowCount; - temp = - (in->output1.outputCbcr.outRowIncrement + - (out - 1)) / out; - - cmd.out1CbcrRowIncrementIn64bit = temp; - - vfe_prog_hw(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PING_ADDR, - (uint32_t *)&cmd, sizeof(cmd)); -} - -static void vfe_reg_bus_cfg(struct vfe_bus_cfg_data *in) -{ - struct vfe_axi_bus_cfg cmd; - - cmd.stripeRdPathEn = in->stripeRdPathEn; - cmd.encYWrPathEn = in->encYWrPathEn; - cmd.encCbcrWrPathEn = in->encCbcrWrPathEn; - cmd.viewYWrPathEn = in->viewYWrPathEn; - cmd.viewCbcrWrPathEn = in->viewCbcrWrPathEn; - cmd.rawPixelDataSize = (uint32_t)in->rawPixelDataSize; - cmd.rawWritePathSelect = (uint32_t)in->rawWritePathSelect; - - /* program vfe_bus_cfg */ - writel(*((uint32_t *)&cmd), ctrl->vfebase + VFE_BUS_CFG); -} - -static void vfe_reg_camif_config(struct vfe_camif_cfg_data *in) -{ - struct VFE_CAMIFConfigType cfg; - - memset(&cfg, 0, sizeof(cfg)); - - cfg.VSyncEdge = - in->camifCfgFromCmd.vSyncEdge; - - cfg.HSyncEdge = - in->camifCfgFromCmd.hSyncEdge; - - cfg.syncMode = - in->camifCfgFromCmd.syncMode; - - cfg.vfeSubsampleEnable = - in->camifCfgFromCmd.vfeSubSampleEnable; - - cfg.busSubsampleEnable = - in->camifCfgFromCmd.busSubSampleEnable; - - cfg.camif2vfeEnable = - in->camif2OutputEnable; - - cfg.camif2busEnable = - in->camif2BusEnable; - - cfg.irqSubsampleEnable = - in->camifCfgFromCmd.irqSubSampleEnable; - - cfg.binningEnable = - in->camifCfgFromCmd.binningEnable; - - cfg.misrEnable = - in->camifCfgFromCmd.misrEnable; - - /* program camif_config */ - writel(*((uint32_t *)&cfg), ctrl->vfebase + CAMIF_CONFIG); -} - -static void vfe_reg_bus_cmd(struct vfe_bus_cmd_data *in) -{ - struct vfe_buscmd cmd; - memset(&cmd, 0, sizeof(cmd)); - - cmd.stripeReload = in->stripeReload; - cmd.busPingpongReload = in->busPingpongReload; - cmd.statsPingpongReload = in->statsPingpongReload; - - writel(*((uint32_t *)&cmd), ctrl->vfebase + VFE_BUS_CMD); - - CDBG("bus command = 0x%x\n", (*((uint32_t *)&cmd))); - - /* this is needed, as the control bits are pulse based. - * Don't want to reload bus pingpong again. */ - in->busPingpongReload = 0; - in->statsPingpongReload = 0; - in->stripeReload = 0; -} - -static void vfe_reg_module_cfg(struct vfe_module_enable *in) -{ - struct vfe_mod_enable ena; - - memset(&ena, 0, sizeof(ena)); - - ena.blackLevelCorrectionEnable = in->blackLevelCorrectionEnable; - ena.lensRollOffEnable = in->lensRollOffEnable; - ena.demuxEnable = in->demuxEnable; - ena.chromaUpsampleEnable = in->chromaUpsampleEnable; - ena.demosaicEnable = in->demosaicEnable; - ena.statsEnable = in->statsEnable; - ena.cropEnable = in->cropEnable; - ena.mainScalerEnable = in->mainScalerEnable; - ena.whiteBalanceEnable = in->whiteBalanceEnable; - ena.colorCorrectionEnable = in->colorCorrectionEnable; - ena.yHistEnable = in->yHistEnable; - ena.skinToneEnable = in->skinToneEnable; - ena.lumaAdaptationEnable = in->lumaAdaptationEnable; - ena.rgbLUTEnable = in->rgbLUTEnable; - ena.chromaEnhanEnable = in->chromaEnhanEnable; - ena.asfEnable = in->asfEnable; - ena.chromaSuppressionEnable = in->chromaSuppressionEnable; - ena.chromaSubsampleEnable = in->chromaSubsampleEnable; - ena.scaler2YEnable = in->scaler2YEnable; - ena.scaler2CbcrEnable = in->scaler2CbcrEnable; - - writel(*((uint32_t *)&ena), ctrl->vfebase + VFE_MODULE_CFG); -} - -static void vfe_program_dmi_cfg(enum VFE_DMI_RAM_SEL bankSel) -{ - /* set bit 8 for auto increment. */ - uint32_t value = (uint32_t) ctrl->vfebase + VFE_DMI_CFG_DEFAULT; - - value += (uint32_t)bankSel; - /* CDBG("dmi cfg input bank is 0x%x\n", bankSel); */ - - writel(value, ctrl->vfebase + VFE_DMI_CFG); - writel(0, ctrl->vfebase + VFE_DMI_ADDR); -} - -static void vfe_write_lens_roll_off_table( - struct vfe_cmd_roll_off_config *in) -{ - uint16_t i; - uint32_t data; - - uint16_t *initGr = in->initTableGr; - uint16_t *initGb = in->initTableGb; - uint16_t *initB = in->initTableB; - uint16_t *initR = in->initTableR; - - int16_t *pDeltaGr = in->deltaTableGr; - int16_t *pDeltaGb = in->deltaTableGb; - int16_t *pDeltaB = in->deltaTableB; - int16_t *pDeltaR = in->deltaTableR; - - vfe_program_dmi_cfg(ROLLOFF_RAM); - - /* first pack and write init table */ - for (i = 0; i < VFE_ROLL_OFF_INIT_TABLE_SIZE; i++) { - data = (((uint32_t)(*initR)) & 0x0000FFFF) | - (((uint32_t)(*initGr)) << 16); - initR++; - initGr++; - - writel(data, ctrl->vfebase + VFE_DMI_DATA_LO); - - data = (((uint32_t)(*initB)) & 0x0000FFFF) | - (((uint32_t)(*initGr))<<16); - initB++; - initGb++; - - writel(data, ctrl->vfebase + VFE_DMI_DATA_LO); - } - - /* there are gaps between the init table and delta table, - * set the offset for delta table. */ - writel(LENS_ROLL_OFF_DELTA_TABLE_OFFSET, - ctrl->vfebase + VFE_DMI_ADDR); - - /* pack and write delta table */ - for (i = 0; i < VFE_ROLL_OFF_DELTA_TABLE_SIZE; i++) { - data = (((int32_t)(*pDeltaR)) & 0x0000FFFF) | - (((int32_t)(*pDeltaGr))<<16); - pDeltaR++; - pDeltaGr++; - - writel(data, ctrl->vfebase + VFE_DMI_DATA_LO); - - data = (((int32_t)(*pDeltaB)) & 0x0000FFFF) | - (((int32_t)(*pDeltaGb))<<16); - pDeltaB++; - pDeltaGb++; - - writel(data, ctrl->vfebase + VFE_DMI_DATA_LO); - } - - /* After DMI transfer, to make it safe, need to set the - * DMI_CFG to unselect any SRAM - */ - /* unselect the SRAM Bank. */ - writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG); -} - -static void vfe_set_default_reg_values(void) -{ - writel(0x800080, ctrl->vfebase + VFE_DEMUX_GAIN_0); - writel(0x800080, ctrl->vfebase + VFE_DEMUX_GAIN_1); - writel(0xFFFFF, ctrl->vfebase + VFE_CGC_OVERRIDE); - - /* default frame drop period and pattern */ - writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG); - writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_CFG); - writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN); - writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_PATTERN); - writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_CFG); - writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_CFG); - writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN); - writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_PATTERN); - writel(0, ctrl->vfebase + VFE_CLAMP_MIN_CFG); - writel(0xFFFFFF, ctrl->vfebase + VFE_CLAMP_MAX_CFG); -} - -static void vfe_config_demux(uint32_t period, uint32_t even, uint32_t odd) -{ - writel(period, ctrl->vfebase + VFE_DEMUX_CFG); - writel(even, ctrl->vfebase + VFE_DEMUX_EVEN_CFG); - writel(odd, ctrl->vfebase + VFE_DEMUX_ODD_CFG); -} - -static void vfe_pm_stop(void) -{ - writel(VFE_PERFORMANCE_MONITOR_STOP, ctrl->vfebase + VFE_BUS_PM_CMD); -} - -static void vfe_program_bus_rd_irq_en(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_BUS_PINGPONG_IRQ_EN); -} - -static void vfe_camif_go(void) -{ - writel(CAMIF_COMMAND_START, ctrl->vfebase + CAMIF_COMMAND); -} - -static void vfe_camif_stop_immediately(void) -{ - writel(CAMIF_COMMAND_STOP_IMMEDIATELY, ctrl->vfebase + CAMIF_COMMAND); - writel(0, ctrl->vfebase + VFE_CGC_OVERRIDE); -} - -static void vfe_program_reg_update_cmd(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_REG_UPDATE_CMD); -} - -static void vfe_program_bus_cmd(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_BUS_CMD); -} - -static void vfe_program_global_reset_cmd(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_GLOBAL_RESET_CMD); -} - -static void vfe_program_axi_cmd(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_AXI_CMD); -} - -static void vfe_program_irq_composite_mask(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_IRQ_COMPOSITE_MASK); -} - -static inline void vfe_program_irq_mask(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_IRQ_MASK); -} - -static void vfe_program_chroma_upsample_cfg(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_CHROMA_UPSAMPLE_CFG); -} - -static uint32_t vfe_read_axi_status(void) -{ - return readl(ctrl->vfebase + VFE_AXI_STATUS); -} - -static uint32_t vfe_read_pm_status_in_raw_capture(void) -{ - return readl(ctrl->vfebase + VFE_BUS_ENC_CBCR_WR_PM_STATS_1); -} - -static void -vfe_set_stats_pingpong_address(struct vfe_stats_control *afControl, - struct vfe_stats_control *awbControl) -{ - afControl->hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR); - afControl->hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR); - - awbControl->hwRegPingAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR); - awbControl->hwRegPongAddress = (uint8_t *) - (ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR); -} - -static uint32_t vfe_read_camif_status(void) -{ - return readl(ctrl->vfebase + CAMIF_STATUS); -} - -static void vfe_program_lut_bank_sel(struct vfe_gamma_lut_sel *in) -{ - struct VFE_GammaLutSelect_ConfigCmdType cmd; - - memset(&cmd, 0, sizeof(cmd)); - - cmd.ch0BankSelect = in->ch0BankSelect; - cmd.ch1BankSelect = in->ch1BankSelect; - cmd.ch2BankSelect = in->ch2BankSelect; - CDBG("VFE gamma lut bank selection is 0x%x\n", *((uint32_t *)&cmd)); - vfe_prog_hw(ctrl->vfebase + VFE_LUT_BANK_SEL, - (uint32_t *)&cmd, sizeof(cmd)); -} - -static void vfe_program_stats_cmd(struct vfe_stats_cmd_data *in) -{ - struct VFE_StatsCmdType stats; - memset(&stats, 0, sizeof(stats)); - - stats.autoFocusEnable = in->autoFocusEnable; - stats.axwEnable = in->axwEnable; - stats.histEnable = in->histEnable; - stats.clearHistEnable = in->clearHistEnable; - stats.histAutoClearEnable = in->histAutoClearEnable; - stats.colorConversionEnable = in->colorConversionEnable; - - writel(*((uint32_t *)&stats), ctrl->vfebase + VFE_STATS_CMD); -} - -static void vfe_pm_start(struct vfe_cmd_bus_pm_start *in) -{ - struct VFE_Bus_Pm_ConfigCmdType cmd; - memset(&cmd, 0, sizeof(struct VFE_Bus_Pm_ConfigCmdType)); - - cmd.output2YWrPmEnable = in->output2YWrPmEnable; - cmd.output2CbcrWrPmEnable = in->output2CbcrWrPmEnable; - cmd.output1YWrPmEnable = in->output1YWrPmEnable; - cmd.output1CbcrWrPmEnable = in->output1CbcrWrPmEnable; - - vfe_prog_hw(ctrl->vfebase + VFE_BUS_PM_CFG, - (uint32_t *)&cmd, sizeof(cmd)); -} - -static void vfe_8k_pm_start(struct vfe_cmd_bus_pm_start *in) -{ - in->output1CbcrWrPmEnable = ctrl->vfeBusConfigLocal.viewCbcrWrPathEn; - in->output1YWrPmEnable = ctrl->vfeBusConfigLocal.viewYWrPathEn; - in->output2CbcrWrPmEnable = ctrl->vfeBusConfigLocal.encCbcrWrPathEn; - in->output2YWrPmEnable = ctrl->vfeBusConfigLocal.encYWrPathEn; - - if (in->output1CbcrWrPmEnable || in->output1YWrPmEnable) - ctrl->viewPath.pmEnabled = TRUE; - - if (in->output2CbcrWrPmEnable || in->output2YWrPmEnable) - ctrl->encPath.pmEnabled = TRUE; - - vfe_pm_start(in); - - writel(VFE_PERFORMANCE_MONITOR_GO, ctrl->vfebase + VFE_BUS_PM_CMD); -} - -static uint32_t vfe_irq_pack(struct vfe_interrupt_mask data) -{ - struct vfe_irqenable packedData; - - memset(&packedData, 0, sizeof(packedData)); - - packedData.camifErrorIrq = data.camifErrorIrq; - packedData.camifSofIrq = data.camifSofIrq; - packedData.camifEolIrq = data.camifEolIrq; - packedData.camifEofIrq = data.camifEofIrq; - packedData.camifEpoch1Irq = data.camifEpoch1Irq; - packedData.camifEpoch2Irq = data.camifEpoch2Irq; - packedData.camifOverflowIrq = data.camifOverflowIrq; - packedData.ceIrq = data.ceIrq; - packedData.regUpdateIrq = data.regUpdateIrq; - packedData.resetAckIrq = data.resetAckIrq; - packedData.encYPingpongIrq = data.encYPingpongIrq; - packedData.encCbcrPingpongIrq = data.encCbcrPingpongIrq; - packedData.viewYPingpongIrq = data.viewYPingpongIrq; - packedData.viewCbcrPingpongIrq = data.viewCbcrPingpongIrq; - packedData.rdPingpongIrq = data.rdPingpongIrq; - packedData.afPingpongIrq = data.afPingpongIrq; - packedData.awbPingpongIrq = data.awbPingpongIrq; - packedData.histPingpongIrq = data.histPingpongIrq; - packedData.encIrq = data.encIrq; - packedData.viewIrq = data.viewIrq; - packedData.busOverflowIrq = data.busOverflowIrq; - packedData.afOverflowIrq = data.afOverflowIrq; - packedData.awbOverflowIrq = data.awbOverflowIrq; - packedData.syncTimer0Irq = data.syncTimer0Irq; - packedData.syncTimer1Irq = data.syncTimer1Irq; - packedData.syncTimer2Irq = data.syncTimer2Irq; - packedData.asyncTimer0Irq = data.asyncTimer0Irq; - packedData.asyncTimer1Irq = data.asyncTimer1Irq; - packedData.asyncTimer2Irq = data.asyncTimer2Irq; - packedData.asyncTimer3Irq = data.asyncTimer3Irq; - packedData.axiErrorIrq = data.axiErrorIrq; - packedData.violationIrq = data.violationIrq; - - return *((uint32_t *)&packedData); -} - -static uint32_t -vfe_irq_composite_pack(struct vfe_irq_composite_mask_config data) -{ - struct VFE_Irq_Composite_MaskType packedData; - - memset(&packedData, 0, sizeof(packedData)); - - packedData.encIrqComMaskBits = data.encIrqComMask; - packedData.viewIrqComMaskBits = data.viewIrqComMask; - packedData.ceDoneSelBits = data.ceDoneSel; - - return *((uint32_t *)&packedData); -} - -static void vfe_addr_convert(struct msm_vfe_phy_info *pinfo, - enum vfe_resp_msg type, void *data, void **ext, int32_t *elen) -{ - switch (type) { - case VFE_MSG_OUTPUT1: { - pinfo->y_phy = - ((struct vfe_message *)data)->_u.msgOutput1.yBuffer; - pinfo->cbcr_phy = - ((struct vfe_message *)data)->_u.msgOutput1.cbcrBuffer; - - ((struct vfe_frame_extra *)ctrl->extdata)->bpcInfo = - ((struct vfe_message *)data)->_u.msgOutput1.bpcInfo; - - ((struct vfe_frame_extra *)ctrl->extdata)->asfInfo = - ((struct vfe_message *)data)->_u.msgOutput1.asfInfo; - - ((struct vfe_frame_extra *)ctrl->extdata)->frameCounter = - ((struct vfe_message *)data)->_u.msgOutput1.frameCounter; - - ((struct vfe_frame_extra *)ctrl->extdata)->pmData = - ((struct vfe_message *)data)->_u.msgOutput1.pmData; - - *ext = ctrl->extdata; - *elen = ctrl->extlen; - } - break; - - case VFE_MSG_OUTPUT2: { - pinfo->y_phy = - ((struct vfe_message *)data)->_u.msgOutput2.yBuffer; - pinfo->cbcr_phy = - ((struct vfe_message *)data)->_u.msgOutput2.cbcrBuffer; - - CDBG("vfe_addr_convert, pinfo->y_phy = 0x%x\n", pinfo->y_phy); - CDBG("vfe_addr_convert, pinfo->cbcr_phy = 0x%x\n", - pinfo->cbcr_phy); - - ((struct vfe_frame_extra *)ctrl->extdata)->bpcInfo = - ((struct vfe_message *)data)->_u.msgOutput2.bpcInfo; - - ((struct vfe_frame_extra *)ctrl->extdata)->asfInfo = - ((struct vfe_message *)data)->_u.msgOutput2.asfInfo; - - ((struct vfe_frame_extra *)ctrl->extdata)->frameCounter = - ((struct vfe_message *)data)->_u.msgOutput2.frameCounter; - - ((struct vfe_frame_extra *)ctrl->extdata)->pmData = - ((struct vfe_message *)data)->_u.msgOutput2.pmData; - - *ext = ctrl->extdata; - *elen = ctrl->extlen; - } - break; - - case VFE_MSG_STATS_AF: - pinfo->sbuf_phy = - ((struct vfe_message *)data)->_u.msgStatsAf.afBuffer; - break; - - case VFE_MSG_STATS_WE: - pinfo->sbuf_phy = - ((struct vfe_message *)data)->_u.msgStatsWbExp.awbBuffer; - break; - - default: - break; - } /* switch */ -} - -static void -vfe_proc_ops(enum VFE_MESSAGE_ID id, void *msg, size_t len) -{ - struct msm_vfe_resp *rp; - - /* In 8k, OUTPUT1 & OUTPUT2 messages arrive before - * SNAPSHOT_DONE. We don't send such messages to user */ - - CDBG("ctrl->vfeOperationMode = %d, msgId = %d\n", - ctrl->vfeOperationMode, id); - - if ((ctrl->vfeOperationMode == VFE_START_OPERATION_MODE_SNAPSHOT) && - (id == VFE_MSG_ID_OUTPUT1 || id == VFE_MSG_ID_OUTPUT2)) { - return; - } - - rp = ctrl->resp->vfe_alloc(sizeof(struct msm_vfe_resp), ctrl->syncdata); - if (!rp) { - CDBG("rp: cannot allocate buffer\n"); - return; - } - - CDBG("vfe_proc_ops, msgId = %d\n", id); - - rp->evt_msg.type = MSM_CAMERA_MSG; - rp->evt_msg.msg_id = id; - rp->evt_msg.len = len; - rp->evt_msg.data = msg; - - switch (rp->evt_msg.msg_id) { - case VFE_MSG_ID_SNAPSHOT_DONE: - rp->type = VFE_MSG_SNAPSHOT; - break; - - case VFE_MSG_ID_OUTPUT1: - rp->type = VFE_MSG_OUTPUT1; - vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT1, - rp->evt_msg.data, &(rp->extdata), - &(rp->extlen)); - break; - - case VFE_MSG_ID_OUTPUT2: - rp->type = VFE_MSG_OUTPUT2; - vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT2, - rp->evt_msg.data, &(rp->extdata), - &(rp->extlen)); - break; - - case VFE_MSG_ID_STATS_AUTOFOCUS: - rp->type = VFE_MSG_STATS_AF; - vfe_addr_convert(&(rp->phy), VFE_MSG_STATS_AF, - rp->evt_msg.data, NULL, NULL); - break; - - case VFE_MSG_ID_STATS_WB_EXP: - rp->type = VFE_MSG_STATS_WE; - vfe_addr_convert(&(rp->phy), VFE_MSG_STATS_WE, - rp->evt_msg.data, NULL, NULL); - break; - - default: - rp->type = VFE_MSG_GENERAL; - break; - } - - ctrl->resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, ctrl->syncdata); -} - -static void vfe_send_msg_no_payload(enum VFE_MESSAGE_ID id) -{ - struct vfe_message *msg; - - msg = kzalloc(sizeof(*msg), GFP_ATOMIC); - if (!msg) - return; - - msg->_d = id; - vfe_proc_ops(id, msg, 0); -} - -static void vfe_send_bus_overflow_msg(void) -{ - struct vfe_message *msg; - msg = - kzalloc(sizeof(struct vfe_message), GFP_ATOMIC); - if (!msg) - return; - - msg->_d = VFE_MSG_ID_BUS_OVERFLOW; -#if 0 - memcpy(&(msg->_u.msgBusOverflow), - &ctrl->vfePmData, sizeof(ctrl->vfePmData)); -#endif - - vfe_proc_ops(VFE_MSG_ID_BUS_OVERFLOW, - msg, sizeof(struct vfe_message)); -} - -static void vfe_send_camif_error_msg(void) -{ -#if 0 - struct vfe_message *msg; - msg = - kzalloc(sizeof(struct vfe_message), GFP_ATOMIC); - if (!msg) - return; - - msg->_d = VFE_MSG_ID_CAMIF_ERROR; - memcpy(&(msg->_u.msgCamifError), - &ctrl->vfeCamifStatusLocal, sizeof(ctrl->vfeCamifStatusLocal)); - - vfe_proc_ops(VFE_MSG_ID_CAMIF_ERROR, - msg, sizeof(struct vfe_message)); -#endif -} - -static void vfe_process_error_irq( - struct vfe_interrupt_status *irqstatus) -{ - /* all possible error irq. Note error irqs are not enabled, it is - * checked only when other interrupts are present. */ - if (irqstatus->afOverflowIrq) - vfe_send_msg_no_payload(VFE_MSG_ID_AF_OVERFLOW); - - if (irqstatus->awbOverflowIrq) - vfe_send_msg_no_payload(VFE_MSG_ID_AWB_OVERFLOW); - - if (irqstatus->axiErrorIrq) - vfe_send_msg_no_payload(VFE_MSG_ID_AXI_ERROR); - - if (irqstatus->busOverflowIrq) - vfe_send_bus_overflow_msg(); - - if (irqstatus->camifErrorIrq) - vfe_send_camif_error_msg(); - - if (irqstatus->camifOverflowIrq) - vfe_send_msg_no_payload(VFE_MSG_ID_CAMIF_OVERFLOW); - - if (irqstatus->violationIrq) - ; -} - -static void vfe_process_camif_sof_irq(void) -{ - /* increment the frame id number. */ - ctrl->vfeFrameId++; - - CDBG("camif_sof_irq, frameId = %d\n", - ctrl->vfeFrameId); - - /* In snapshot mode, if frame skip is programmed, - * need to check it accordingly to stop camif at - * correct frame boundary. For the dropped frames, - * there won't be any output path irqs, but there is - * still SOF irq, which can help us determine when - * to stop the camif. - */ - if (ctrl->vfeOperationMode) { - if ((1 << ctrl->vfeFrameSkipCount) & - ctrl->vfeFrameSkipPattern) { - - ctrl->vfeSnapShotCount--; - if (ctrl->vfeSnapShotCount == 0) - /* terminate vfe pipeline at frame boundary. */ - writel(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY, - ctrl->vfebase + CAMIF_COMMAND); - } - - /* update frame skip counter for bit checking. */ - ctrl->vfeFrameSkipCount++; - if (ctrl->vfeFrameSkipCount == - (ctrl->vfeFrameSkipPeriod + 1)) - ctrl->vfeFrameSkipCount = 0; - } -} - -static int vfe_get_af_pingpong_status(void) -{ - uint32_t busPingPongStatus; - int rc = 0; - - busPingPongStatus = - readl(ctrl->vfebase + VFE_BUS_PINGPONG_STATUS); - - if ((busPingPongStatus & VFE_AF_PINGPONG_STATUS_BIT) == 0) - return -EFAULT; - - return rc; -} - -static uint32_t vfe_read_af_buf_addr(boolean pipo) -{ - if (pipo == FALSE) - return readl(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR); - else - return readl(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR); -} - -static void -vfe_update_af_buf_addr(boolean pipo, uint32_t addr) -{ - if (pipo == FALSE) - writel(addr, ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR); - else - writel(addr, ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR); -} - -static void -vfe_send_af_stats_msg(uint32_t afBufAddress) -{ - /* unsigned long flags; */ - struct vfe_message *msg; - msg = - kzalloc(sizeof(struct vfe_message), GFP_ATOMIC); - if (!msg) - return; - - /* fill message with right content. */ - /* @todo This is causing issues, need further investigate */ - /* spin_lock_irqsave(&ctrl->state_lock, flags); */ - if (ctrl->vstate != VFE_STATE_ACTIVE) { - kfree(msg); - goto af_stats_done; - } - - msg->_d = VFE_MSG_ID_STATS_AUTOFOCUS; - msg->_u.msgStatsAf.afBuffer = afBufAddress; - msg->_u.msgStatsAf.frameCounter = ctrl->vfeFrameId; - - vfe_proc_ops(VFE_MSG_ID_STATS_AUTOFOCUS, - msg, sizeof(struct vfe_message)); - - ctrl->afStatsControl.ackPending = TRUE; - -af_stats_done: - /* spin_unlock_irqrestore(&ctrl->state_lock, flags); */ - return; -} - -static void vfe_process_stats_af_irq(void) -{ - boolean bufferAvailable; - - if (!(ctrl->afStatsControl.ackPending)) { - - /* read hardware status. */ - ctrl->afStatsControl.pingPongStatus = - vfe_get_af_pingpong_status(); - - bufferAvailable = - (ctrl->afStatsControl.pingPongStatus) ^ 1; - - ctrl->afStatsControl.bufToRender = - vfe_read_af_buf_addr(bufferAvailable); - - /* update the same buffer address (ping or pong) */ - vfe_update_af_buf_addr(bufferAvailable, - ctrl->afStatsControl.nextFrameAddrBuf); - - vfe_send_af_stats_msg(ctrl->afStatsControl.bufToRender); - } else - ctrl->afStatsControl.droppedStatsFrameCount++; -} - -static boolean vfe_get_awb_pingpong_status(void) -{ - uint32_t busPingPongStatus; - - busPingPongStatus = - readl(ctrl->vfebase + VFE_BUS_PINGPONG_STATUS); - - if ((busPingPongStatus & VFE_AWB_PINGPONG_STATUS_BIT) == 0) - return FALSE; - - return TRUE; -} - -static uint32_t -vfe_read_awb_buf_addr(boolean pingpong) -{ - if (pingpong == FALSE) - return readl(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR); - else - return readl(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR); -} - -static void vfe_update_awb_buf_addr( - boolean pingpong, uint32_t addr) -{ - if (pingpong == FALSE) - writel(addr, ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR); - else - writel(addr, ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR); -} - -static void vfe_send_awb_stats_msg(uint32_t awbBufAddress) -{ - /* unsigned long flags; */ - struct vfe_message *msg; - - msg = - kzalloc(sizeof(struct vfe_message), GFP_ATOMIC); - if (!msg) - return; - - /* fill message with right content. */ - /* @todo This is causing issues, need further investigate */ - /* spin_lock_irqsave(&ctrl->state_lock, flags); */ - if (ctrl->vstate != VFE_STATE_ACTIVE) { - kfree(msg); - goto awb_stats_done; - } - - msg->_d = VFE_MSG_ID_STATS_WB_EXP; - msg->_u.msgStatsWbExp.awbBuffer = awbBufAddress; - msg->_u.msgStatsWbExp.frameCounter = ctrl->vfeFrameId; - - vfe_proc_ops(VFE_MSG_ID_STATS_WB_EXP, - msg, sizeof(struct vfe_message)); - - ctrl->awbStatsControl.ackPending = TRUE; - -awb_stats_done: - /* spin_unlock_irqrestore(&ctrl->state_lock, flags); */ - return; -} - -static void vfe_process_stats_awb_irq(void) -{ - boolean bufferAvailable; - - if (!(ctrl->awbStatsControl.ackPending)) { - - ctrl->awbStatsControl.pingPongStatus = - vfe_get_awb_pingpong_status(); - - bufferAvailable = (ctrl->awbStatsControl.pingPongStatus) ^ 1; - - ctrl->awbStatsControl.bufToRender = - vfe_read_awb_buf_addr(bufferAvailable); - - vfe_update_awb_buf_addr(bufferAvailable, - ctrl->awbStatsControl.nextFrameAddrBuf); - - vfe_send_awb_stats_msg(ctrl->awbStatsControl.bufToRender); - - } else - ctrl->awbStatsControl.droppedStatsFrameCount++; -} - -static void vfe_process_sync_timer_irq( - struct vfe_interrupt_status *irqstatus) -{ - if (irqstatus->syncTimer0Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_SYNC_TIMER0_DONE); - - if (irqstatus->syncTimer1Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_SYNC_TIMER1_DONE); - - if (irqstatus->syncTimer2Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_SYNC_TIMER2_DONE); -} - -static void vfe_process_async_timer_irq( - struct vfe_interrupt_status *irqstatus) -{ - - if (irqstatus->asyncTimer0Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_ASYNC_TIMER0_DONE); - - if (irqstatus->asyncTimer1Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_ASYNC_TIMER1_DONE); - - if (irqstatus->asyncTimer2Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_ASYNC_TIMER2_DONE); - - if (irqstatus->asyncTimer3Irq) - vfe_send_msg_no_payload(VFE_MSG_ID_ASYNC_TIMER3_DONE); -} - -static void vfe_send_violation_msg(void) -{ - vfe_send_msg_no_payload(VFE_MSG_ID_VIOLATION); -} - -static void vfe_send_async_timer_msg(void) -{ - vfe_send_msg_no_payload(VFE_MSG_ID_ASYNC_TIMER0_DONE); -} - -static void vfe_write_gamma_table(uint8_t channel, - boolean bank, int16_t *pTable) -{ - uint16_t i; - - enum VFE_DMI_RAM_SEL dmiRamSel = NO_MEM_SELECTED; - - switch (channel) { - case 0: - if (bank == 0) - dmiRamSel = RGBLUT_RAM_CH0_BANK0; - else - dmiRamSel = RGBLUT_RAM_CH0_BANK1; - break; - - case 1: - if (bank == 0) - dmiRamSel = RGBLUT_RAM_CH1_BANK0; - else - dmiRamSel = RGBLUT_RAM_CH1_BANK1; - break; - - case 2: - if (bank == 0) - dmiRamSel = RGBLUT_RAM_CH2_BANK0; - else - dmiRamSel = RGBLUT_RAM_CH2_BANK1; - break; - - default: - break; - } - - vfe_program_dmi_cfg(dmiRamSel); - - for (i = 0; i < VFE_GAMMA_TABLE_LENGTH; i++) { - writel((uint32_t)(*pTable), ctrl->vfebase + VFE_DMI_DATA_LO); - pTable++; - } - - /* After DMI transfer, need to set the DMI_CFG to unselect any SRAM - unselect the SRAM Bank. */ - writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG); -} - -static void vfe_prog_hw_testgen_cmd(uint32_t value) -{ - writel(value, ctrl->vfebase + VFE_HW_TESTGEN_CMD); -} - -static inline void vfe_read_irq_status(struct vfe_irq_thread_msg *out) -{ - uint32_t *temp; - - memset(out, 0, sizeof(struct vfe_irq_thread_msg)); - - temp = (uint32_t *)(ctrl->vfebase + VFE_IRQ_STATUS); - out->vfeIrqStatus = readl(temp); - - temp = (uint32_t *)(ctrl->vfebase + CAMIF_STATUS); - out->camifStatus = readl(temp); - writel(0x7, ctrl->vfebase + CAMIF_COMMAND); - writel(0x3, ctrl->vfebase + CAMIF_COMMAND); - CDBG("camifStatus = 0x%x\n", out->camifStatus); - -/* - temp = (uint32_t *)(ctrl->vfebase + VFE_DEMOSAIC_STATUS); - out->demosaicStatus = readl(temp); - - temp = (uint32_t *)(ctrl->vfebase + VFE_ASF_MAX_EDGE); - out->asfMaxEdge = readl(temp); - - temp = (uint32_t *)(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PM_STATS_0); -*/ - -#if 0 - out->pmInfo.encPathPmInfo.yWrPmStats0 = readl(temp++); - out->pmInfo.encPathPmInfo.yWrPmStats1 = readl(temp++); - out->pmInfo.encPathPmInfo.cbcrWrPmStats0 = readl(temp++); - out->pmInfo.encPathPmInfo.cbcrWrPmStats1 = readl(temp++); - out->pmInfo.viewPathPmInfo.yWrPmStats0 = readl(temp++); - out->pmInfo.viewPathPmInfo.yWrPmStats1 = readl(temp++); - out->pmInfo.viewPathPmInfo.cbcrWrPmStats0 = readl(temp++); - out->pmInfo.viewPathPmInfo.cbcrWrPmStats1 = readl(temp); -#endif /* if 0 Jeff */ -} - -static struct vfe_interrupt_status -vfe_parse_interrupt_status(uint32_t irqStatusIn) -{ - struct vfe_irqenable hwstat; - struct vfe_interrupt_status ret; - boolean temp; - - memset(&hwstat, 0, sizeof(hwstat)); - memset(&ret, 0, sizeof(ret)); - - hwstat = *((struct vfe_irqenable *)(&irqStatusIn)); - - ret.camifErrorIrq = hwstat.camifErrorIrq; - ret.camifSofIrq = hwstat.camifSofIrq; - ret.camifEolIrq = hwstat.camifEolIrq; - ret.camifEofIrq = hwstat.camifEofIrq; - ret.camifEpoch1Irq = hwstat.camifEpoch1Irq; - ret.camifEpoch2Irq = hwstat.camifEpoch2Irq; - ret.camifOverflowIrq = hwstat.camifOverflowIrq; - ret.ceIrq = hwstat.ceIrq; - ret.regUpdateIrq = hwstat.regUpdateIrq; - ret.resetAckIrq = hwstat.resetAckIrq; - ret.encYPingpongIrq = hwstat.encYPingpongIrq; - ret.encCbcrPingpongIrq = hwstat.encCbcrPingpongIrq; - ret.viewYPingpongIrq = hwstat.viewYPingpongIrq; - ret.viewCbcrPingpongIrq = hwstat.viewCbcrPingpongIrq; - ret.rdPingpongIrq = hwstat.rdPingpongIrq; - ret.afPingpongIrq = hwstat.afPingpongIrq; - ret.awbPingpongIrq = hwstat.awbPingpongIrq; - ret.histPingpongIrq = hwstat.histPingpongIrq; - ret.encIrq = hwstat.encIrq; - ret.viewIrq = hwstat.viewIrq; - ret.busOverflowIrq = hwstat.busOverflowIrq; - ret.afOverflowIrq = hwstat.afOverflowIrq; - ret.awbOverflowIrq = hwstat.awbOverflowIrq; - ret.syncTimer0Irq = hwstat.syncTimer0Irq; - ret.syncTimer1Irq = hwstat.syncTimer1Irq; - ret.syncTimer2Irq = hwstat.syncTimer2Irq; - ret.asyncTimer0Irq = hwstat.asyncTimer0Irq; - ret.asyncTimer1Irq = hwstat.asyncTimer1Irq; - ret.asyncTimer2Irq = hwstat.asyncTimer2Irq; - ret.asyncTimer3Irq = hwstat.asyncTimer3Irq; - ret.axiErrorIrq = hwstat.axiErrorIrq; - ret.violationIrq = hwstat.violationIrq; - - /* logic OR of any error bits - * although each irq corresponds to a bit, the data type here is a - * boolean already. hence use logic operation. - */ - temp = - ret.camifErrorIrq || - ret.camifOverflowIrq || - ret.afOverflowIrq || - ret.awbPingpongIrq || - ret.busOverflowIrq || - ret.axiErrorIrq || - ret.violationIrq; - - ret.anyErrorIrqs = temp; - - /* logic OR of any output path bits*/ - temp = - ret.encYPingpongIrq || - ret.encCbcrPingpongIrq || - ret.encIrq; - - ret.anyOutput2PathIrqs = temp; - - temp = - ret.viewYPingpongIrq || - ret.viewCbcrPingpongIrq || - ret.viewIrq; - - ret.anyOutput1PathIrqs = temp; - - ret.anyOutputPathIrqs = - ret.anyOutput1PathIrqs || - ret.anyOutput2PathIrqs; - - /* logic OR of any sync timer bits*/ - temp = - ret.syncTimer0Irq || - ret.syncTimer1Irq || - ret.syncTimer2Irq; - - ret.anySyncTimerIrqs = temp; - - /* logic OR of any async timer bits*/ - temp = - ret.asyncTimer0Irq || - ret.asyncTimer1Irq || - ret.asyncTimer2Irq || - ret.asyncTimer3Irq; - - ret.anyAsyncTimerIrqs = temp; - - /* bool for all interrupts that are not allowed in idle state */ - temp = - ret.anyErrorIrqs || - ret.anyOutputPathIrqs || - ret.anySyncTimerIrqs || - ret.regUpdateIrq || - ret.awbPingpongIrq || - ret.afPingpongIrq || - ret.camifSofIrq || - ret.camifEpoch2Irq || - ret.camifEpoch1Irq; - - ret.anyIrqForActiveStatesOnly = - temp; - - return ret; -} - -static struct vfe_frame_asf_info -vfe_get_asf_frame_info(struct vfe_irq_thread_msg *in) -{ - struct vfe_asf_info asfInfoTemp; - struct vfe_frame_asf_info rc; - - memset(&rc, 0, sizeof(rc)); - memset(&asfInfoTemp, 0, sizeof(asfInfoTemp)); - - asfInfoTemp = - *((struct vfe_asf_info *)(&(in->asfMaxEdge))); - - rc.asfHbiCount = asfInfoTemp.HBICount; - rc.asfMaxEdge = asfInfoTemp.maxEdge; - - return rc; -} - -static struct vfe_frame_bpc_info -vfe_get_demosaic_frame_info(struct vfe_irq_thread_msg *in) -{ - struct vfe_bps_info bpcInfoTemp; - struct vfe_frame_bpc_info rc; - - memset(&rc, 0, sizeof(rc)); - memset(&bpcInfoTemp, 0, sizeof(bpcInfoTemp)); - - bpcInfoTemp = - *((struct vfe_bps_info *)(&(in->demosaicStatus))); - - rc.greenDefectPixelCount = - bpcInfoTemp.greenBadPixelCount; - - rc.redBlueDefectPixelCount = - bpcInfoTemp.RedBlueBadPixelCount; - - return rc; -} - -static struct vfe_msg_camif_status -vfe_get_camif_status(struct vfe_irq_thread_msg *in) -{ - struct vfe_camif_stats camifStatusTemp; - struct vfe_msg_camif_status rc; - - memset(&rc, 0, sizeof(rc)); - memset(&camifStatusTemp, 0, sizeof(camifStatusTemp)); - - camifStatusTemp = - *((struct vfe_camif_stats *)(&(in->camifStatus))); - - rc.camifState = (boolean)camifStatusTemp.camifHalt; - rc.lineCount = camifStatusTemp.lineCount; - rc.pixelCount = camifStatusTemp.pixe