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 <media/video-buf.h>
21 #include <asm/scatterlist.h>
24 typedef void (*dma_callback_t)(void *arg1, void *arg2);
27 const struct scatterlist *sglist;
28 int sglen; /* number of sglist entries */
29 int next_sglist; /* index of next sglist entry to process */
30 int queued_sglist; /* number of sglist entries queued for DMA */
31 unsigned long csr; /* DMA return code */
32 dma_callback_t callback;
36 /* NUM_SG_DMA is the number of scatter-gather DMA transfers that can be queued.
38 #define NUM_SG_DMA VIDEO_MAX_FRAME+2
40 /* per-device data structure */
41 struct camera_device {
43 struct video_device *vfd;
45 spinlock_t overlay_lock; /* spinlock for overlay DMA counter */
46 int overlay_cnt; /* count of queued overlay DMA xfers */
47 struct scatterlist overlay_sglist;
48 unsigned long overlay_base_phys;
49 unsigned long overlay_base;
50 unsigned long overlay_size;
52 spinlock_t vbq_lock; /* spinlock for videobuf queues */
53 struct videobuf_queue_ops vbq_ops; /* videobuf queue operations */
54 unsigned long field_count; /* field counter for videobuf_buffer */
56 /* scatter-gather DMA management */
58 int free_sgdma; /* number of free sg dma slots */
59 int next_sgdma; /* index of next sg dma slot to use */
60 struct sgdma_state sgdma[NUM_SG_DMA];
63 /* The img_lock is used to serialize access to the image parameters for
64 * overlay and capture. Need to use spin_lock_irq when writing to the
65 * reading, streaming, and previewing parameters. A regular spin_lock
66 * will suffice for all other cases.
70 /* We allow reading from at most one filehandle at a time.
71 * non-NULL means reading is in progress.
73 struct camera_fh *reading;
74 /* We allow streaming from at most one filehandle at a time.
75 * non-NULL means streaming is in progress.
77 struct camera_fh *streaming;
78 /* We allow previewing from at most one filehandle at a time.
79 * non-NULL means previewing is in progress.
81 struct camera_fh *previewing;
83 /* capture parameters (frame rate, number of buffers) */
84 struct v4l2_captureparm cparm;
86 /* This is the frame period actually requested by the user. */
87 struct v4l2_fract nominal_timeperframe;
89 /* frequency (in Hz) of camera interface xclk output */
92 /* Pointer to the sensor interface ops */
93 struct camera_sensor *cam_sensor;
96 /* Pointer to the camera interface hardware ops */
97 struct camera_hardware *cam_hardware;
100 /* pix defines the size and pixel format of the image captured by the
101 * sensor. This also defines the size of the framebuffers. The
102 * same pool of framebuffers is used for video capture and video
103 * overlay. These parameters are set/queried by the
104 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
106 struct v4l2_pix_format pix;
107 struct v4l2_pix_format pix2;
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 */