xref: /haiku/src/add-ons/media/media-add-ons/radeon/VideoIn.h (revision b028e77473189065f2baefc6f5e10d451cf591e2)
1 /******************************************************************************
2 /
3 /	File:			VideoIn.h
4 /
5 /	Description:	High-Level ATI Radeon Video Capture Interface.
6 /
7 /	Copyright 2001, Carlos Hasan
8 /
9 *******************************************************************************/
10 
11 #ifndef __VIDEO_IN_H__
12 #define __VIDEO_IN_H__
13 
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"
24 
25 enum video_in_source {
26 	C_VIDEO_IN_TUNER,
27 	C_VIDEO_IN_COMPOSITE,
28 	C_VIDEO_IN_SVIDEO,
29 };
30 
31 enum { C_VIDEO_IN_SOURCE_MAX = 2 };
32 
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 };
45 
46 enum { C_VIDEO_IN_STANDARD_MAX = 8 };
47 
48 enum video_in_capture_mode {
49 	C_VIDEO_IN_FIELD,
50 	C_VIDEO_IN_BOB,
51 	C_VIDEO_IN_WEAVE
52 };
53 
54 enum { C_VIDEO_IN_CAPTURE_MODE_MAX = 2 };
55 
56 enum video_in_resolution {
57 	C_VIDEO_IN_NTSC_SQ_WIDTH	= 640,
58 	C_VIDEO_IN_NTSC_SQ_HEIGHT	= 480,
59 
60 	C_VIDEO_IN_NTSC_CCIR_WIDTH	= 720,
61 	C_VIDEO_IN_NTSC_CCIR_HEIGHT	= 480,
62 
63 	C_VIDEO_IN_PAL_SQ_WIDTH		= 768,
64 	C_VIDEO_IN_PAL_SQ_HEIGHT	= 576,
65 
66 	C_VIDEO_IN_PAL_CCIR_WIDTH	= 720,
67 	C_VIDEO_IN_PAL_CCIR_HEIGHT	= 576
68 };
69 
70 /*enum video_in_frame_rate {
71 	C_VIDEO_IN_NTSC_FRAME_RATE	= 29976,
72 	C_VIDEO_IN_PAL_FRAME_RATE	= 25000
73 };*/
74 
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
80 };
81 
82 class CVideoIn {
83 public:
84 	CVideoIn( const char *dev_name );
85 
86 	~CVideoIn();
87 
88 	status_t InitCheck();
89 
90 	int Capabilities() const;
91 
92 public:
93 	void Start(video_in_source source, video_in_standard standard,
94 			   video_in_capture_mode mode, int width, int height);
95 
96 	void Stop();
97 
98 	int Capture(color_space colorSpace, void * bits, int bitsLength,
99 				int bytesPerRow, int * sequence, short * number, bigtime_t * when);
100 
101 public:
102 	void SetBrightness(int brightness);
103 
104 	void SetContrast(int contrast);
105 
106 	void SetSaturation(int saturation);
107 
108 	void SetHue(int hue);
109 
110 	void SetSharpness(int sharpness);
111 
112 	void SetFrequency(float frequency, float picture);
113 
114 	float FrequencyForChannel(int channel, video_in_standard standard);
115 
116 	bool SetChannel(int channel, video_in_standard standard);
117 
118 	int32 getFrameRate( video_in_standard standard );
119 
120 	void getActiveRange( video_in_standard standard, CRadeonRect &rect );
121 
122 private:
123 	void FreeBuffers();
124 
125 	void Trace(const char * message) const;
126 
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;
144 };
145 
146 #endif
147