3INDI Interface
for V4L devices
6 This library is free software;
7you can redistribute it and / or
8modify it under the terms of the GNU Lesser General Public
9License as published by the Free Software Foundation;
11version 2.1 of the License, or (at your option) any later version.
13This library is distributed in the hope that it will be useful,
14 but WITHOUT
ANY WARRANTY;
15without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17Lesser General Public License
for more details.
19You should have received
a copy of the GNU Lesser General Public
20License along with
this library;
21if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
34 {
"NexImage 5",
"NexImage 5",
nullptr, 2.2f, -1, 0, 0,
true },
35 {
"Logitech Webcam Pro 9000",
"UVC Camera (046d:0809)",
"Logitech Webcam Pro 9000", 3.3f, -1, 0, 0,
true },
36 {
"SVBONY SV105",
"SVBONY SV105: SVBONY SV105",
"SVBONY SV105", 3.0f, -1, 0, 0,
true },
37 {
"SVBONY SV205",
"SVBONY SV205: SVBONY SV205",
"SVBONY SV205", 4.0f, -1, 0, 0,
true },
38 {
"NexImage 10",
"NexImage 10",
nullptr, 1.67f, -1, 0, 0,
true },
39 {
"NexImage Burst Color",
"NexImage Burst Color",
nullptr, 3.75f, -1, 0, 0,
false },
40 {
"NexImage Burst Mono",
"NexImage Burst Mono",
nullptr, 3.75f, -1, 0, 0,
false },
41 {
"Skyris 132C",
"Skyris 132C",
nullptr, 3.75f, -1, 0, 0,
false },
42 {
"Skyris 132M",
"Skyris 132M",
nullptr, 3.75f, -1, 0, 0,
false },
43 {
"Skyris 236C",
"Skyris 236C",
nullptr, 2.8f, -1, 0, 0,
false },
44 {
"Skyris 236M",
"Skyris 236M",
nullptr, 2.8f, -1, 0, 0,
false },
45 {
"iOptron iPolar",
"iOptron iPolar: iOptron iPolar",
"iOptron iPolar", 3.75f, -1, 1280, 960,
true },
46 {
"iOptron iPolar",
"iOptron iPolar",
"iOptron iPolar", 3.75f, -1, 1280, 960,
true },
47 {
"iOptron iPolar",
"iOptron iPolar 1.1: iOptron iPo",
"iOptron iPolar", 3.75f, -1, 1280, 960,
true },
48 {
"iOptron iGuider",
"iOptron iGuider: iOptron iGuide",
"iOptron iGuider", 3.75f, -1, 1280, 960,
true },
49 {
"iOptron iGuider",
"iOptron iGuider 1",
"iOptron iGuider", 3.75f, -1, 1280, 960,
true },
50 {
"iOptron iGuider",
"iOptron iGuider External: iOptr",
"iOptron iGuider", 3.75f, -1, 1280, 960,
true },
51 {
"Raspberry Pi High Quality Camera",
"mmal service 16.1",
"Raspberry Pi High Quality Camera", 1.55f, -1, 0, 0,
true },
52 {
"Logitech HD C270",
"UVC Camera (046d:0825)",
"Logitech HD C270", 2.8f, -1, 0, 0,
true },
53 {
"IMX290 Camera",
"USB 2.0 Camera: USB Camera",
"USB 2.0 IMX290 Board", 2.9f, -1, 0, 0,
true },
54 {
"IMX290 H264 Camera",
"0c45:6366 Microdia",
"Spinel 2MP Full HD Low Light WDR H264 USB Camera Module IMX290", 2.9f, -1, 0, 0,
true },
55 {
"Microsoft LifeCam Cinema",
"Microsoft® LifeCam Cinema(TM):",
"Microsoft® LifeCam Cinema(TM)", 3.0f, -1, 0, 0,
false },
56 {
"OpenAstroGuider",
"OpenAstroGuider IMX290",
nullptr, 2.9f, -1, 0, 0,
false },
57 {
nullptr,
nullptr,
nullptr, 5.6f, -1, 0, 0,
false}
60static const double IOptronDurations[] = { 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, -1 };
61static const double iGuiderTicks[] = { 1, 2, 5, 10, 20, 39, 78, 156, 312, 625, 1250, 2500, -1 };
62static const double iPolarTicks[] = { 13, 26, 66, 133, 266, 666, 1333, 1999, 2666, 3332, 3999, 4665, -1 };
64#define MAX_IOPTRON_INDEX (sizeof(IOptronDurations) / sizeof(double) - 2)
65#define MAX_IOPTRON_DURATION (IOptronDurations[MAX_IOPTRON_INDEX])
66#define MAX_IOPTRON_TICKS (iGuiderTicks[MAX_IOPTRON_INDEX])
68#define IOPTRON_ABS_EXPOSURE_CTRL_ID 0x9A0902
69#define IOPTRON_AUTO_EXPOSURE_CTRL_ID 0x9A0901
70#define IOPTRON_WATCHDOG_PERIOD_IN_MS 10000
246 PrimaryCCD.setMinMaxStep(
"CCD_EXPOSURE",
"CCD_EXPOSURE_VALUE", 0.001, 3600, 1,
false);
248 if (!
lx->initProperties(
this))
249 LOG_WARN(
"Can not init Long Exposure");
291#ifdef WITH_V4L2_EXPERIMENTS
323#ifdef WITH_V4L2_EXPERIMENTS
331 const char * commonName =
m_Info->commonName;
332 float pixX =
m_Info->pixelSizeX;
333 float pixY =
m_Info->pixelSizeY;
336 commonName =
m_Info->deviceName;
342 LOGF_INFO(
"Setting pixel size correctly for %s", commonName);
343 if (
m_Info->tested ==
false)
345 LOGF_INFO(
"Please report that the camera worked: Name: %s/%s Detected and working, to https://bit.ly/2S1Vxjq",
346 v4l_base->getDeviceName(), commonName);
351 LOGF_INFO(
"Setting pixel size to default of %5.2f", pixX);
352 LOGF_INFO(
"For future autodetection of pixel size, please report the following: Reported Name: %s, "
353 "Common Name (Eg: NexImage 10), Pixel Size to the following thread: https://bit.ly/2S1Vxjq",
361 lx->updateProperties();
369 lx->updateProperties();
395#ifdef WITH_V4L2_EXPERIMENTS
415 if (strcmp(name,
InputsSP.name) == 0)
420 LOG_ERROR(
"Can not set input while capturing.");
427 unsigned int inputindex, oldindex;
433 if (
v4l_base->setinput(inputindex, errmsg) == -1)
435 LOGF_INFO(
"ERROR (setinput): %s", errmsg);
479 LOG_ERROR(
"Can not set format while capturing.");
492 if (index < 0 || v4l_base->setcaptureformat(*((
unsigned int *)
CaptureFormatsSP.sp[index].aux), errmsg) == -1)
494 LOGF_INFO(
"ERROR (setformat): %s", errmsg);
517#ifdef WITH_V4L2_EXPERIMENTS
525 uint8_t pixelDepth = 8;
527 Streamer->setPixelFormat(pixelFormat, pixelDepth);
541 LOG_ERROR(
"Can not set capture size while capturing.");
548 int index{0}, w {0}, h {0};
576 LOG_ERROR(
"Can not change frame rate while capturing.");
582 struct v4l2_fract frate;
586 sscanf(
FrameRatesSP.sp[index].name,
"%d/%d", &frate.numerator, &frate.denominator);
587 if (index < 0 || (
v4l_base->*(
v4l_base->setframerate))(frate, errmsg) == -1)
589 LOGF_INFO(
"ERROR (setframerate): %s", errmsg);
605 LOG_WARN(
"Can not set Image depth (8/16bits) while recording.");
647 if (strcmp(
Options[iopt].name, name) == 0)
651 unsigned int ctrl_id, optindex, ctrlindex;
661 if (
Options[iopt].sp[optindex].aux !=
nullptr)
662 ctrlindex = *(
unsigned int *)(
Options[iopt].sp[optindex].aux);
664 ctrlindex = optindex;
665 ctrl_id = (*((
unsigned int *)
Options[iopt].aux));
666 LOGF_DEBUG(
" On switch is (%d) %s=\"%s\", ctrl_id = 0x%X ctrl_index=%d", optindex,
667 Options[iopt].sp[optindex].name,
Options[iopt].sp[optindex].label, ctrl_id, ctrlindex);
668 if (
v4l_base->setOPTControl(ctrl_id, ctrlindex, errmsg) < 0)
676 LOGF_ERROR(
"Unable to adjust setting. %s", errmsg);
706 LOG_WARN(
"No color processing in color mode ");
710 lx->ISNewSwitch(dev, name, states, names,
n);
722 if (strcmp(name,
PortTP.name) == 0)
735 lx->ISNewText(dev, name, texts, names,
n);
742 while (allowed_values[
n] != -1)
744 if (value < (allowed_values[
n - 1] + allowed_values[
n]) / 2.0)
766 LOG_ERROR(
"Can not set capture size while capturing.");
773 unsigned int sizes[2], w = 0, h = 0;
775 if (strcmp(names[0],
"Width") == 0)
777 sizes[0] = values[0];
778 sizes[1] = values[1];
782 sizes[0] = values[1];
783 sizes[1] = values[0];
811 unsigned int const ctrl_id = *((
unsigned int *)
ImageAdjustNP.np[i].aux0);
843 LOGF_WARN(
"Control %s set to %f returned %f (ctrl_id = 0x%X)",
863 char errorMessage[
MAXRBUF] = {0};
864 if (
v4l_base->setcapturesize(width, height, errorMessage) == -1)
866 LOGF_ERROR(
"Failed to update capture size to %dx%d: %s", width, height, errorMessage);
899 LOG_ERROR(
"Cannot start new exposure while streamer is busy, stop streaming first");
906 "Cannot start new exposure until the current one completes (%.3f seconds left).",
951 LOGF_INFO(
"Using long exposure mode for %.3f sec frame.", duration);
954 LOGF_INFO(
"Started %.3f-second long exposure.", duration);
960 "Unable to start %.3f-second long exposure, falling back to auto exposure", duration);
979 LOGF_INFO(
"Started %.3f-second manual exposure.", duration);
984 LOGF_WARN(
"Failed %.3f-second manual exposure, no adequate control is registered.",
1004 long ticks = lround(duration * 10000.0f);
1007 bool ioptron_maximum_duration_exceeded =
false;
1019 ioptron_maximum_duration_exceeded =
true;
1032 LOGF_WARN(
"Absolute exposure duration control is undefined, stacking up to %.3f seconds using %.16s.",
1037 IDLog(
"Interval = %d %d\n", fn,
fd);
1038 ticks = (long)(10000.0 * (
float)fn / (
float)
fd + 0.5);
1046 LOG_ERROR(
"Absolute exposure duration control is undefined and tacking is not supported");
1053 LOGF_ERROR(
"Failed exposing, the absolute exposure duration control is undefined, and stacking is not ready.",
"");
1054 LOGF_ERROR(
"Configure grayscale and stacking in order to stack streamed frames up to %.3f seconds.", duration);
1059 else if (
AbsExposureN->max < ticks || ioptron_maximum_duration_exceeded)
1063 LOG_WARN(
"Requested manual exposure is out of device bounds auto set stackMode to ADDITIVE" );
1076 LOGF_WARN(
"Requested manual exposure is out of device bounds [%.3f,%.3f], stacking up to %.3f seconds using %.16s.",
1096 LOGF_ERROR(
"Failed %.3f-second manual exposure, out of device bounds [%.3f,%.3f], and stacking is not ready.",
1098 LOGF_ERROR(
"Configure grayscale and stacking in order to stack streamed frames up to %.3f seconds.", duration);
1140 if (
v4l_base->setOPTControl(ctrl_id, ctrlindex, errmsg) < 0)
1147 LOGF_ERROR(
"Unable to adjust manual/auto exposure control. %s", errmsg);
1157 LOGF_WARN(
"Failed switching to manual exposure, control is unavailable",
"");
1168 LOGF_DEBUG(
"%.3f-second exposure translates to %ld 1/10,000th-second device ticks.",
1171 unsigned int const ctrl_id = *((
unsigned int *)
AbsExposureN->aux0);
1187 LOGF_ERROR(
"Failed %.3f-second manual exposure, out of device bounds [%.3f,%.3f].",
1204 if (1.0f < remaining)
1233 LOG_WARN(
"Cannot start exposure while streaming is in progress");
1239 LOGF_WARN(
"Cannot start exposure while another is in progress (%.3f seconds left)",
1247 if (
v4l_base->start_capturing(errmsg))
1249 LOGF_WARN(
"V4L2 base failed starting capture (%s)", errmsg);
1270 LOG_WARN(
"No exposure or streaming in progress");
1284 LOGF_WARN(
"Stopping running exposure %.3f seconds before completion",
1292 if (
v4l_base->stop_capturing(errmsg))
1294 LOGF_WARN(
"V4L2 base failed stopping capture (%s)", errmsg);
1306 return (
lx->startLx());
1314 if (p->lx->getLxmode() ==
LXSERIAL)
1323 if (!p->v4l_base->isstreamactive())
1324 p->is_capturing = p->start_capturing(
false);
1331 if (hor == 1 && ver == 1)
1338 LOG_WARN(
"Binning color frames is currently not supported.");
1344 LOGF_WARN(
"Cannot accept asymmetrical binning %dx%d.", hor, ver);
1348 if (hor != 1 && hor != 2 && hor != 4)
1350 LOG_WARN(
"Can only accept 1x1, 2x2, and 4x4 binning.");
1356 LOG_WARN(
"Cannot change binning while streaming/recording.");
1372 if (
v4l_base->setcroprect(x, y, w, h, errmsg) != -1)
1374 struct v4l2_rect crect;
1386 LOGF_INFO(
"ERROR (setcroprect): %s", errmsg);
1403 float const * src =
v4l_base->getLinearY();
1404 float const *
const end =
v4l_base->getLinearY() + size;
1405 float * dest =
V4LFrame->stackedFrame;
1410 V4LFrame->stackedFrame = (
float *)malloc(
sizeof(
float) * size);
1411 memcpy(
V4LFrame->stackedFrame, src,
sizeof(
float) * size);
1417 float const frameMax = std::numeric_limits<float>::max();
1418 while (src < end)
if (frameMax - *dest < *src)
1423 else *dest++ += *src++;
1430 struct timeval now = { .tv_sec = 0, .tv_usec = 0 }, duration = { .tv_sec = 0, .tv_usec = 0 };
1431 gettimeofday( &now,
nullptr );
1438 struct timeval remaining = { .tv_sec = 0, .tv_usec = 0 };
1440 return (
float) remaining.tv_sec + (float) remaining.tv_usec / 1000000.0f;
1447 timersub(&
frame_received, ¤t_frame_duration, ¤t_frame_duration);
1454 int height =
v4l_base->getHeight();
1458 unsigned char * buffer =
nullptr;
1462 if (
v4l_base->getFormat() == V4L2_PIX_FMT_MJPEG)
1465 auto buffer =
v4l_base->getMJPEGBuffer(totalBytes);
1469 memcpy(
PrimaryCCD.getFrameBuffer(), buffer, totalBytes);
1473 Streamer->newFrame(buffer, totalBytes);
1480 totalBytes = width * height * (dbpp / 8);
1486 totalBytes = width * height * (dbpp / 8) * 3;
1493 unsigned short * src = (
unsigned short *)buffer;
1494 unsigned char * dest = buffer;
1495 unsigned char shift = 0;
1508 for (
int i = 0; i < totalBytes; i++)
1510 *dest++ = *(src++) >> shift;
1515 unsigned char * src = (
unsigned char *)buffer + 1;
1517 for (
int i = 0; i < totalBytes; i++)
1527 memcpy(
PrimaryCCD.getFrameBuffer(), buffer, totalBytes);
1545 LOG_DEBUG(
"Skip frame, setup not complete yet" );
1549 struct timeval capture_frame_dif = { .tv_sec = 0, .tv_usec = 0 };
1552 float time_since_capture_started = (float) capture_frame_dif.tv_sec + (
float) capture_frame_dif.tv_usec / 1000000.0f;
1555 if( time_since_capture_started < expected_frame_duration * 0.9 )
1557 LOGF_DEBUG(
"Skip early frame cfd = %ld.%06ld seconds.", capture_frame_dif.tv_sec, capture_frame_dif.tv_usec);
1569 LOGF_INFO(
"Frame took %ld.%06ld s, e = %ld.%06ld s, t = %ld.%06ld s., cfd = %ld.%06ld s.",
1570 current_frame_duration.tv_sec, current_frame_duration.tv_usec,
1573 capture_frame_dif.tv_sec, capture_frame_dif.tv_usec
1597 auto buffer =
v4l_base->getMJPEGBuffer(totalBytes);
1600 memcpy(
PrimaryCCD.getFrameBuffer(), buffer, totalBytes);
1601 PrimaryCCD.setFrameBufferSize(totalBytes,
false);
1610 unsigned char * src, *dest;
1612 dest = (
unsigned char *)
PrimaryCCD.getFrameBuffer();
1624 float * src =
V4LFrame->stackedFrame;
1629 float * dark =
V4LFrame->darkFrame;
1649 unsigned char * dest = (
unsigned char *)
PrimaryCCD.getFrameBuffer();
1653 *dest++ = (
unsigned char)((*src++ * 255.0f) /
subframeCount);
1659 unsigned short * dest = (
unsigned short *)
PrimaryCCD.getFrameBuffer();
1663 *dest++ = (
unsigned short)((*src++ * 65535.0f) /
subframeCount);
1676 unsigned char * dest = (
unsigned char *)
PrimaryCCD.getFrameBuffer();
1681 *dest++ = *src < 1.0f ? (
unsigned char)((*src * 255)) : 255;
1689 unsigned short * dest = (
unsigned short *)
PrimaryCCD.getFrameBuffer();
1693 *dest++ = *src < 1.0f ? (
unsigned short)((*src * 65535)) : 65535;
1703 if (
V4LFrame->darkFrame !=
nullptr)
1711 unsigned char * dest = (
unsigned char *)
PrimaryCCD.getFrameBuffer();
1715 *dest++ = (
unsigned char)((*src++ * 255));
1721 unsigned short * dest = (
unsigned short *)
PrimaryCCD.getFrameBuffer();
1725 *dest++ = (
unsigned short)((*src++ * 65535));
1738 unsigned char * src =
v4l_base->getRGBBuffer();
1739 unsigned char * dest =
PrimaryCCD.getFrameBuffer();
1741 unsigned char * red = dest;
1747 *(red++) = *(src + i);
1748 *(green++) = *(src + i + 1);
1749 *(blue++) = *(src + i + 2);
1757 if (
lx->isEnabled())
1763 LOGF_INFO(
"Capture of LX frame took %ld.%06ld seconds.", current_exposure.tv_sec, current_exposure.tv_usec);
1775 LOGF_DEBUG(
"%s: streamer is busy, continue capturing\n", __FUNCTION__);
1779 LOGF_INFO(
"Capture of one frame (%d stacked frames) took %ld.%06ld seconds.",
subframeCount, current_exposure.tv_sec,
1780 current_exposure.tv_usec);
1795 LOGF_WARN(
"%s: frame received while not exposing, force-aborting capture", __FUNCTION__);
1803 if (
lx->isEnabled())
1815 LOG_WARN(
"Cannot abort exposure while video streamer is busy, stop streaming first");
1826 LOGF_ERROR(
"Error: unable to open device %s: %s",
PortT[0].text, errmsg);
1840 if (!(strcmp((
const char *)
v4l_base->cap.driver,
"pwc")))
1842 "To use LED Long exposure mode with recent kernels, see https://code.google.com/p/pwc-lxled/");
1867 int inputindex = -1, formatindex = -1;
1868 struct v4l2_fract frate;
1872 std::string deviceName = std::string(
v4l_base->getDeviceName());
1874 std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
1875 while (info->deviceName)
1877 std::string infoDeviceName = std::string(info->deviceName);
1878 std::transform(infoDeviceName.begin(), infoDeviceName.end(), infoDeviceName.begin(), ::tolower);
1879 std::string infoDeviceLabel = std::string(info->deviceLabel);
1880 std::transform(infoDeviceLabel.begin(), infoDeviceLabel.end(), infoDeviceLabel.begin(), ::tolower);
1883 if (infoDeviceName == deviceName || infoDeviceLabel == deviceName)
1899 auto captureSizeChangeRequired =
true;
1903 uint32_t w = 0, h = 0;
1904 if (sscanf(name,
"%ux%u", &w, &h) == 2)
1907 captureSizeChangeRequired =
false;
1912 if (captureSizeChangeRequired)
1914 auto resolution = std::to_string(
m_Info->width) +
"x" + std::to_string(
m_Info->height);
1919 const char * names[] = { resolution.c_str() };
1934 if (inputindex >= 0 && formatindex >= 0)
1935 LOGF_INFO(
"Found initial Input \"%s\", Format \"%s\", Size %dx%d, Frame interval %d/%ds",
1939 LOGF_INFO(
"Found initial size %dx%d, frame interval %d/%ds", w, h, frate.numerator,
1944#ifdef WITH_V4L2_EXPERIMENTS
1961 uint8_t pixelDepth = 8;
1963 Streamer->setPixelFormat(pixelFormat, pixelDepth);
1972 LOG_DEBUG(
"Enumerating V4L2 controls...");
1996 if (strcmp(
ImageAdjustNP.np[i].label,
"Exposure (Absolute)") == 0 ||
1997 strcmp(
ImageAdjustNP.np[i].label,
"Exposure Time, Absolute") == 0 ||
2011 if (strcmp(
Options[i].label,
"Exposure, Auto") == 0 || strcmp(
Options[i].label,
"Auto Exposure") == 0)
2020 LOG_WARN(
"Absolute exposure duration control is not possible on the device!");
2023 LOG_WARN(
"Manual/auto exposure control is not possible on the device!");
2032 LOG_ERROR(
"Critical Error: Unable to initialize driver. Low memory.");
2053 LOG_WARN(
"Cannot stream binned color frame.");
2058 if (onSwitch && strstr(onSwitch->label,
"JPEG"))
2069 LOGF_WARN(
"Cannot stop streaming, exposure running (%.1f seconds remaining)",
2092 if (format.isValid())
2107 return Streamer->saveConfigItems(fp);
2116 case V4L2_PIX_FMT_GREY:
2117#ifdef V4L2_PIX_FMT_Y10
2118 case V4L2_PIX_FMT_Y10:
2120#ifdef V4L2_PIX_FMT_Y12
2121 case V4L2_PIX_FMT_Y12:
2123#ifdef V4L2_PIX_FMT_Y16
2124 case V4L2_PIX_FMT_Y16:
2127#ifdef V4L2_PIX_FMT_Y10
2128 if (v4l2format == V4L2_PIX_FMT_Y10)
2131#ifdef V4L2_PIX_FMT_Y12
2132 if (v4l2format == V4L2_PIX_FMT_Y12)
2135#ifdef V4L2_PIX_FMT_Y16
2136 if (v4l2format == V4L2_PIX_FMT_Y16)
2140 case V4L2_PIX_FMT_SBGGR8:
2141#ifdef V4L2_PIX_FMT_SBGGR10
2142 case V4L2_PIX_FMT_SBGGR10:
2144#ifdef V4L2_PIX_FMT_SBGGR12
2145 case V4L2_PIX_FMT_SBGGR12:
2147 case V4L2_PIX_FMT_SBGGR16:
2149#ifdef V4L2_PIX_FMT_SBGGR10
2150 if (v4l2format == V4L2_PIX_FMT_SBGGR10)
2153#ifdef V4L2_PIX_FMT_SBGGR12
2154 if (v4l2format == V4L2_PIX_FMT_SBGGR12)
2157 if (v4l2format == V4L2_PIX_FMT_SBGGR16)
2160 case V4L2_PIX_FMT_SGBRG8:
2161#ifdef V4L2_PIX_FMT_SGBRG10
2162 case V4L2_PIX_FMT_SGBRG10:
2164#ifdef V4L2_PIX_FMT_SGBRG12
2165 case V4L2_PIX_FMT_SGBRG12:
2168#ifdef V4L2_PIX_FMT_SGBRG10
2169 if (v4l2format == V4L2_PIX_FMT_SGBRG10)
2172#ifdef V4L2_PIX_FMT_SGBRG12
2173 if (v4l2format == V4L2_PIX_FMT_SGBRG12)
2177#if defined(V4L2_PIX_FMT_SGRBG8) || defined(V4L2_PIX_FMT_SGRBG10) || defined(V4L2_PIX_FMT_SGRBG12)
2178#ifdef V4L2_PIX_FMT_SGRBG8
2179 case V4L2_PIX_FMT_SGRBG8:
2181#ifdef V4L2_PIX_FMT_SGRBG10
2182 case V4L2_PIX_FMT_SGRBG10:
2184#ifdef V4L2_PIX_FMT_SGRBG12
2185 case V4L2_PIX_FMT_SGRBG12:
2188#ifdef V4L2_PIX_FMT_SGRBG10
2189 if (v4l2format == V4L2_PIX_FMT_SGRBG10)
2193#ifdef V4L2_PIX_FMT_SGRBG12
2194 if (v4l2format == V4L2_PIX_FMT_SGRBG12)
2199#if defined(V4L2_PIX_FMT_SRGGB8) || defined(V4L2_PIX_FMT_SRGGB10) || defined(V4L2_PIX_FMT_SRGGB12)
2200#ifdef V4L2_PIX_FMT_SRGGB8
2201 case V4L2_PIX_FMT_SRGGB8:
2203#ifdef V4L2_PIX_FMT_SRGGB10
2204 case V4L2_PIX_FMT_SRGGB10:
2206#ifdef V4L2_PIX_FMT_SRGGB12
2207 case V4L2_PIX_FMT_SRGGB12:
2210#ifdef V4L2_PIX_FMT_SRGGB10
2211 if (v4l2format == V4L2_PIX_FMT_SRGGB10)
2214#ifdef V4L2_PIX_FMT_SRGGB12
2215 if (v4l2format == V4L2_PIX_FMT_SRGGB12)
2220 case V4L2_PIX_FMT_RGB24:
2223 case V4L2_PIX_FMT_BGR24:
2235 LOG_WARN(
"Can not set Image type (GRAY/COLOR) while recording.");
Property getProperty(const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN) const
Return a property and its type given its name.
void setDeviceName(const char *dev)
Set the device name.
void setExposureLeft(double duration)
setExposureLeft Update exposure time left. Inform the client of the new exposure time left value.
uint32_t GetCCDCapability() const
GetCCDCapability returns the CCD capabilities.
std::unique_ptr< StreamManager > Streamer
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool ExposureComplete(CCDChip *targetChip)
Uploads target Chip exposed buffer as FITS to the client. Derived classes should class this function ...
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
INDI::PropertySwitch EncodeFormatSP
Specifies Driver image encoding format (FITS, Native, JPG, ..etc).
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual void addCaptureFormat(const CaptureFormat &format)
addCaptureFormat Add a supported camera native capture format (e.g. Mono, Bayer8.....
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save configuration items in XML file.
INDI::PropertySwitch CaptureFormatSP
Specifies Camera NATIVE capture format (e.g. Mono, RGB, RAW8..etc).
void SetCCDCapability(uint32_t cap)
SetCCDCapability Set the CCD capabilities. All fields must be initialized.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual void SetCCDParams(int x, int y, int bpp, float xf, float yf)
Setup CCD parameters for primary CCD. Child classes call this function to update CCD parameters.
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
void addDebugControl()
Add Debug control to the driver.
bool setManualExposure(double duration)
ITextVectorProperty camNameTP
virtual bool StopStreaming() override
StopStreaming Stop live video streaming.
virtual const char * getDefaultName() override
virtual bool StartStreaming() override
StartStreaming Start live video streaming.
ITextVectorProperty CaptureColorSpaceTP
INDI::PropertySwitch StackModeSP
INumberVectorProperty FrameRateNP
virtual void getBasicData()
struct timeval getElapsedExposure() const
struct timeval exposure_duration
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
INumberVectorProperty CaptureSizesNP
struct timeval frame_received
bool setShutter(double duration)
ISwitchVectorProperty FrameRatesSP
virtual void updateV4L2Controls()
virtual bool Disconnect() override
Disconnect from device.
INumberVectorProperty ImageAdjustNP
ISwitchVectorProperty InputsSP
bool startlongexposure(double timeinsec)
ISwitchVectorProperty CaptureFormatsSP
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool UpdateCCDFrame(int x, int y, int w, int h) override
CCD calls this function when CCD Frame dimension needs to be updated in the hardware....
ITextVectorProperty PortTP
virtual void initCamBase()
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool AbortExposure() override
Abort ongoing exposure.
ISwitchVectorProperty ImageDepthSP
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool StartExposure(float duration) override
Start exposing primary CCD chip.
char defaultVideoPort[256]
bool valid_frame_has_arrived
unsigned int non_capture_frames
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
struct timeval frame_duration
static void newFrame(void *p)
struct timeval capture_start
ISwitchVectorProperty CaptureSizesSP
bool updateCaptureSize(uint32_t width, uint32_t height)
struct timeval elapsed_exposure
ISwitchVectorProperty ColorProcessingSP
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
ISwitchVectorProperty * ManualExposureSP
void iOptronWatchdogCallback()
virtual ~V4L2_Driver() override
virtual bool UpdateCCDBin(int hor, int ver) override
CCD calls this function when CCD Binning needs to be updated in the hardware. Derived classes should ...
INDI::Timer ioptron_watchdog_timer
IText CaptureColorSpaceT[3]
bool start_capturing(bool do_stream)
virtual bool SetCaptureFormat(uint8_t index) override
SetCaptureFormat Set Active Capture format.
INDI::V4L2_Base * v4l_base
static void stdtimerCallback(void *userpointer)
unsigned int v4ladjustments
bool getPixelFormat(uint32_t v4l2format, INDI_PIXEL_FORMAT &pixelFormat, uint8_t &pixelDepth)
float getRemainingExposure() const
static void lxtimerCallback(void *userpointer)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save configuration items in XML file.
ISwitch ColorProcessingS[3]
ISwitchVectorProperty * Options
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
void IE_TCF(void *userpointer)
Signature of a timeout caller.
void IERmTimer(int timerid)
Remove the timer with the given timerid, as returned from IEAddTimer() or IEAddPeriodicTimer().
int IEAddTimer(int millisecs, IE_TCF *fp, void *p)
Register a new single-shot timer function, fp, to be called with ud as argument after ms.
#define NARRAY(a)
Handy macro to find the number of elements in array a[]. Must be used with actual array,...
const char * IMAGE_SETTINGS_TAB
const char * IMAGE_INFO_TAB
void IDLog(const char *fmt,...)
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
ISwitch * IUFindSwitch(const ISwitchVectorProperty *svp, const char *name)
Find an ISwitch member in a vector switch property.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
ISwitch * IUFindOnSwitch(const ISwitchVectorProperty *svp)
Returns the first ON switch it finds in the vector switch property.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
const char * IUFindOnSwitchName(ISState *states, char *names[], int n)
Returns the name of the first ON switch it finds in the supplied arguments.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUGetConfigOnSwitchName(const char *dev, const char *property, char *name, size_t size)
IUGetConfigOnSwitchLabel Opens configuration file and returns the name of the ON switch property,...
int IUGetConfigText(const char *dev, const char *property, const char *member, char *value, int len)
IUGetConfigText Opens configuration file and reads single text property.
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
#define LOGF_WARN(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)
#define DEBUGF(priority, msg,...)
const char * DEVICE_PORT
Device serial (or bluetooth) connection port. The default value on Linux is /dev/ttyUSB0 while on Mac...
Namespace to encapsulate INDI client, drivers, and mediator classes.
*brief create JSON pointer *sa reference_tokens const string_t & a
const char * getColorSpaceName(struct v4l2_format *fmt)
const char * getQuantizationName(struct v4l2_format *fmt)
const char * getYCbCrEncodingName(struct v4l2_format *fmt)
int findIndexOfNearestValue(double value, const double allowed_values[])
#define IOPTRON_ABS_EXPOSURE_CTRL_ID
#define MAX_IOPTRON_DURATION
#define IOPTRON_WATCHDOG_PERIOD_IN_MS
#define MAX_IOPTRON_TICKS