vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / radeon / VideoIn.h
blob5374934fafdffb7acd45a65ebf1b522ab8176333
1 /******************************************************************************
3 / File: VideoIn.h
5 / Description: High-Level ATI Radeon Video Capture Interface.
7 / Copyright 2001, Carlos Hasan
9 *******************************************************************************/
11 #ifndef __VIDEO_IN_H__
12 #define __VIDEO_IN_H__
14 #include "Radeon.h"
15 #include "Capture.h"
16 //#include "Overlay.h"
17 #include "I2CPort.h"
18 #include "VIPPort.h"
19 #include "Tuner.h"
20 #include "MSP3430.h"
21 #include "Theater.h"
22 #include "Theater100.h"
23 #include "Theater200.h"
25 enum video_in_source {
26 C_VIDEO_IN_TUNER,
27 C_VIDEO_IN_COMPOSITE,
28 C_VIDEO_IN_SVIDEO,
31 enum { C_VIDEO_IN_SOURCE_MAX = 2 };
33 enum video_in_standard {
34 C_VIDEO_IN_NTSC,
35 C_VIDEO_IN_NTSC_JAPAN,
36 C_VIDEO_IN_NTSC_443,
37 C_VIDEO_IN_PAL_M,
38 C_VIDEO_IN_PAL_BDGHI,
39 C_VIDEO_IN_PAL_N,
40 C_VIDEO_IN_PAL_60,
41 C_VIDEO_IN_PAL_NC,
42 C_VIDEO_IN_SECAM,
43 C_VIDEO_IN_NTSC_RAW
44 };
46 enum { C_VIDEO_IN_STANDARD_MAX = 8 };
48 enum video_in_capture_mode {
49 C_VIDEO_IN_FIELD,
50 C_VIDEO_IN_BOB,
51 C_VIDEO_IN_WEAVE
54 enum { C_VIDEO_IN_CAPTURE_MODE_MAX = 2 };
56 enum video_in_resolution {
57 C_VIDEO_IN_NTSC_SQ_WIDTH = 640,
58 C_VIDEO_IN_NTSC_SQ_HEIGHT = 480,
60 C_VIDEO_IN_NTSC_CCIR_WIDTH = 720,
61 C_VIDEO_IN_NTSC_CCIR_HEIGHT = 480,
63 C_VIDEO_IN_PAL_SQ_WIDTH = 768,
64 C_VIDEO_IN_PAL_SQ_HEIGHT = 576,
66 C_VIDEO_IN_PAL_CCIR_WIDTH = 720,
67 C_VIDEO_IN_PAL_CCIR_HEIGHT = 576
70 /*enum video_in_frame_rate {
71 C_VIDEO_IN_NTSC_FRAME_RATE = 29976,
72 C_VIDEO_IN_PAL_FRAME_RATE = 25000
73 };*/
75 enum video_in_capabilities {
76 C_VIDEO_IN_HAS_SOUND = 1 << 0,
77 C_VIDEO_IN_HAS_TUNER = 1 << 1,
78 C_VIDEO_IN_HAS_COMPOSITE = 1 << 2,
79 C_VIDEO_IN_HAS_SVIDEO = 1 << 3
82 class CVideoIn {
83 public:
84 CVideoIn( const char *dev_name );
86 ~CVideoIn();
88 status_t InitCheck();
90 int Capabilities() const;
92 public:
93 void Start(video_in_source source, video_in_standard standard,
94 video_in_capture_mode mode, int width, int height);
96 void Stop();
98 int Capture(color_space colorSpace, void * bits, int bitsLength,
99 int bytesPerRow, int * sequence, short * number, bigtime_t * when);
101 public:
102 void SetBrightness(int brightness);
104 void SetContrast(int contrast);
106 void SetSaturation(int saturation);
108 void SetHue(int hue);
110 void SetSharpness(int sharpness);
112 void SetFrequency(float frequency, float picture);
114 float FrequencyForChannel(int channel, video_in_standard standard);
116 bool SetChannel(int channel, video_in_standard standard);
118 int32 getFrameRate( video_in_standard standard );
120 void getActiveRange( video_in_standard standard, CRadeonRect &rect );
122 private:
123 void FreeBuffers();
125 void Trace(const char * message) const;
127 private:
128 CRadeon fRadeon;
129 CCapture fCapture;
130 CI2CPort fI2CPort;
131 CTheater* fTheater;
132 CTuner fTuner;
133 CMSP3430 fSound;
134 int32 fBuffer0;
135 int32 fBuffer1;
136 int32 fBuffer0Handle;
137 int32 fBuffer1Handle;
138 void *convert_buffer;
139 int fBufferLength;
140 int fBufferBytesPerRow;
141 int fBufferSequence;
142 bigtime_t fBufferPeriod;
143 bool started;
146 #endif