Terence Hampson | a6914ca | 2012-04-09 14:06:50 -0400 | [diff] [blame^] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef VCAP_V4L2_H |
| 15 | #define VCAP_V4L2_H |
| 16 | |
| 17 | #ifdef __KERNEL__ |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/videodev2.h> |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/workqueue.h> |
| 22 | #include <media/videobuf2-vmalloc.h> |
| 23 | #include <media/v4l2-device.h> |
| 24 | #include <media/v4l2-ioctl.h> |
| 25 | #include <media/v4l2-ctrls.h> |
| 26 | #include <media/v4l2-fh.h> |
| 27 | #include <media/v4l2-common.h> |
| 28 | #include <media/vcap_fmt.h> |
| 29 | #include <mach/board.h> |
| 30 | |
| 31 | struct vcap_client_data; |
| 32 | |
| 33 | enum rdy_buf { |
| 34 | VC_NO_BUF = 0, |
| 35 | VC_BUF1 = 1 << 1, |
| 36 | VC_BUF2 = 1 << 2, |
| 37 | VC_BUF1N2 = 0x11 << 1, |
| 38 | }; |
| 39 | |
| 40 | struct vcap_buf_info { |
| 41 | unsigned long vaddr; |
| 42 | unsigned long size; |
| 43 | }; |
| 44 | |
| 45 | struct vcap_action { |
| 46 | struct list_head active; |
| 47 | |
| 48 | /* thread for generating video stream*/ |
| 49 | struct task_struct *kthread; |
| 50 | wait_queue_head_t wq; |
| 51 | |
| 52 | /* Buffer index */ |
| 53 | enum rdy_buf buf_ind; |
| 54 | |
| 55 | /* Buffers inside vc */ |
| 56 | struct vcap_buffer *buf1; |
| 57 | struct vcap_buffer *buf2; |
| 58 | |
| 59 | /* Counters to control fps rate */ |
| 60 | int frame; |
| 61 | int ini_jiffies; |
| 62 | }; |
| 63 | |
| 64 | struct vcap_dev { |
| 65 | struct v4l2_device v4l2_dev; |
| 66 | |
| 67 | struct video_device *vfd; |
| 68 | struct ion_client *ion_client; |
| 69 | |
| 70 | struct resource *vcapirq; |
| 71 | |
| 72 | struct resource *vcapmem; |
| 73 | struct resource *vcapio; |
| 74 | void __iomem *vcapbase; |
| 75 | |
| 76 | struct vcap_platform_data *vcap_pdata; |
| 77 | |
| 78 | struct regulator *fs_vcap; |
| 79 | struct clk *vcap_clk; |
| 80 | struct clk *vcap_p_clk; |
| 81 | struct clk *vcap_npl_clk; |
| 82 | /*struct platform_device *pdev;*/ |
| 83 | |
| 84 | uint32_t bus_client_handle; |
| 85 | |
| 86 | struct vcap_client_data *vc_client; |
| 87 | struct vcap_client_data *vp_client; |
| 88 | |
| 89 | atomic_t vc_enabled; |
| 90 | atomic_t vc_resource; |
| 91 | atomic_t vp_resource; |
| 92 | }; |
| 93 | |
| 94 | struct vp_format_data { |
| 95 | unsigned int width, height; |
| 96 | unsigned int pixelformat; |
| 97 | enum v4l2_field field; |
| 98 | |
| 99 | }; |
| 100 | |
| 101 | struct vcap_buffer { |
| 102 | /* common v4l buffer stuff -- must be first */ |
| 103 | struct vb2_buffer vb; |
| 104 | struct list_head list; |
| 105 | unsigned long paddr; |
| 106 | struct ion_handle *ion_handle; |
| 107 | }; |
| 108 | |
| 109 | struct vcap_client_data { |
| 110 | struct vcap_dev *dev; |
| 111 | |
| 112 | struct vb2_queue vc_vidq; |
| 113 | /*struct vb2_queue vb__vidq;*/ |
| 114 | /*struct vb2_queue vb_cap_vidq;*/ |
| 115 | |
| 116 | struct v4l2_format_vc_ext vc_format; |
| 117 | |
| 118 | enum v4l2_buf_type vp_buf_type_field; |
| 119 | struct vp_format_data vp_format; |
| 120 | |
| 121 | struct vcap_action vid_vc_action; |
| 122 | struct workqueue_struct *vcap_work_q; |
| 123 | struct ion_handle *vc_ion_handle; |
| 124 | |
| 125 | uint32_t hold_vc; |
| 126 | uint32_t hold_vp; |
| 127 | |
| 128 | spinlock_t cap_slock; |
| 129 | }; |
| 130 | |
| 131 | #endif |
| 132 | #endif |