1/*
2 * Copyright 2004-2008, Fran��ois Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
4 */
5
6#include "CamSensor.h"
7#include "CamDebug.h"
8
9
10CamSensor::CamSensor(CamDevice *_camera)
11	: fInitStatus(B_NO_INIT),
12	  fIsBigEndian(false),
13	  fTransferEnabled(false),
14	  fVideoFrame(),
15	  fLastParameterChanges(0),
16	  fCamDevice(_camera)
17{
18
19}
20
21
22CamSensor::~CamSensor()
23{
24
25}
26
27
28status_t
29CamSensor::Probe()
30{
31	// default is to match by USB IDs
32	return B_OK;
33}
34
35
36status_t
37CamSensor::InitCheck()
38{
39	return fInitStatus;
40}
41
42
43status_t
44CamSensor::Setup()
45{
46	return fInitStatus;
47}
48
49
50const char *
51CamSensor::Name()
52{
53	return "<unknown>";
54}
55
56
57status_t
58CamSensor::StartTransfer()
59{
60	fTransferEnabled = true;
61	return B_OK;
62}
63
64
65status_t
66CamSensor::StopTransfer()
67{
68	fTransferEnabled = false;
69	return B_OK;
70}
71
72
73status_t
74CamSensor::AcceptVideoFrame(uint32 &width, uint32 &height)
75{
76	// minimum sanity
77	if (width < 1)
78		width = MaxWidth();
79	if (height < 1)
80		height = MaxHeight();
81	if (width > (uint32)MaxWidth())
82		width = MaxWidth();
83	if (height > (uint32)MaxHeight())
84		height = MaxHeight();
85	return B_OK;
86}
87
88
89status_t
90CamSensor::SetVideoFrame(BRect rect)
91{
92	return ENOSYS;
93}
94
95
96status_t
97CamSensor::SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue)
98{
99	return ENOSYS;
100}
101
102
103void
104CamSensor::AddParameters(BParameterGroup *group, int32 &index)
105{
106	fFirstParameterID = index;
107}
108
109status_t
110CamSensor::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size)
111{
112	return B_BAD_VALUE;
113}
114
115status_t
116CamSensor::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size)
117{
118	return B_BAD_VALUE;
119}
120
121
122CamDevice *
123CamSensor::Device()
124{
125	return fCamDevice;
126}
127
128
129status_t
130CamSensor::ProbeByIICSignature(const uint8 *regList, const uint8 *matchList,
131	size_t count)
132{
133	for (size_t i = 0; i < count; i++) {
134		uint8 value = 0;
135		ssize_t len;
136		len = Device()->ReadIIC8(regList[i], &value);
137		PRINT((CH ": ReadIIC8 = %" B_PRIdSSIZE " val = %d" CT, len, value));
138		if (len < 1)
139			return ENODEV;
140		if (value != matchList[i])
141			return ENODEV;
142	}
143	return B_OK;
144}
145