2 * drivers/media/video/omap/camera_core.h
4 * Copyright (C) 2004 Texas Instruments, Inc.
6 * This package is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
11 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15 #ifndef CAMERA_CORE__H
16 #define CAMERA_CORE__H
20 #include <asm/scatterlist.h>
21 #include <media/videobuf-dma-sg.h>
22 #include <media/v4l2-int-device.h>
25 typedef void (*dma_callback_t)(void *arg1, void *arg2);
28 const struct scatterlist *sglist;
29 int sglen; /* number of sglist entries */
30 int next_sglist; /* index of next sglist entry to process */
31 int queued_sglist; /* number of sglist entries queued for DMA */
32 unsigned long csr; /* DMA return code */
33 dma_callback_t callback;
37 /* NUM_SG_DMA is the number of scatter-gather DMA transfers that can be queued.
39 #define NUM_SG_DMA VIDEO_MAX_FRAME+2
41 /* per-device data structure */
42 struct camera_device {
44 struct video_device *vfd;
46 spinlock_t overlay_lock; /* spinlock for overlay DMA counter */
47 int overlay_cnt; /* count of queued overlay DMA xfers */
48 struct scatterlist overlay_sglist;
49 unsigned long overlay_base_phys;
50 unsigned long overlay_base;
51 unsigned long overlay_size;
53 spinlock_t vbq_lock; /* spinlock for videobuf queues */
54 struct videobuf_queue_ops vbq_ops; /* videobuf queue operations */
55 unsigned long field_count; /* field counter for videobuf_buffer */
57 /* scatter-gather DMA management */
59 int free_sgdma; /* number of free sg dma slots */
60 int next_sgdma; /* index of next sg dma slot to use */
61 struct sgdma_state sgdma[NUM_SG_DMA];
64 /* The img_lock is used to serialize access to the image parameters for
65 * overlay and capture. Need to use spin_lock_irq when writing to the
66 * reading, streaming, and previewing parameters. A regular spin_lock
67 * will suffice for all other cases.
71 /* We allow reading from at most one filehandle at a time.
72 * non-NULL means reading is in progress.
74 struct camera_fh *reading;
75 /* We allow streaming from at most one filehandle at a time.
76 * non-NULL means streaming is in progress.
78 struct camera_fh *streaming;
79 /* We allow previewing from at most one filehandle at a time.
80 * non-NULL means previewing is in progress.
82 struct camera_fh *previewing;
85 * Sensor interface parameters: interface type, CC_CTRL
86 * register value and interface specific data.
94 /* Pointer to the sensor interface ops */
95 struct v4l2_int_device *sdev;
97 /* Pointer to the camera interface hardware ops */
98 struct camera_hardware *cam_hardware;
101 /* pix defines the size and pixel format of the image captured by the
102 * sensor. This also defines the size of the framebuffers. The
103 * same pool of framebuffers is used for video capture and video
104 * overlay. These parameters are set/queried by the
105 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
107 struct v4l2_pix_format pix;
109 /* crop defines the size and offset of the video overlay source window
110 * within the framebuffer. These parameters are set/queried by the
111 * VIDIOC_S_CROP/VIDIOC_G_CROP ioctls with an OVERLAY buffer type.
112 * The cropping rectangle allows a subset of the captured image to be
113 * previewed. It only affects the portion of the image previewed, not
114 * captured; the entire camera image is always captured.
116 struct v4l2_rect crop;
118 /* win defines the size and offset of the video overlay target window
119 * within the video display. These parameters are set/queried by the
120 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with an OVERLAY buffer type.
122 struct v4l2_window win;
124 /* fbuf reflects the size of the video display. It is queried with the
125 * VIDIOC_G_FBUF ioctl. The size of the video display cannot be
126 * changed with the VIDIOC_S_FBUF ioctl.
128 struct v4l2_framebuffer fbuf;
130 /* end of generic stuff, the above should be common to all omaps */
132 /* note, 2420 uses videobuf to do caprure, it is more memory efficient
133 we need 1710 and 2420 do capture in the same way */
134 /* Variables to store the capture state */
135 /* Wait till DMA is completed */
136 wait_queue_head_t new_video_frame;
137 char capture_completed;
138 char capture_started;
139 spinlock_t capture_lock;
140 struct scatterlist capture_sglist;
141 unsigned long capture_base;
142 unsigned long capture_base_phys;
147 /* per-filehandle data structure */
149 struct camera_device *cam;
150 enum v4l2_buf_type type;
151 struct videobuf_queue vbq;
154 #define CAM_NAME "omap_camera"
156 #endif /* CAMERA_CORE__H */