adsd3500_sensor.cpp
Go to the documentation of this file.
1 /********************************************************************************/
2 /* */
3 /* Copyright (c) 2020 Analog Devices, Inc. All Rights Reserved. */
4 /* This software is proprietary to Analog Devices, Inc. and its licensors. */
5 /* */
6 /********************************************************************************/
7 #include "adsd3500_sensor.h"
10 #include "gpio.h"
12 #include "utils.h"
13 #include "utils_ini.h"
14 
15 #include <algorithm>
16 #include <arm_neon.h>
17 #include <cmath>
18 #include <fcntl.h>
19 #include <fstream>
20 #ifdef USE_GLOG
21 #include <glog/logging.h>
22 #else
23 #include <aditof/log.h>
24 #include <cstring>
25 #include <unistd.h>
26 #endif
27 #include "tofi/tofi_config.h"
28 #include <dirent.h>
29 #include <linux/videodev2.h>
30 #include <signal.h>
31 #include <sstream>
32 #include <sys/ioctl.h>
33 #include <sys/mman.h>
34 #include <sys/stat.h>
35 #include <thread>
36 #include <unordered_map>
37 
38 #define MAX_SUBFRAMES_COUNT \
39  10 // maximum number of subframes that are used to create a full frame (maximum total_captures of all modes)
40 #define EXTRA_BUFFERS_COUNT \
41  3 // how many extra buffers are sent to the driver in addition to the total_captures of a mode
42 
43 #define CLEAR(x) memset(&(x), 0, sizeof(x))
44 
45 #define V4L2_CID_AD_DEV_CHIP_CONFIG (0x9819e1)
46 #define CTRL_PACKET_SIZE 65537
47 #define CTRL_SET_MODE (0x9819e0)
48 #define CTRL_AB_AVG (0x9819e5)
49 #define CTRL_DEPTH_EN (0x9819e6)
50 #define CTRL_PHASE_DEPTH_BITS (0x9819e2)
51 #define CTRL_AB_BITS (0x9819e3)
52 #define CTRL_CONFIDENCE_BITS (0x9819e4)
53 #ifdef NVIDIA
54 #define CTRL_SET_FRAME_RATE (0x9a200b)
55 #endif
56 #define ADSD3500_CTRL_PACKET_SIZE 4099
57 // Can be moved to target_definitions in "camera"/"platform"
58 #define TEMP_SENSOR_DEV_PATH "/dev/i2c-1"
59 #define LASER_TEMP_SENSOR_I2C_ADDR 0x49
60 #define AFE_TEMP_SENSOR_I2C_ADDR 0x4b
61 
62 #define ADI_DEBUG 1
63 #define REQ_COUNT 10
64 
65 #define NR_OF_MODES_FROM_CCB 10
66 #define SIZE_OF_MODES_FROM_CCB 256
67 
68 uint16_t chip_id;
69 uint8_t mode_num;
70 
71 struct CalibrationData {
73  float gain;
74  float offset;
75  uint16_t *cache;
76 };
77 
79  uint16_t id;
80  uint16_t ver;
81  uint32_t size;
82  uint16_t burst_layout;
83  uint16_t burst_num;
84  uint16_t burst_setup[4];
85  uint16_t start_address;
86  uint16_t rsvd;
87  uint32_t values;
88 };
89 
90 enum class SensorImagerType {
95 };
96 
98 
100  uint8_t numVideoDevs;
103  std::unordered_map<std::string, __u32> controlsCommands;
107 
109  : numVideoDevs(1),
111  ccbVersion{CCBVersion::CCB_UNKNOWN}, modeDetails{0, {}, 0, 0, 0, 0,
112  0, 0, 0, 0, {}} {}
113 };
114 
115 // TO DO: This exists in linux_utils.h which is not included on Dragoboard.
116 // Should not have duplicated code if possible.
117 static int xioctl(int fh, unsigned int request, void *arg) {
118  int r;
119  int tries = 3;
120 
121  do {
122  r = ioctl(fh, request, arg);
123  } while (--tries > 0 && r == -1 && EINTR == errno);
124 
125  return r;
126 }
127 
129  const std::string &driverSubPath,
130  const std::string &captureDev)
131  : m_driverPath(driverPath), m_driverSubPath(driverSubPath),
132  m_captureDev(captureDev), m_implData(new Adsd3500Sensor::ImplData),
133  m_firstRun(true), m_adsd3500Queried(false), m_depthComputeOnTarget(true),
134  m_chipStatus(0), m_imagerStatus(0),
135  m_hostConnectionType(aditof::ConnectionType::ON_TARGET) {
136  m_sensorName = "adsd3500";
138  m_sensorDetails.id = driverPath;
139  m_sensorConfiguration = "standard";
140 
141  // Define the controls that this sensor has available
142  m_controls.emplace("abAveraging", "0");
143  m_controls.emplace("depthEnable", "0");
144  m_controls.emplace("phaseDepthBits", "0");
145  m_controls.emplace("abBits", "0");
146  m_controls.emplace("confidenceBits", "0");
147  m_controls.emplace("fps", "0");
148  m_controls.emplace("imagerType", "");
149  m_controls.emplace("inputFormat", "");
150  m_controls.emplace("netlinktest", "0");
151  m_controls.emplace("depthComputeOpenSource", "0");
152  m_controls.emplace("disableCCBM", "0");
153  m_controls.emplace("availableCCBM", "0");
154 
155  // Define the commands that correspond to the sensor controls
156  m_implData->controlsCommands["abAveraging"] = 0x9819e5;
157  m_implData->controlsCommands["depthEnable"] = 0x9819e6;
158  m_implData->controlsCommands["phaseDepthBits"] = 0x9819e2;
159  m_implData->controlsCommands["abBits"] = 0x9819e3;
160  m_implData->controlsCommands["confidenceBits"] = 0x9819e4;
161 
163 }
164 
166  struct VideoDev *dev;
167 
168  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
169  dev = &m_implData->videoDevs[i];
170  if (dev->started) {
171  stop();
172  }
173  }
174 
175  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
176  dev = &m_implData->videoDevs[i];
177 
178  for (unsigned int i = 0; i < dev->nVideoBuffers; i++) {
179  if (munmap(dev->videoBuffers[i].start,
180  dev->videoBuffers[i].length) == -1) {
181  LOG(WARNING)
182  << "munmap error "
183  << "errno: " << errno << " error: " << strerror(errno);
184  }
185  }
186  free(dev->videoBuffers);
187 
188  if (dev->fd != -1) {
189  if (close(dev->fd) == -1) {
190  LOG(WARNING)
191  << "close m_implData->fd error "
192  << "errno: " << errno << " error: " << strerror(errno);
193  }
194  }
195 
196  if (dev->sfd != -1) {
197  if (close(dev->sfd) == -1) {
198  LOG(WARNING)
199  << "close m_implData->sfd error "
200  << "errno: " << errno << " error: " << strerror(errno);
201  }
202  }
203  }
204 
205  delete m_bufferProcessor;
206 }
207 
209  using namespace aditof;
210  Status status = Status::OK;
211 
212  // Subscribe to ADSD3500 interrupts
213  if (Adsd3500InterruptNotifier::getInstance().interruptsAvailable()) {
214  std::weak_ptr<Adsd3500Sensor> wptr = shared_from_this();
216  }
217 
218  LOG(INFO) << "Opening device";
219 
220  struct stat st;
221  struct v4l2_capability cap;
222  struct VideoDev *dev;
223 
224  const char *devName, *subDevName, *cardName;
225 
226  std::vector<std::string> driverPaths;
227  Utils::splitIntoTokens(m_driverPath, '|', driverPaths);
228 
229  std::vector<std::string> driverSubPaths;
230  Utils::splitIntoTokens(m_driverSubPath, '|', driverSubPaths);
231 
232  std::vector<std::string> cards;
233  std::string captureDeviceName(m_captureDev);
234  Utils::splitIntoTokens(captureDeviceName, '|', cards);
235 
236  LOG(INFO) << "Looking for the following cards:";
237  for (const auto card : cards) {
238  LOG(INFO) << card;
239  }
240 
241  m_implData->numVideoDevs = driverSubPaths.size();
242  m_implData->videoDevs = new VideoDev[m_implData->numVideoDevs];
243 
244  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
245  devName = driverPaths.at(i).c_str();
246  subDevName = driverSubPaths.at(i).c_str();
247  cardName = cards.at(i).c_str();
248  dev = &m_implData->videoDevs[i];
249 
250  LOG(INFO) << "device: " << devName << "\tsubdevice: " << subDevName;
251 
252  //Don't open the video device for UVC context. It is opened in uvc-app/lib/v4l2.c
253  if (m_hostConnectionType != ConnectionType::USB) {
254  /* Open V4L2 device */
255  if (stat(devName, &st) == -1) {
256  LOG(WARNING)
257  << "Cannot identify " << devName << "errno: " << errno
258  << "error: " << strerror(errno);
259  return Status::GENERIC_ERROR;
260  }
261 
262  if (!S_ISCHR(st.st_mode)) {
263  LOG(WARNING) << devName << " is not a valid device";
264  return Status::GENERIC_ERROR;
265  }
266 
267  dev->fd = ::open(devName, O_RDWR | O_NONBLOCK, 0);
268  if (dev->fd == -1) {
269  LOG(WARNING) << "Cannot open " << devName << "errno: " << errno
270  << "error: " << strerror(errno);
271  return Status::GENERIC_ERROR;
272  }
273 
274  if (xioctl(dev->fd, VIDIOC_QUERYCAP, &cap) == -1) {
275  LOG(WARNING) << devName << " VIDIOC_QUERYCAP error";
276  return Status::GENERIC_ERROR;
277  }
278 
279  if (strncmp((char *)cap.card, cardName, strlen(cardName))) {
280  LOG(WARNING) << "CAPTURE Device " << cap.card;
281  LOG(WARNING) << "Read " << cardName;
282  return Status::GENERIC_ERROR;
283  }
284 
285  if (!(cap.capabilities &
286  (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE))) {
287  LOG(WARNING) << devName << " is not a video capture device";
288  return Status::GENERIC_ERROR;
289  }
290 
291  if (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) {
292  dev->videoBuffersType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
293  } else {
294  dev->videoBuffersType = V4L2_BUF_TYPE_VIDEO_CAPTURE;
295  }
296 
297  if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
298  LOG(WARNING) << devName << " does not support streaming i/o";
299  return Status::GENERIC_ERROR;
300  }
301  }
302  /* Open V4L2 subdevice */
303  if (stat(subDevName, &st) == -1) {
304  LOG(WARNING) << "Cannot identify " << subDevName
305  << " errno: " << errno
306  << " error: " << strerror(errno);
307  return Status::GENERIC_ERROR;
308  }
309 
310  if (!S_ISCHR(st.st_mode)) {
311  LOG(WARNING) << subDevName << " is not a valid device";
312  return Status::GENERIC_ERROR;
313  }
314 
315  dev->sfd = ::open(subDevName, O_RDWR | O_NONBLOCK);
316  if (dev->sfd == -1) {
317  LOG(WARNING) << "Cannot open " << subDevName << " errno: " << errno
318  << " error: " << strerror(errno);
319  return Status::GENERIC_ERROR;
320  }
321 
322  //Check chip status and reset if there are any errors.
323  if (m_firstRun) {
326  uint16_t chipID;
327  uint8_t dealiasCheck[32] = {0};
328  dealiasCheck[0] = 1;
329 
330  for (int i = 0; i < 10; i++) {
331 #ifdef DUAL
332  chipIDStatus = adsd3500_read_cmd(0x0116, &chipID, 110 * 1000);
333 #else
334  chipIDStatus = adsd3500_read_cmd(0x0112, &chipID);
335 #endif
336  if (chipIDStatus != Status::OK) {
337  LOG(INFO) << "Could not read chip ID. Resetting ADSD3500 "
338  "to handle previous error.";
339  adsd3500_reset();
340  }
341 
342  chip_id = chipID;
343 
344  dealiasStatus =
345  adsd3500_read_payload_cmd(0x02, dealiasCheck, 32);
346  if (dealiasStatus != Status::OK) {
347  LOG(INFO) << "Could not read Dealias Parameters. Resetting "
348  "ADSD3500 "
349  "to handle previous error.";
350  adsd3500_reset();
351  continue;
352  }
353 
354  if (chipIDStatus == aditof::Status::OK &&
355  dealiasStatus == aditof::Status::OK) {
356  LOG(INFO) << "ADSD3500 is ready to communicate with.";
357  break;
358  }
359  }
360 
361  if (chipIDStatus != aditof::Status::OK) {
362  LOG(ERROR) << "Cannot read chip id! Latest ADSD3500 "
363  "programming might not be succesful";
364  return chipIDStatus;
365  }
366 
367  if (dealiasStatus != aditof::Status::OK) {
368  LOG(ERROR) << "Cannot read dealias parameters! Latest ADSD3500 "
369  "programming might not be succesful";
370  return dealiasStatus;
371  }
372 
373  m_firstRun = false;
374  }
375  }
376 
377  if (!m_adsd3500Queried) {
378  status = queryAdsd3500();
379  m_adsd3500Queried = true;
380  }
381 
382  status = m_bufferProcessor->setInputDevice(m_implData->videoDevs);
383  if (status != Status::OK) {
384  LOG(ERROR) << "Failed to set input video device!";
385  return status;
386  }
387 
388  status = m_bufferProcessor->open();
389  if (status != Status::OK) {
390  LOG(ERROR) << "Failed to open output video device!";
391  return status;
392  }
393 
394  return status;
395 }
396 
398  using namespace aditof;
399  Status status = Status::OK;
400  struct VideoDev *dev;
401  struct v4l2_buffer buf;
402 
403  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
404  dev = &m_implData->videoDevs[i];
405  if (dev->started) {
406  LOG(INFO) << "Device already started";
407  return Status::BUSY;
408  }
409  LOG(INFO) << "Starting device " << i;
410 
411  for (unsigned int i = 0; i < dev->nVideoBuffers; i++) {
412  CLEAR(buf);
413  buf.type = dev->videoBuffersType;
414  buf.memory = V4L2_MEMORY_MMAP;
415  buf.index = i;
416  buf.m.planes = dev->planes;
417  buf.length = 1;
418 
419  if (xioctl(dev->fd, VIDIOC_QBUF, &buf) == -1) {
420  LOG(WARNING)
421  << "mmap error "
422  << "errno: " << errno << " error: " << strerror(errno);
423  return Status::GENERIC_ERROR;
424  }
425  }
426 
427  if (xioctl(dev->fd, VIDIOC_STREAMON, &dev->videoBuffersType) != 0) {
428  LOG(WARNING) << "VIDIOC_STREAMON error "
429  << "errno: " << errno << " error: " << strerror(errno);
430  return Status::GENERIC_ERROR;
431  }
432 
433  dev->started = true;
434  }
435 
436  return status;
437 }
438 
440  using namespace aditof;
441  Status status = Status::OK;
442  struct VideoDev *dev;
443 
444  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
445  dev = &m_implData->videoDevs[i];
446 
447  if (!dev->started) {
448  LOG(INFO) << "Device " << i << " already stopped";
449  return Status::BUSY;
450  }
451  LOG(INFO) << "Stopping device";
452 
453  if (xioctl(dev->fd, VIDIOC_STREAMOFF, &dev->videoBuffersType) != 0) {
454  LOG(WARNING) << "VIDIOC_STREAMOFF error "
455  << "errno: " << errno << " error: " << strerror(errno);
456  return Status::GENERIC_ERROR;
457  }
458 
459  dev->started = false;
460  }
461  return status;
462 }
463 
464 aditof::Status Adsd3500Sensor::getAvailableModes(std::vector<uint8_t> &modes) {
465  modes.clear();
466  for (const auto &availableMode : m_availableModes) {
467 #ifndef ENABLE_PCM
468  if (availableMode.isPCM)
469  continue;
470 #endif
471  modes.emplace_back(availableMode.modeNumber);
472  }
473  return aditof::Status::OK;
474 }
475 
479  using namespace aditof;
480  Status status = Status::OK;
481  for (const auto &modeDetails : m_availableModes) {
482  if (modeDetails.modeNumber == mode) {
483  details = modeDetails;
484  break;
485  }
486  }
487  return status;
488 }
489 
493 
494  status = m_modeSelector.setControl("mode", std::to_string(mode));
495  if (status != aditof::Status::OK) {
496  LOG(ERROR) << "Failed to set control in modeSelector!";
497  return status;
498  }
499 
500  if (m_ccbmEnabled && m_sensorConfiguration == "standard") {
501  bool modeFound = false;
502  for (auto table : m_availableModes) {
503  if (mode == table.modeNumber) {
504  modeTable = table;
505  modeFound = true;
506  break;
507  }
508  }
509 
510  if (!modeFound) {
511  LOG(ERROR) << "Mode not found in ccb!";
513  }
514 
515  } else {
516  status = m_modeSelector.getConfigurationTable(modeTable);
517  if (status != aditof::Status::OK) {
518  LOG(ERROR) << "Failed to get configuration table!";
520  }
521  }
522 
523  status = m_modeSelector.updateConfigurationTable(modeTable);
524  if (status != aditof::Status::OK) {
525  LOG(ERROR) << "Failed to update configuration table for currrent "
526  "configuration";
528  }
529 
530  status = setMode(modeTable);
531  if (status != aditof::Status::OK) {
532  LOG(ERROR) << "Failed to set mode for the current configuration!";
534  }
535 
536  m_implData->modeDetails = modeTable;
537  return aditof::Status::OK;
538 }
539 
542 
543  using namespace aditof;
544  Status status = Status::OK;
545  struct VideoDev *dev;
546 
547  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
548  dev = &m_implData->videoDevs[i];
549  if (dev->started) {
550  stop();
551  }
552  }
553 
554  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
555  dev = &m_implData->videoDevs[i];
556 
557  for (unsigned int i = 0; i < dev->nVideoBuffers; i++) {
558  if (munmap(dev->videoBuffers[i].start,
559  dev->videoBuffers[i].length) == -1) {
560  LOG(WARNING)
561  << "munmap error "
562  << "errno: " << errno << " error: " << strerror(errno);
563  }
564  }
565  free(dev->videoBuffers);
566 
567  if (dev->fd != -1) {
568  if (close(dev->fd) == -1) {
569  LOG(WARNING)
570  << "close m_implData->fd error "
571  << "errno: " << errno << " error: " << strerror(errno);
572  }
573  }
574 
575  if (dev->sfd != -1) {
576  if (close(dev->sfd) == -1) {
577  LOG(WARNING)
578  << "close m_implData->sfd error "
579  << "errno: " << errno << " error: " << strerror(errno);
580  }
581  }
582  }
583 
584  status = open();
585  if (status != aditof::Status::OK) {
586  LOG(INFO) << "Failed to open sensor!";
587  return status;
588  }
589 
590  // Don't request buffers & set fromat for UVC context. It is already done in uvc-app/lib/v4l2.c
591  if (m_hostConnectionType != ConnectionType::USB) {
592  m_capturesPerFrame = 1;
593 
594  for (unsigned int i = 0; i < m_implData->numVideoDevs; i++) {
595  dev = &m_implData->videoDevs[i];
596 
597  //Set mode in chip code block
598  struct v4l2_requestbuffers req;
599  struct v4l2_buffer buf;
600  struct v4l2_format fmt;
601  size_t length, offset;
602 
603  static struct v4l2_control ctrl;
604 
605  memset(&ctrl, 0, sizeof(ctrl));
606 
607  ctrl.id = CTRL_SET_MODE;
608  ctrl.value = type.modeNumber;
609  mode_num = type.modeNumber;
610 
611  if (xioctl(dev->sfd, VIDIOC_S_CTRL, &ctrl) == -1) {
612  LOG(WARNING)
613  << "Setting Mode error "
614  << "errno: " << errno << " error: " << strerror(errno);
615  status = Status::GENERIC_ERROR;
616  return status;
617  }
618 
619  //End of set mode in chip
620 
621  if (type.modeNumber != m_implData->modeDetails.modeNumber) {
622  for (unsigned int i = 0; i < dev->nVideoBuffers; i++) {
623  if (munmap(dev->videoBuffers[i].start,
624  dev->videoBuffers[i].length) == -1) {
625  LOG(WARNING) << "munmap error "
626  << "errno: " << errno
627  << " error: " << strerror(errno);
628  return Status::GENERIC_ERROR;
629  }
630  }
631  free(dev->videoBuffers);
632  dev->nVideoBuffers = 0;
633  CLEAR(req);
634  req.count = 0;
635  req.type = dev->videoBuffersType;
636  req.memory = V4L2_MEMORY_MMAP;
637 
638  if (xioctl(dev->fd, VIDIOC_REQBUFS, &req) == -1) {
639  LOG(WARNING)
640  << "VIDIOC_REQBUFS error "
641  << "errno: " << errno << " error: " << strerror(errno);
642  return Status::GENERIC_ERROR;
643  }
644  } else if (dev->nVideoBuffers) {
645  return status;
646  }
647 
648  __u32 pixelFormat = 0;
649 
650  if (type.pixelFormatIndex == 1) {
651  pixelFormat = V4L2_PIX_FMT_SBGGR12;
652  } else {
653 #ifdef NXP
654  pixelFormat = V4L2_PIX_FMT_SBGGR8;
655 #else
656  pixelFormat = V4L2_PIX_FMT_SRGGB8;
657 #endif
658  }
659 
660  /* Set the frame format in the driver */
661  CLEAR(fmt);
662  fmt.type = dev->videoBuffersType;
663  fmt.fmt.pix.pixelformat = pixelFormat;
664  fmt.fmt.pix.width = type.frameWidthInBytes;
665  fmt.fmt.pix.height = type.frameHeightInBytes;
666  if (xioctl(dev->fd, VIDIOC_S_FMT, &fmt) == -1) {
667  LOG(WARNING) << "Setting Pixel Format error, errno: " << errno
668  << " error: " << strerror(errno);
669  return Status::GENERIC_ERROR;
670  }
671 
672  /* Allocate the video buffers in the driver */
673  CLEAR(req);
675  req.type = dev->videoBuffersType;
676  req.memory = V4L2_MEMORY_MMAP;
677 
678  if (xioctl(dev->fd, VIDIOC_REQBUFS, &req) == -1) {
679  LOG(WARNING)
680  << "VIDIOC_REQBUFS error "
681  << "errno: " << errno << " error: " << strerror(errno);
682  return Status::GENERIC_ERROR;
683  }
684 
685  dev->videoBuffers =
686  (buffer *)calloc(req.count, sizeof(*dev->videoBuffers));
687  if (!dev->videoBuffers) {
688  LOG(WARNING)
689  << "Failed to allocate video m_implData->videoBuffers";
690  return Status::GENERIC_ERROR;
691  }
692 
693  for (dev->nVideoBuffers = 0; dev->nVideoBuffers < req.count;
694  dev->nVideoBuffers++) {
695  CLEAR(buf);
696  buf.type = dev->videoBuffersType;
697  buf.memory = V4L2_MEMORY_MMAP;
698  buf.index = dev->nVideoBuffers;
699  buf.m.planes = dev->planes;
700  buf.length = 1;
701 
702  if (xioctl(dev->fd, VIDIOC_QUERYBUF, &buf) == -1) {
703  LOG(WARNING)
704  << "VIDIOC_QUERYBUF error "
705  << "errno: " << errno << " error: " << strerror(errno);
706  return Status::GENERIC_ERROR;
707  }
708 
709  if (dev->videoBuffersType == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
710  length = buf.length;
711  offset = buf.m.offset;
712  } else {
713  length = buf.m.planes[0].length;
714  offset = buf.m.planes[0].m.mem_offset;
715  }
716 
717  dev->videoBuffers[dev->nVideoBuffers].start =
718  mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED,
719  dev->fd, offset);
720 
721  if (dev->videoBuffers[dev->nVideoBuffers].start == MAP_FAILED) {
722  LOG(WARNING)
723  << "mmap error "
724  << "errno: " << errno << " error: " << strerror(errno);
725  return Status::GENERIC_ERROR;
726  }
727 
729  }
730  }
731  }
732 
733  if (!type.isPCM) {
734  //TO DO: update this values when frame_impl gets restructured
736  type.baseResolutionWidth * 4, type.baseResolutionHeight);
737  if (status != Status::OK) {
738  LOG(ERROR) << "Failed to set bufferProcessor properties!";
739  return status;
740  }
741  }
742 
743  return status;
744 }
745 
747 
748  using namespace aditof;
749  Status status;
750 
751  if (m_depthComputeOnTarget && !m_implData->modeDetails.isPCM) {
752 
754 
755  if (status != Status::OK) {
756  LOG(ERROR) << "Failed to process buffer!";
757  return status;
758  }
759  return status;
760  }
761 
762  struct v4l2_buffer buf[MAX_SUBFRAMES_COUNT];
763  struct VideoDev *dev;
764  unsigned int buf_data_len;
765  uint8_t *pdata;
766  dev = &m_implData->videoDevs[0];
767  m_capturesPerFrame = 1;
768  for (int idx = 0; idx < m_capturesPerFrame; idx++) {
769  status = waitForBufferPrivate(dev);
770  if (status != Status::OK) {
771  return status;
772  }
773 
774  status = dequeueInternalBufferPrivate(buf[idx], dev);
775  if (status != Status::OK) {
776  return status;
777  }
778 
779  status = getInternalBufferPrivate(&pdata, buf_data_len, buf[idx], dev);
780  if (status != Status::OK) {
781  return status;
782  }
783 
784  memcpy(buffer, pdata, buf_data_len);
785 
786  status = enqueueInternalBufferPrivate(buf[idx], dev);
787  if (status != Status::OK) {
788  return status;
789  }
790  }
791 
792  return status;
793 }
794 
796 Adsd3500Sensor::getAvailableControls(std::vector<std::string> &controls) const {
797  controls.clear();
798  controls.reserve(m_controls.size());
799  for (const auto &item : m_controls) {
800  controls.emplace_back(item.first);
801  }
802 
803  return aditof::Status::OK;
804 }
805 
807  const std::string &value) {
808  using namespace aditof;
809  Status status = Status::OK;
810  struct VideoDev *dev = &m_implData->videoDevs[0];
811 
812  if (m_controls.count(control) == 0) {
813  LOG(WARNING) << "Unsupported control";
815  }
816 
817  m_controls[control] = value;
818 
819  if (control == "fps") {
820  int fps = std::stoi(value);
821 #ifdef NVIDIA
822  struct v4l2_ext_control extCtrl;
823  struct v4l2_ext_controls extCtrls;
824  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
825  memset(&extCtrl, 0, sizeof(struct v4l2_ext_control));
826 
827  extCtrls.count = 1;
828  extCtrls.controls = &extCtrl;
829  extCtrl.id = CTRL_SET_FRAME_RATE;
830  extCtrl.value = fps;
831 
832  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
833  LOG(WARNING) << "Failed to set control: " << control << " "
834  << "errno: " << errno << " error: " << strerror(errno);
835  status = Status::GENERIC_ERROR;
836  }
837 #else // NXP
838  struct v4l2_streamparm fpsControl;
839  memset(&fpsControl, 0, sizeof(struct v4l2_streamparm));
840 
841  fpsControl.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
842  fpsControl.parm.capture.timeperframe.numerator = 1;
843  fpsControl.parm.capture.timeperframe.denominator = fps;
844 
845  if (xioctl(dev->fd, VIDIOC_S_PARM, &fpsControl) == -1) {
846  LOG(WARNING) << "Failed to set control: " << control << " "
847  << "errno: " << errno << " error: " << strerror(errno);
848  status = Status::GENERIC_ERROR;
849  }
850 #endif
851 
852  m_sensorFps = fps;
853  status = this->adsd3500_write_cmd(0x22, fps);
854  if (status != Status::OK) {
855  LOG(ERROR) << "Failed to set fps at: " << fps
856  << "via host commands!";
857  return Status::GENERIC_ERROR;
858  }
859 
860  return status;
861  }
862 
863  if (control == "imagerType") {
864  LOG(WARNING) << "Control: " << control << " is read only!";
865  return Status::UNAVAILABLE;
866  }
867 
868  if (control == "depthComputeOpenSource") {
869  LOG(WARNING) << "Control: " << control << " is read only!";
870  return Status::UNAVAILABLE;
871  }
872 
873  if (control == "availableCCBM") {
874  LOG(WARNING) << "Control: " << control << " is read only!";
875  return Status::UNAVAILABLE;
876  }
877 
878  if (control == "disableCCBM") {
879  m_controls.at("disableCCBM") = value;
880  return Status::OK;
881  }
882 
883  std::vector<std::string> convertor = {"0", "4", "8", "10",
884  "12", "14", "16"};
885 
886  if (control == "phaseDepthBits")
887  m_modeSelector.setControl("depthBits", convertor.at(stoi(value)));
888  if (control == "abBits")
889  m_modeSelector.setControl("abBits", convertor.at(stoi(value)));
890  if (control == "confidenceBits")
891  m_modeSelector.setControl("confBits", convertor.at(stoi(value)));
892  if (control == "inputFormat") {
893  m_modeSelector.setControl("inputFormat", value);
894  return Status::OK;
895  }
896  if (control == "netlinktest") {
897  return Status::OK;
898  }
899  // Send the command that sets the control value
900  struct v4l2_control ctrl;
901  memset(&ctrl, 0, sizeof(ctrl));
902 
903  ctrl.id = m_implData->controlsCommands[control];
904  ctrl.value = std::stoi(value);
905 
906  if (xioctl(dev->sfd, VIDIOC_S_CTRL, &ctrl) == -1) {
907  LOG(WARNING) << "Failed to set control: " << control << " "
908  << "errno: " << errno << " error: " << strerror(errno);
909  status = Status::GENERIC_ERROR;
910  }
911 
912  return status;
913 }
914 
916  std::string &value) const {
917  using namespace aditof;
918 
919  if (m_controls.count(control) > 0) {
920  if (control == "imagerType") {
921  value = std::to_string((int)m_implData->imagerType);
922  return Status::OK;
923  }
924 
925  if (control == "depthComputeOpenSource") {
926  value = m_controls.at("depthComputeOpenSource");
927  return Status::OK;
928  }
929 
930  if (control == "inputFormat") {
931  value = m_controls.at("inputFormat");
932  return Status::OK;
933  }
934 
935  if (control == "disableCCBM") {
936  value = m_controls.at("disableCCBM");
937  return Status::OK;
938  }
939 
940  if (control == "availableCCBM") {
941  value = m_ccbmEnabled ? "1" : "0";
942  return Status::OK;
943  }
944 
945  // Send the command that reads the control value
946  struct v4l2_control ctrl;
947  memset(&ctrl, 0, sizeof(ctrl));
948 
949  ctrl.id = m_implData->controlsCommands[control];
950 
951  struct VideoDev *dev = &m_implData->videoDevs[0];
952 
953  if (xioctl(dev->sfd, VIDIOC_G_CTRL, &ctrl) == -1) {
954  LOG(WARNING) << "Failed to get control: " << control << " "
955  << "errno: " << errno << " error: " << strerror(errno);
956  return Status::GENERIC_ERROR;
957  }
958  value = std::to_string(ctrl.value);
959 
960  } else {
961  LOG(WARNING) << "Unsupported control";
963  }
964 
965  return aditof::Status::OK;
966 }
967 
970 
971  details = m_sensorDetails;
972  return aditof::Status::OK;
973 }
974 
976 
977  return aditof::Status::OK;
978 }
979 
981  name = m_sensorName;
982 
983  return aditof::Status::OK;
984 }
985 
988  if (connectionType == "USB") {
990  } else if (connectionType == "NETWORK") {
992  }
993 
994  return aditof::Status::OK;
995 }
996 
998  unsigned int usDelay) {
999  using namespace aditof;
1000  struct VideoDev *dev = &m_implData->videoDevs[0];
1001  Status status = Status::OK;
1002 
1003  static struct v4l2_ext_control extCtrl;
1004  static struct v4l2_ext_controls extCtrls;
1005  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1006 
1007  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1008  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1009  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1010  extCtrls.controls = &extCtrl;
1011  extCtrls.count = 1;
1012 
1013  buf[0] = 1;
1014  buf[1] = 0;
1015  buf[2] = 2;
1016  buf[3] = uint8_t(cmd >> 8);
1017  buf[4] = uint8_t(cmd & 0xFF);
1018  extCtrl.p_u8 = buf;
1019 
1020  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1021  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1022  << " with command: 0x" << std::hex << cmd
1023  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1024  return Status::GENERIC_ERROR;
1025  }
1026 
1027  buf[0] = 0;
1028  buf[1] = 0;
1029  buf[2] = 2;
1030 
1031  extCtrl.p_u8 = buf;
1032 
1033  usleep(usDelay);
1034 
1035  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1036  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1037  << " with command: 0x" << std::hex << cmd
1038  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1039  return Status::GENERIC_ERROR;
1040  }
1041 
1042  if (xioctl(dev->sfd, VIDIOC_G_EXT_CTRLS, &extCtrls) == -1) {
1043  LOG(WARNING) << "Could not get control: 0x" << std::hex << extCtrl.id
1044  << " with command: 0x" << std::hex << cmd
1045  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1046  return Status::GENERIC_ERROR;
1047  }
1048 
1049  *data = (uint16_t)(extCtrl.p_u8[3] << 8) + (uint16_t)(extCtrl.p_u8[4]);
1050 
1051  return status;
1052 }
1053 
1055  unsigned int usDelay) {
1056  using namespace aditof;
1057  struct VideoDev *dev = &m_implData->videoDevs[0];
1058  Status status = Status::OK;
1059 
1060  static struct v4l2_ext_control extCtrl;
1061  static struct v4l2_ext_controls extCtrls;
1062  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1063 
1064  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1065  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1066  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1067  extCtrls.controls = &extCtrl;
1068  extCtrls.count = 1;
1069 
1070  buf[0] = 1;
1071  buf[1] = 0;
1072  buf[2] = 4;
1073  buf[3] = uint8_t(cmd >> 8);
1074  buf[4] = uint8_t(cmd & 0xFF);
1075  buf[5] = uint8_t(data >> 8);
1076  buf[6] = uint8_t(data & 0xFF);
1077  extCtrl.p_u8 = buf;
1078 
1079  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1080  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1081  << " with command: 0x" << std::hex << cmd
1082  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1083  return Status::GENERIC_ERROR;
1084  }
1085 
1086  if (usDelay)
1087  usleep(usDelay);
1088 
1089  return status;
1090 }
1091 
1092 // TO DO: Verify mechanism for read/write burst
1093 
1095  uint8_t *readback_data,
1096  uint16_t payload_len) {
1097  using namespace aditof;
1098  struct VideoDev *dev = &m_implData->videoDevs[0];
1099  Status status = Status::OK;
1100 
1101  //switch to burst mode
1102  uint32_t switchCmd = 0x0019;
1103  uint16_t switchPayload = 0x0000;
1104 
1105  status = adsd3500_write_cmd(switchCmd, switchPayload);
1106  if (status != Status::OK) {
1107  LOG(INFO) << "Failed to switch to burst mode!";
1108  return status;
1109  }
1110 
1111  static struct v4l2_ext_control extCtrl;
1112  static struct v4l2_ext_controls extCtrls;
1113  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1114  memset(buf, 0, ADSD3500_CTRL_PACKET_SIZE * sizeof(uint8_t));
1115 
1116  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1117  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1118 
1119  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1120  extCtrls.controls = &extCtrl;
1121  extCtrls.count = 1;
1122 
1123  buf[0] = 0x01;
1124  buf[1] = 0x00;
1125  buf[2] = 0x10;
1126 
1127  buf[3] = 0xAD;
1128  buf[6] = uint8_t(cmd & 0xFF);
1129 
1130  uint32_t checksum = 0;
1131  for (int i = 0; i < 7; i++) {
1132  checksum += buf[i + 4];
1133  }
1134  memcpy(buf + 11, &checksum, 4);
1135  memcpy(buf + 15, readback_data, 1);
1136  extCtrl.p_u8 = buf;
1137 
1138  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1139  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1140  << " with command: 0x" << std::hex << cmd
1141  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1142  return Status::GENERIC_ERROR;
1143  }
1144 
1145  if (cmd == 0x13)
1146  usleep(1000);
1147  else if (cmd == 0x19)
1148  usleep(5000);
1149 
1150  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1151  extCtrls.controls = &extCtrl;
1152  extCtrls.count = 1;
1153 
1154  buf[0] = 0x00;
1155  buf[1] = uint8_t(payload_len >> 8);
1156  buf[2] = uint8_t(payload_len & 0xFF);
1157 
1158  extCtrl.p_u8 = buf;
1159 
1160  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1161  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1162  << " with command: 0x" << std::hex << cmd
1163  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1164  return Status::GENERIC_ERROR;
1165  }
1166 
1167  if (xioctl(dev->sfd, VIDIOC_G_EXT_CTRLS, &extCtrls) == -1) {
1168  LOG(WARNING) << "Could not get control: 0x" << std::hex << extCtrl.id
1169  << " with command: 0x" << std::hex << cmd
1170  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1171  return Status::GENERIC_ERROR;
1172  }
1173 
1174  memcpy(readback_data, extCtrl.p_u8 + 3, payload_len);
1175 
1176  //If we use the read ccb command we need to keep adsd3500 in burst mode
1177  if (cmd == 0x13) {
1178  return status;
1179  }
1180 
1181  //switch to standard mode
1182  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1183  extCtrls.controls = &extCtrl;
1184  extCtrls.count = 1;
1185 
1186  uint8_t switchBuf[] = {0x01, 0x00, 0x10, 0xAD, 0x00, 0x00, 0x10,
1187  0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
1188  0x00, 0x00, 0x00, 0x00, 0x00};
1189 
1190  memcpy(extCtrl.p_u8, switchBuf, 19);
1191 
1192  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1193  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1194  << " with command: 0x" << std::hex << cmd
1195  << " (switch to standard mode)"
1196  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1197  return Status::GENERIC_ERROR;
1198  }
1199 
1200  return status;
1201 }
1202 
1204  uint16_t payload_len) {
1205  using namespace aditof;
1206  struct VideoDev *dev = &m_implData->videoDevs[0];
1207  Status status = Status::OK;
1208 
1209  static struct v4l2_ext_control extCtrl;
1210  static struct v4l2_ext_controls extCtrls;
1211  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1212  memset(buf, 0, ADSD3500_CTRL_PACKET_SIZE * sizeof(uint8_t));
1213 
1214  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1215  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1216 
1217  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1218  extCtrls.controls = &extCtrl;
1219  extCtrls.count = 1;
1220 
1221  buf[0] = 0x00;
1222  buf[1] = uint8_t(payload_len >> 8);
1223  buf[2] = uint8_t(payload_len & 0xFF);
1224 
1225  extCtrl.p_u8 = buf;
1226 
1227  usleep(30000);
1228 
1229  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1230  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1231  << " to read payload with length: " << payload_len
1232  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1233  return Status::GENERIC_ERROR;
1234  }
1235 
1236  if (xioctl(dev->sfd, VIDIOC_G_EXT_CTRLS, &extCtrls) == -1) {
1237  LOG(WARNING) << "Could not get control: 0x" << std::hex << extCtrl.id
1238  << " to read payload with length: " << payload_len
1239  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1240  return Status::GENERIC_ERROR;
1241  }
1242 
1243  memcpy(payload, extCtrl.p_u8 + 3, payload_len);
1244 
1245  return status;
1246 }
1247 
1249 Adsd3500Sensor::adsd3500_write_payload_cmd(uint32_t cmd, uint8_t *payload,
1250  uint16_t payload_len) {
1251  using namespace aditof;
1252  struct VideoDev *dev = &m_implData->videoDevs[0];
1253  Status status = Status::OK;
1254 
1255  //switch to burst mode
1256  uint32_t switchCmd = 0x0019;
1257  uint16_t switchPayload = 0x0000;
1258 
1259  status = adsd3500_write_cmd(switchCmd, switchPayload);
1260  if (status != Status::OK) {
1261  LOG(INFO) << "Failed to switch to burst mode!";
1262  }
1263 
1264  static struct v4l2_ext_control extCtrl;
1265  static struct v4l2_ext_controls extCtrls;
1266  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1267 
1268  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1269  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1270  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1271  extCtrls.controls = &extCtrl;
1272  extCtrls.count = 1;
1273 
1274  payload_len += 16;
1275  buf[0] = 0x01;
1276  buf[1] = uint8_t(payload_len >> 8);
1277  buf[2] = uint8_t(payload_len & 0xFF);
1278 
1279  payload_len -= 16;
1280  buf[3] = 0xAD;
1281  buf[4] = uint8_t(payload_len >> 8);
1282  buf[5] = uint8_t(payload_len & 0xFF);
1283  buf[6] = uint8_t(cmd & 0xFF);
1284 
1285  uint32_t checksum = 0;
1286  for (int i = 0; i < 7; i++) {
1287  checksum += buf[i + 4];
1288  }
1289  memcpy(buf + 11, &checksum, 4);
1290  memcpy(buf + 15, payload, payload_len);
1291  extCtrl.p_u8 = buf;
1292 
1293  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1294  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1295  << " with command: 0x" << std::hex << cmd
1296  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1297  return Status::GENERIC_ERROR;
1298  }
1299 
1300  //switch to standard mode
1301  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1302  extCtrls.controls = &extCtrl;
1303  extCtrls.count = 1;
1304 
1305  uint8_t switchBuf[] = {0x01, 0x00, 0x10, 0xAD, 0x00, 0x00, 0x10,
1306  0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
1307  0x00, 0x00, 0x00, 0x00, 0x00};
1308 
1309  memcpy(extCtrl.p_u8, switchBuf, 19);
1310 
1311  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1312  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1313  << " with command: 0x" << std::hex << cmd
1314  << " (switch to standard mode)"
1315  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1316  return Status::GENERIC_ERROR;
1317  }
1318 
1319  return status;
1320 }
1321 
1323  uint16_t payload_len) {
1324  using namespace aditof;
1325  struct VideoDev *dev = &m_implData->videoDevs[0];
1326  Status status = Status::OK;
1327 
1328  static struct v4l2_ext_control extCtrl;
1329  static struct v4l2_ext_controls extCtrls;
1330  static uint8_t buf[ADSD3500_CTRL_PACKET_SIZE];
1331 
1332  extCtrl.size = ADSD3500_CTRL_PACKET_SIZE;
1333  extCtrl.id = V4L2_CID_AD_DEV_CHIP_CONFIG;
1334  memset(&extCtrls, 0, sizeof(struct v4l2_ext_controls));
1335  extCtrls.controls = &extCtrl;
1336  extCtrls.count = 1;
1337 
1338  buf[0] = 1;
1339  buf[1] = uint8_t(payload_len >> 8);
1340  buf[2] = uint8_t(payload_len & 0xFF);
1341 
1342  memcpy(buf + 3, payload, payload_len);
1343  extCtrl.p_u8 = buf;
1344 
1345  if (xioctl(dev->sfd, VIDIOC_S_EXT_CTRLS, &extCtrls) == -1) {
1346  LOG(WARNING) << "Could not set control: 0x" << std::hex << extCtrl.id
1347  << " to write payload with length: " << payload_len
1348  << ". Reason: " << strerror(errno) << "(" << errno << ")";
1349  return Status::GENERIC_ERROR;
1350  }
1351 
1352  usleep(100000);
1353 
1354  return status;
1355 }
1356 
1358  using namespace aditof;
1359  Status status = Status::OK;
1360 
1361 #if defined(NXP)
1362  m_chipResetDone = false;
1364  aditof::SensorInterruptCallback cb = [this](Adsd3500Status status) {
1365  m_adsd3500Status = status;
1366  m_chipResetDone = true;
1367  };
1369  bool interruptsAvailable = (status == Status::OK);
1370 
1371 #ifdef DUAL
1372  system("echo 0 > /sys/class/gpio/gpio64/value");
1373  usleep(1000000);
1374  system("echo 1 > /sys/class/gpio/gpio64/value");
1375 #else
1376  system("echo 0 > /sys/class/gpio/gpio122/value");
1377  usleep(1000000);
1378  system("echo 1 > /sys/class/gpio/gpio122/value");
1379 #endif
1380 
1381  if (interruptsAvailable) {
1382  LOG(INFO) << "Waiting for ADSD3500 to reset.";
1383  int secondsTimeout = 10;
1384  int secondsWaited = 0;
1385  int secondsWaitingStep = 1;
1386  while (!m_chipResetDone && secondsWaited < secondsTimeout) {
1387  LOG(INFO) << ".";
1388  std::this_thread::sleep_for(
1389  std::chrono::seconds(secondsWaitingStep));
1390  secondsWaited += secondsWaitingStep;
1391  }
1392  LOG(INFO) << "Waited: " << secondsWaited << " seconds";
1394  } else {
1395  usleep(7000000);
1396  }
1397 #elif defined(NVIDIA)
1398  struct stat st;
1399  if (stat("/sys/class/gpio/PP.04/value", &st) == 0) {
1400  system("echo 0 > /sys/class/gpio/PP.04/value");
1401  usleep(100000);
1402  system("echo 1 > /sys/class/gpio/PP.04/value");
1403  usleep(5000000);
1404  } else {
1405  Gpio gpio11("/dev/gpiochip3", 11);
1406  gpio11.openForWrite();
1407 
1408  gpio11.writeValue(0);
1409  usleep(100000);
1410  gpio11.writeValue(1);
1411  usleep(5000000);
1412 
1413  gpio11.close();
1414  }
1415 #endif
1416  return aditof::Status::OK;
1417 }
1418 
1420  uint16_t iniFileLength,
1421  uint8_t *calData,
1422  uint16_t calDataLength) {
1423  using namespace aditof;
1424  Status status = Status::OK;
1425 
1427  iniFile, iniFileLength, calData, calDataLength,
1428  m_implData->modeDetails.modeNumber, true);
1429  if (status != Status::OK) {
1430  LOG(ERROR) << "Failed to initialize depth compute on target!";
1431  return status;
1432  }
1433 
1434  uint8_t depthComputeStatus;
1435  status = m_bufferProcessor->getDepthComputeVersion(depthComputeStatus);
1436  if (status != Status::OK) {
1437  LOG(ERROR) << "Failed to get depth compute version!";
1438  return status;
1439  }
1440 
1441  m_controls["depthComputeOpenSource"] = std::to_string(depthComputeStatus);
1442 
1443  return aditof::Status::OK;
1444 }
1445 
1447  std::map<std::string, std::string> &params) {
1449  aditof::Status status;
1450 
1451  ABThresholdsParams ab_params;
1452  int type = 3;
1453  status = getIniParamsImpl(&ab_params, type, config->p_tofi_cal_config);
1454  params["abThreshMin"] = std::to_string(ab_params.ab_thresh_min);
1455  params["abSumThresh"] = std::to_string(ab_params.ab_sum_thresh);
1456 
1457  DepthRangeParams dr_params;
1458  type = 4;
1459  status = getIniParamsImpl(&dr_params, type, config->p_tofi_cal_config);
1460  params["confThresh"] = std::to_string(dr_params.conf_thresh);
1461  params["radialThreshMin"] = std::to_string(dr_params.radial_thresh_min);
1462  params["radialThreshMax"] = std::to_string(dr_params.radial_thresh_max);
1463 
1464  JBLFConfigParams jblf_params;
1465  type = 2;
1466  status = getIniParamsImpl(&jblf_params, type, config->p_tofi_cal_config);
1467  params["jblfApplyFlag"] =
1468  std::to_string(static_cast<float>(jblf_params.jblf_apply_flag));
1469  params["jblfWindowSize"] =
1470  std::to_string(static_cast<float>(jblf_params.jblf_window_size));
1471  params["jblfGaussianSigma"] =
1472  std::to_string(jblf_params.jblf_gaussian_sigma);
1473  params["jblfExponentialTerm"] =
1474  std::to_string(jblf_params.jblf_exponential_term);
1475  params["jblfMaxEdge"] = std::to_string(jblf_params.jblf_max_edge);
1476  params["jblfABThreshold"] = std::to_string(jblf_params.jblf_ab_threshold);
1477 
1478  InputRawDataParams ir_params;
1479  type = 1;
1480  status = getIniParamsImpl(&ir_params, type, config->p_tofi_cal_config);
1481  params["headerSize"] =
1482  std::to_string(static_cast<float>(ir_params.headerSize));
1483 
1484  return status;
1485 }
1486 
1488  const std::map<std::string, std::string> &params) {
1490  aditof::Status status;
1491 
1492  ABThresholdsParams ab_params;
1493  int type = 3;
1494  ab_params.ab_thresh_min = std::stof(params.at("abThreshMin"));
1495  ab_params.ab_sum_thresh = std::stof(params.at("abSumThresh"));
1496  status = setIniParamsImpl(&ab_params, type, config->p_tofi_cal_config);
1497 
1498  DepthRangeParams dr_params;
1499  type = 4;
1500  dr_params.conf_thresh = std::stof(params.at("confThresh"));
1501  dr_params.radial_thresh_min = std::stof(params.at("radialThreshMin"));
1502  dr_params.radial_thresh_max = std::stof(params.at("radialThreshMax"));
1503  status = setIniParamsImpl(&dr_params, type, config->p_tofi_cal_config);
1504 
1505  JBLFConfigParams jblf_params;
1506  type = 2;
1507  status = getIniParamsImpl(
1508  &jblf_params, type,
1509  config->p_tofi_cal_config); // get any original non-customizable value
1510  jblf_params.jblf_apply_flag =
1511  static_cast<int>(std::stof(params.at("jblfApplyFlag")));
1512  jblf_params.jblf_window_size =
1513  static_cast<int>(std::stof(params.at("jblfWindowSize")));
1514  jblf_params.jblf_gaussian_sigma = std::stof(params.at("jblfGaussianSigma"));
1515  jblf_params.jblf_exponential_term =
1516  std::stof(params.at("jblfExponentialTerm"));
1517  jblf_params.jblf_max_edge = std::stof(params.at("jblfMaxEdge"));
1518  jblf_params.jblf_ab_threshold = std::stof(params.at("jblfABThreshold"));
1519  status = setIniParamsImpl(&jblf_params, type, config->p_tofi_cal_config);
1520 
1521  return status;
1522 }
1523 
1525  fd_set fds;
1526  struct timeval tv;
1527  int r;
1528 
1529  if (dev == nullptr)
1530  dev = &m_implData->videoDevs[0];
1531 
1532  FD_ZERO(&fds);
1533  FD_SET(dev->fd, &fds);
1534 
1535  tv.tv_sec = 20;
1536  tv.tv_usec = 0;
1537 
1538  r = select(dev->fd + 1, &fds, NULL, NULL, &tv);
1539 
1540  if (r == -1) {
1541  LOG(WARNING) << "select error "
1542  << "errno: " << errno << " error: " << strerror(errno);
1544  } else if (r == 0) {
1545  LOG(WARNING) << "select timeout";
1547  }
1548  return aditof ::Status::OK;
1549 }
1550 
1553  struct VideoDev *dev) {
1554  using namespace aditof;
1555  Status status = Status::OK;
1556 
1557  if (dev == nullptr)
1558  dev = &m_implData->videoDevs[0];
1559 
1560  CLEAR(buf);
1561  buf.type = dev->videoBuffersType;
1562  buf.memory = V4L2_MEMORY_MMAP;
1563  buf.length = 1;
1564  buf.m.planes = dev->planes;
1565 
1566  if (xioctl(dev->fd, VIDIOC_DQBUF, &buf) == -1) {
1567  LOG(WARNING) << "VIDIOC_DQBUF error "
1568  << "errno: " << errno << " error: " << strerror(errno);
1569  switch (errno) {
1570  case EAGAIN:
1571  case EIO:
1572  break;
1573  default:
1574  return Status::GENERIC_ERROR;
1575  }
1576  }
1577 
1578  if (buf.index >= dev->nVideoBuffers) {
1579  LOG(WARNING) << "Not enough buffers avaialable";
1580  return Status::GENERIC_ERROR;
1581  }
1582 
1583  return status;
1584 }
1585 
1587  uint8_t **buffer, uint32_t &buf_data_len, const struct v4l2_buffer &buf,
1588  struct VideoDev *dev) {
1589  if (dev == nullptr)
1590  dev = &m_implData->videoDevs[0];
1591 
1592  *buffer = static_cast<uint8_t *>(dev->videoBuffers[buf.index].start);
1593  buf_data_len = buf.bytesused;
1594 
1595  return aditof::Status::OK;
1596 }
1597 
1600  struct VideoDev *dev) {
1601  if (dev == nullptr)
1602  dev = &m_implData->videoDevs[0];
1603 
1604  if (xioctl(dev->fd, VIDIOC_QBUF, &buf) == -1) {
1605  LOG(WARNING) << "VIDIOC_QBUF error "
1606  << "errno: " << errno << " error: " << strerror(errno);
1608  }
1609 
1610  return aditof::Status::OK;
1611 }
1612 
1614  using namespace aditof;
1615  struct VideoDev *dev = &m_implData->videoDevs[0];
1616 
1617  if (dev->fd != -1) {
1618  fileDescriptor = dev->fd;
1619  return Status::OK;
1620  }
1621 
1622  return Status::INVALID_ARGUMENT;
1623 }
1624 
1626 
1627  return waitForBufferPrivate();
1628 }
1629 
1631 
1633 }
1634 
1636 Adsd3500Sensor::getInternalBuffer(uint8_t **buffer, uint32_t &buf_data_len,
1637  const struct v4l2_buffer &buf) {
1638 
1639  return getInternalBufferPrivate(buffer, buf_data_len, buf);
1640 }
1641 
1643 
1645 }
1646 
1648 
1649  return aditof::Status::OK;
1650 }
1651 
1653  using namespace aditof;
1654  Status status = Status::OK;
1655  // Ask ADSD3500 what imager is being used and whether we're using the old or new modes (CCB version)
1656  if (m_implData->imagerType == SensorImagerType::IMAGER_UNKNOWN ||
1657  m_implData->ccbVersion == CCBVersion::CCB_UNKNOWN) {
1658 
1659  uint8_t fwData[44] = {0};
1660  fwData[0] = uint8_t(1);
1661  adsd3500_read_payload_cmd(0x05, fwData, 44);
1662  if (status != Status::OK) {
1663  LOG(ERROR) << "Failed to retrieve fw version and git hash for "
1664  "adsd3500!";
1665  return status;
1666  }
1667  m_implData->fw_ver = std::string((char *)(fwData), 4);
1668 
1669  uint16_t readValue = 0;
1670  int majorVersion = m_implData->fw_ver.at(0);
1671  if (majorVersion ==
1672  0) { // 0 means beta version, so version start at position 1
1673  majorVersion = m_implData->fw_ver.at(1);
1674  }
1675  if (majorVersion > 3) {
1676  status = adsd3500_read_cmd(0x0032, &readValue);
1677  } else {
1678  status = Status::GENERIC_ERROR;
1679  }
1680  if (status == aditof::Status::OK) {
1681  uint8_t ccb_version = readValue & 0x00FF;
1682  switch (ccb_version) {
1683  case 1: {
1684  m_implData->ccbVersion = CCBVersion::CCB_VERSION0;
1685  break;
1686  }
1687  case 2: {
1688  m_implData->ccbVersion = CCBVersion::CCB_VERSION1;
1689  break;
1690  }
1691  case 3: {
1692  m_implData->ccbVersion = CCBVersion::CCB_VERSION2;
1693  break;
1694  }
1695  default: {
1696  LOG(WARNING) << "Unknown CCB version read from ADSD3500: "
1697  << ccb_version;
1698  }
1699  } // switch (ccb_version)
1700 
1701  uint8_t imager_version = (readValue & 0xFF00) >> 8;
1702  switch (imager_version) {
1703  case 1: {
1705  m_modeSelector.setControl("imagerType", "adsd3100");
1706  break;
1707  }
1708  case 2: {
1710  m_modeSelector.setControl("imagerType", "adsd3030");
1711  break;
1712  }
1713  case 3: {
1715  m_modeSelector.setControl("imagerType", "adtf3080");
1716  break;
1717  }
1718  default: {
1719  LOG(WARNING) << "Unknown imager type read from ADSD3500: "
1720  << imager_version;
1721  }
1722  } // switch (imager_version)
1723  } else {
1724  status = Status::OK;
1725  LOG(ERROR) << "Failed to read imager type and CCB version (command "
1726  "0x0032). Possibly command is not implemented on the "
1727  "current adsd3500 firmware.";
1729  }
1730  }
1731 
1732  if (m_implData->ccbVersion != CCBVersion::CCB_UNKNOWN) {
1733  if (m_implData->ccbVersion == CCBVersion::CCB_VERSION0) {
1734  LOG(ERROR) << "Old modes are no longer supported!";
1735  return Status::GENERIC_ERROR;
1736  } else if (m_implData->ccbVersion == CCBVersion::CCB_VERSION2 &&
1737  m_controls["disableCCBM"] == "0") {
1738 
1739  uint16_t data;
1740  status = adsd3500_read_cmd(0x39, &data);
1741  if (status != Status::OK) {
1742  LOG(ERROR)
1743  << "Failed to check if ccb has mode map table support!";
1744  return status;
1745  }
1746 
1747  LOG(INFO) << "CCB master is supported. Reading mode details "
1748  "from nvm.";
1749 
1750  m_ccbmEnabled = true;
1751 
1752  m_availableModes.clear();
1753  m_ccbmINIContent.clear();
1754 
1755  CcbMode modeStruct[NR_OF_MODES_FROM_CCB];
1756  status = adsd3500_read_payload_cmd(0x24, (uint8_t *)&modeStruct[0],
1758  if (status != Status::OK) {
1759  LOG(ERROR) << "Failed to read mode map table from ccb!";
1760  return status;
1761  }
1762 
1763  for (int i = 0; i < NR_OF_MODES_FROM_CCB; i++) {
1764  DepthSensorModeDetails modeDetails;
1765  memset(&modeDetails, 0, sizeof(DepthSensorModeDetails));
1766 
1767  modeDetails.modeNumber = modeStruct[i].CFG_mode;
1768  if (modeDetails.modeNumber == 0xFF) {
1769  continue;
1770  }
1771 
1772  modeDetails.baseResolutionHeight = modeStruct[i].heigth;
1773  modeDetails.baseResolutionWidth = modeStruct[i].width;
1774  modeDetails.numberOfPhases = modeStruct[i].noOfPhases;
1775  modeDetails.isPCM = modeStruct[i].isPCM;
1776 
1777  if (modeDetails.baseResolutionWidth == 0 ||
1778  modeDetails.baseResolutionHeight == 0) {
1779  continue;
1780  }
1781 
1782  modeDetails.frameContent.clear();
1783  if (!modeDetails.isPCM) {
1784  modeDetails.frameContent = {"raw", "depth", "ab",
1785  "conf", "xyz", "metadata"};
1786  } else {
1787  modeDetails.frameContent = {"ab", "metadata"};
1788  }
1789 
1790  //Read ini file content and store it in the sdk
1791  IniTableEntry iniTableContent;
1792  memset(&iniTableContent, 0, sizeof(IniTableEntry));
1793  iniTableContent.INIIndex = modeDetails.modeNumber;
1794 
1795  if (!modeDetails.isPCM) {
1796  status = adsd3500_read_payload_cmd(
1797  0x25, (uint8_t *)(&iniTableContent), 0x26);
1798  if (status != Status::OK) {
1799  LOG(ERROR) << "Failed to read ini content from nvm";
1800  return status;
1801  }
1802 
1803  if (iniTableContent.INIIndex == 0xFF) {
1804  LOG(INFO) << "No ini content for mode "
1805  << (int)modeDetails.modeNumber << " in nvm!";
1806  continue;
1807  }
1808  }
1809 
1810  iniTableContent.modeNumber = modeDetails.modeNumber;
1811 
1812  m_availableModes.emplace_back(modeDetails);
1813  m_ccbmINIContent.emplace_back(iniTableContent);
1814  }
1815 
1816  } else {
1817  if (m_controls["disableCCBM"] == "1") {
1818  LOG(INFO) << "CCB master is disabled via control. Using "
1819  "sdk defined modes.";
1820  } else {
1821  LOG(INFO)
1822  << "CCB master not supported. Using sdk defined modes.";
1823  }
1824 
1825  int modeToTest = 5; // We are looking at width and height for mode 5
1826  uint8_t tempDealiasParams[32] = {0};
1827  tempDealiasParams[0] = modeToTest;
1828 
1829  TofiXYZDealiasData tempDealiasStruct;
1830  uint16_t width1 = 512;
1831  uint16_t height1 = 512;
1832 
1833  uint16_t width2 = 320;
1834  uint16_t height2 = 256;
1835 
1836  // We read dealias parameters to find out the width and height for mode 5
1837  status = adsd3500_read_payload_cmd(0x02, tempDealiasParams, 32);
1838  if (status != Status::OK) {
1839  LOG(ERROR) << "Failed to read dealias parameters for adsd3500!";
1840  return status;
1841  }
1842 
1843  memcpy(&tempDealiasStruct, tempDealiasParams,
1844  sizeof(TofiXYZDealiasData) - sizeof(CameraIntrinsics));
1845 
1846  // If mixed modes don't have accurate dimensions, switch back to simple new modes table
1847  if ((tempDealiasStruct.n_rows == width1 &&
1848  tempDealiasStruct.n_cols == height1) ||
1849  (tempDealiasStruct.n_rows == width2 &&
1850  tempDealiasStruct.n_cols == height2)) {
1851  m_modeSelector.setControl("mixedModes", "1");
1852  } else {
1853  m_modeSelector.setControl("mixedModes", "0");
1854  }
1855 
1856  //ccmb disabled. Populate struct with sdk defined variables.
1858  if (status != aditof::Status::OK) {
1859  LOG(ERROR) << "Failed to get available frame types for the "
1860  "current configuration.";
1861  }
1862  }
1863  }
1864 
1865  if (m_implData->imagerType == SensorImagerType::IMAGER_ADSD3100) {
1868  } else if (m_implData->imagerType == SensorImagerType::IMAGER_ADSD3030) {
1871  } else if (m_implData->imagerType == SensorImagerType::IMAGER_ADTF3080) {
1874  }
1875  if (status != Status::OK) {
1876  LOG(ERROR) << "Failed to populate ini params struct!";
1877  return status;
1878  }
1879 
1881 
1882  return status;
1883 }
1884 
1887  if (Adsd3500InterruptNotifier::getInstance().interruptsAvailable()) {
1888  m_interruptCallbackMap.insert({&cb, cb});
1889  } else {
1891  }
1892 
1893  return aditof::Status::OK;
1894 }
1895 
1898 
1899  m_interruptCallbackMap.erase(&cb);
1900 
1901  return aditof::Status::OK;
1902 }
1903 
1905  uint16_t statusRegister;
1907 
1908  status = adsd3500_read_cmd(0x0020, &statusRegister);
1909  if (status != aditof::Status::OK) {
1910  LOG(ERROR) << "Failed to read status register!";
1911  return status;
1912  }
1913 
1914  aditof::Adsd3500Status adsd3500Status =
1915  convertIdToAdsd3500Status(statusRegister);
1916  DLOG(INFO) << "statusRegister:" << statusRegister << "(" << adsd3500Status
1917  << ")";
1918 
1919  m_chipStatus = statusRegister;
1920 
1921  if (adsd3500Status == aditof::Adsd3500Status::IMAGER_ERROR) {
1922  status = adsd3500_read_cmd(0x0038, &statusRegister);
1923  if (status != aditof::Status::OK) {
1924  LOG(ERROR) << "Failed to read imager status register!";
1925  return status;
1926  }
1927 
1928  m_imagerStatus = statusRegister;
1929  LOG(ERROR) << "Imager error detected. Error code: " << statusRegister;
1930  }
1931 
1932  for (auto m_interruptCallback : m_interruptCallbackMap) {
1933  m_interruptCallback.second(adsd3500Status);
1934  }
1935 
1936  return status;
1937 }
1938 
1940  int &imagerStatus) {
1941  using namespace aditof;
1942  Status status = Status::OK;
1943 
1944  chipStatus = m_chipStatus;
1945  imagerStatus = m_imagerStatus;
1946 
1947  return status;
1948 }
1949 
1952  aditof::Status status;
1953  status = m_modeSelector.setConfiguration(sensorConf);
1954  if (status == aditof::Status::OK) {
1955  LOG(INFO) << "Using sensor configuration: " << sensorConf;
1956  } else {
1957  LOG(ERROR) << "Invalid sensor configuration provided!";
1958  }
1959  return status;
1960 }
1961 
1963  using namespace aditof;
1964 
1965  switch (status) {
1966  case 0:
1967  return Adsd3500Status::OK;
1968 
1969  case 1:
1970  return Adsd3500Status::INVALID_MODE;
1971 
1972  case 2:
1973  return Adsd3500Status::INVALID_JBLF_FILTER_SIZE;
1974 
1975  case 3:
1976  return Adsd3500Status::UNSUPPORTED_COMMAND;
1977 
1978  case 4:
1979  return Adsd3500Status::INVALID_MEMORY_REGION;
1980 
1981  case 5:
1982  return Adsd3500Status::INVALID_FIRMWARE_CRC;
1983 
1984  case 6:
1985  return Adsd3500Status::INVALID_IMAGER;
1986 
1987  case 7:
1988  return Adsd3500Status::INVALID_CCB;
1989 
1990  case 8:
1991  return Adsd3500Status::FLASH_HEADER_PARSE_ERROR;
1992 
1993  case 9:
1994  return Adsd3500Status::FLASH_FILE_PARSE_ERROR;
1995 
1996  case 10:
1997  return Adsd3500Status::SPIM_ERROR;
1998 
1999  case 11:
2000  return Adsd3500Status::INVALID_CHIPID;
2001 
2002  case 12:
2003  return Adsd3500Status::IMAGER_COMMUNICATION_ERROR;
2004 
2005  case 13:
2006  return Adsd3500Status::IMAGER_BOOT_FAILURE;
2007 
2008  case 14:
2009  return Adsd3500Status::FIRMWARE_UPDATE_COMPLETE;
2010 
2011  case 15:
2012  return Adsd3500Status::NVM_WRITE_COMPLETE;
2013 
2014  case 16:
2015  return Adsd3500Status::IMAGER_ERROR;
2016 
2017  default: {
2018  LOG(ERROR) << "Unknown ID: " << status;
2019  return Adsd3500Status::UNKNOWN_ERROR_ID;
2020  }
2021  }
2022 }
2023 
2025  int params_group,
2026  const void *p_tofi_cal_config) {
2027  using namespace aditof;
2028  Status status = Status::OK;
2029  uint32_t ret;
2030  ret = TofiGetINIParams(p_config_params, params_group, p_tofi_cal_config);
2031  status = static_cast<Status>(ret);
2032 
2033  if (status != Status::OK) {
2034  LOG(ERROR) << "Failed getting ini parameters";
2035  return Status::GENERIC_ERROR;
2036  }
2037 
2038  return status;
2039 }
2040 
2042  int params_group,
2043  const void *p_tofi_cal_config) {
2044  using namespace aditof;
2045  Status status = Status::OK;
2046  uint32_t ret;
2047  ret = TofiSetINIParams(p_config_params, params_group, p_tofi_cal_config);
2048  status = static_cast<Status>(ret);
2049 
2050  if (status != Status::OK) {
2051  LOG(ERROR) << "Failed setting ini parameters";
2052  return Status::GENERIC_ERROR;
2053  }
2054 
2055  return status;
2056 }
2057 
2059  const std::string &imager, const std::string &mode,
2060  std::map<std::string, std::string> &params) {
2061 
2062  auto it = std::find_if(
2064  [&imager, &mode](const iniFileStruct &iniF) {
2065  return (iniF.imagerName == imager && iniF.modeName == mode);
2066  });
2067 
2068  if (it == m_iniFileStructList.end()) {
2069  LOG(WARNING) << "Cannot find default parameters for imager: " << imager
2070  << " and mode: " << mode;
2072  }
2073 
2074  params = it->iniKeyValPairs;
2075 
2076  return aditof::Status::OK;
2077 }
2078 
2080 Adsd3500Sensor::mergeIniParams(std::vector<iniFileStruct> &iniFileStructList) {
2081 
2082  using namespace std;
2083  using namespace aditof;
2084 
2085  if (m_ccbmEnabled) {
2086 
2087  for (auto &ccbmParams : m_ccbmINIContent) {
2088 
2089  for (auto &iniList : iniFileStructList) {
2090 
2091  if (iniList.modeName != "") {
2092  if (ccbmParams.modeNumber ==
2093  std::stoi(iniList.modeName.c_str())) {
2094 
2095  iniList.iniKeyValPairs["abThreshMin"] =
2096  std::to_string(ccbmParams.abThreshMin);
2097  iniList.iniKeyValPairs["confThresh"] =
2098  std::to_string(ccbmParams.confThresh);
2099  iniList.iniKeyValPairs["radialThreshMin"] =
2100  std::to_string(ccbmParams.radialThreshMin);
2101  iniList.iniKeyValPairs["radialThreshMax"] =
2102  std::to_string(ccbmParams.radialThreshMax);
2103  iniList.iniKeyValPairs["jblfApplyFlag"] =
2104  std::to_string(ccbmParams.jblfApplyFlag);
2105  iniList.iniKeyValPairs["jblfWindowSize"] =
2106  std::to_string(ccbmParams.jblfWindowSize);
2107  iniList.iniKeyValPairs["jblfGaussianSigma"] =
2108  std::to_string(ccbmParams.jblfGaussianSigma);
2109  iniList.iniKeyValPairs["jblfExponentialTerm"] =
2110  std::to_string(ccbmParams.jblfExponentialTerm);
2111  iniList.iniKeyValPairs["jblfMaxEdge"] =
2112  std::to_string(ccbmParams.jblfMaxEdge);
2113  iniList.iniKeyValPairs["jblfABThreshold"] =
2114  std::to_string(ccbmParams.jblfABThreshold);
2115 
2116  break;
2117  }
2118  }
2119  }
2120  }
2121  }
2122 
2123  return Status::OK;
2124 }
2125 
2127  std::string &inistr) {
2128 
2129  inistr = "";
2130  for (auto iniPairs : iniStruct.iniKeyValPairs) {
2131  inistr += iniPairs.first + "=" + iniPairs.second + "\n";
2132  }
2133 
2134  return Status::OK;
2135 }
2136 
2138  std::string &iniStr) {
2139  std::string modestr = std::to_string(mode);
2140  std::string imager = "adsd3030";
2141  if (m_implData->imagerType == SensorImagerType::IMAGER_ADSD3100) {
2142  imager = "adsd3100";
2143  } else if (m_implData->imagerType == SensorImagerType::IMAGER_ADTF3080) {
2144  imager = "adtf3080";
2145  }
2146 
2147  auto it = std::find_if(
2149  [&imager, &modestr](const iniFileStruct &iniF) {
2150  return (iniF.imagerName == imager && iniF.modeName == modestr);
2151  });
2152 
2153  if (it == m_iniFileStructList.end()) {
2154  LOG(WARNING) << "Cannot find default parameters for imager: " << imager
2155  << " and mode: " << mode;
2157  }
2158 
2159  convertIniParams(*it, iniStr);
2160 
2161  return Status::OK;
2162 }
Adsd3500Sensor::m_availableModes
std::vector< aditof::DepthSensorModeDetails > m_availableModes
Definition: adsd3500_sensor.h:216
aditof::DepthSensorModeDetails::isPCM
int isPCM
set to true if the mode is PCM
Definition: sensor_definitions.h:170
Adsd3500Sensor::m_bufferProcessor
BufferProcessor * m_bufferProcessor
Definition: adsd3500_sensor.h:218
Adsd3500Sensor::setDepthComputeParams
virtual aditof::Status setDepthComputeParams(const std::map< std::string, std::string > &params) override
Set ini parameters for Depth Compute library.
Definition: adsd3500_sensor.cpp:1487
Adsd3500Sensor::m_hostConnectionType
aditof::ConnectionType m_hostConnectionType
Definition: adsd3500_sensor.h:204
table
upb_strtable table
Definition: php/ext/google/protobuf/protobuf.h:1065
Adsd3500InterruptNotifier::getInstance
static Adsd3500InterruptNotifier & getInstance()
Definition: adsd3500_interrupt_notifier.cpp:24
Adsd3500Sensor::convertIniParams
aditof::Status convertIniParams(iniFileStruct &iniStruct, std::string &inistr)
Definition: adsd3500_sensor.cpp:2126
Adsd3500Sensor::adsd3500_get_status
virtual aditof::Status adsd3500_get_status(int &chipStatus, int &imagerStatus) override
Returns the chip status.
Definition: adsd3500_sensor.cpp:1939
Adsd3500Sensor::getDeviceFileDescriptor
virtual aditof::Status getDeviceFileDescriptor(int &fileDescriptor) override
Definition: adsd3500_sensor.cpp:1613
JBLFConfigParams::jblf_ab_threshold
float jblf_ab_threshold
Definition: tofi_camera_intrinsics.h:72
INFO
const int INFO
Definition: log_severity.h:59
Adsd3500Sensor::adsd3500InterruptHandler
aditof::Status adsd3500InterruptHandler(int signalValue)
Definition: adsd3500_sensor.cpp:1904
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
aditof::DepthSensorModeDetails::frameContent
std::vector< std::string > frameContent
Stores the content of each frame.
Definition: sensor_definitions.h:130
aditof::DepthSensorModeDetails::modeNumber
uint8_t modeNumber
Number associated with the mode.
Definition: sensor_definitions.h:125
JBLFConfigParams
Definition: tofi_camera_intrinsics.h:66
JBLFConfigParams::jblf_gaussian_sigma
float jblf_gaussian_sigma
Definition: tofi_camera_intrinsics.h:69
TofiConfig::p_tofi_cal_config
const void * p_tofi_cal_config
Pointer to the calibration config block.
Definition: tofi_config.h:52
ABThresholdsParams::ab_sum_thresh
float ab_sum_thresh
Definition: tofi_camera_intrinsics.h:77
Adsd3500Sensor::ImplData
Definition: adsd3500_sensor.cpp:99
BufferProcessor::getTofiCongfig
TofiConfig * getTofiCongfig()
Definition: buffer_processor.cpp:463
Adsd3500Sensor::getAvailableControls
virtual aditof::Status getAvailableControls(std::vector< std::string > &controls) const override
Gets the sensors's list of controls.
Definition: adsd3500_sensor.cpp:796
JBLFConfigParams::jblf_exponential_term
float jblf_exponential_term
Definition: tofi_camera_intrinsics.h:70
Adsd3500Sensor::getDepthComputeParams
virtual aditof::Status getDepthComputeParams(std::map< std::string, std::string > &params) override
Get ini parameters for Depth Compute library.
Definition: adsd3500_sensor.cpp:1446
aditof::DepthSensorModeDetails::baseResolutionHeight
int baseResolutionHeight
Processed data height.
Definition: sensor_definitions.h:160
NULL
NULL
Definition: test_security_zap.cpp:405
aditof::SensorDetails
Provides details about the device.
Definition: sensor_definitions.h:50
aditof::Adsd3500ModeSelector::setConfiguration
aditof::Status setConfiguration(const std::string &configuration)
Definition: adsd3500_mode_selector.cpp:55
Adsd3500Sensor::getDefaultIniParamsForMode
aditof::Status getDefaultIniParamsForMode(const std::string &imager, const std::string &mode, std::map< std::string, std::string > &params)
Definition: adsd3500_sensor.cpp:2058
ERROR
const int ERROR
Definition: log_severity.h:60
EINTR
#define EINTR
Definition: errno.hpp:7
Adsd3500Sensor::ImplData::ImplData
ImplData()
Definition: adsd3500_sensor.cpp:108
Adsd3500Sensor::initTargetDepthCompute
virtual aditof::Status initTargetDepthCompute(uint8_t *iniFile, uint16_t iniFileLength, uint8_t *calData, uint16_t calDataLength) override
Get the name of the sensor.
Definition: adsd3500_sensor.cpp:1419
VideoDev::fd
int fd
Definition: buffer_processor.h:49
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
item
cJSON * item
Definition: cJSON.h:236
Adsd3500Sensor::m_controls
std::unordered_map< std::string, std::string > m_controls
Definition: adsd3500_sensor.h:208
ConfigurationData::burst_layout
uint16_t burst_layout
Definition: adsd3500_sensor.cpp:82
aditof::Status::GENERIC_ERROR
@ GENERIC_ERROR
An error occured but there are no details available.
BufferProcessor::setVideoProperties
aditof::Status setVideoProperties(int frameWidth, int frameHeight)
Definition: buffer_processor.cpp:132
CalibrationData::cache
uint16_t * cache
Definition: network_depth_sensor.cpp:47
CalibrationData::gain
float gain
Definition: network_depth_sensor.cpp:45
aditof::ConnectionType::ON_TARGET
@ ON_TARGET
on the target, direct sysfs access
mode
GLenum mode
Definition: glcorearb.h:2764
EAGAIN
#define EAGAIN
Definition: errno.hpp:14
aditof::ConnectionType::NETWORK
@ NETWORK
connects to target via Network
BufferProcessor::setInputDevice
aditof::Status setInputDevice(VideoDev *inputVideoDev)
Definition: buffer_processor.cpp:126
ConfigurationData::values
uint32_t values
Definition: adsd3500_sensor.cpp:87
aditof::Adsd3500ModeSelector::getAvailableModeDetails
aditof::Status getAvailableModeDetails(std::vector< DepthSensorModeDetails > &m_depthSensorModeDetails)
Definition: adsd3500_mode_selector.cpp:66
log.h
Adsd3500Sensor::m_capturesPerFrame
uint8_t m_capturesPerFrame
Definition: adsd3500_sensor.h:210
Adsd3500Sensor::m_sensorName
std::string m_sensorName
Definition: adsd3500_sensor.h:201
DepthRangeParams::radial_thresh_min
float radial_thresh_min
Definition: tofi_camera_intrinsics.h:81
Adsd3500Sensor::getInternalBufferPrivate
aditof::Status getInternalBufferPrivate(uint8_t **buffer, uint32_t &buf_data_len, const struct v4l2_buffer &buf, struct VideoDev *dev=nullptr)
Definition: adsd3500_sensor.cpp:1586
Adsd3500Sensor::open
virtual aditof::Status open() override
Open the communication channels with the hardware.
Definition: adsd3500_sensor.cpp:208
JBLFConfigParams::jblf_max_edge
float jblf_max_edge
Definition: tofi_camera_intrinsics.h:71
IniTableEntry::INIIndex
uint8_t INIIndex
Definition: adsd3500_sensor.h:62
Adsd3500Sensor::getModeDetails
virtual aditof::Status getModeDetails(const uint8_t &mode, aditof::DepthSensorModeDetails &details) override
Returns details of specified mode.
Definition: adsd3500_sensor.cpp:477
Adsd3500Sensor::setMode
virtual aditof::Status setMode(const aditof::DepthSensorModeDetails &type) override
Set the sensor frame mode to the given type.
Definition: adsd3500_sensor.cpp:541
utils_ini.h
VideoDev
Definition: buffer_processor.h:48
SensorImagerType
SensorImagerType
Definition: adsd3500_sensor.cpp:90
ConfigurationData::rsvd
uint16_t rsvd
Definition: adsd3500_sensor.cpp:86
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
SIZE_OF_MODES_FROM_CCB
#define SIZE_OF_MODES_FROM_CCB
Definition: adsd3500_sensor.cpp:66
errno
int errno
Adsd3500Sensor::waitForBufferPrivate
aditof::Status waitForBufferPrivate(struct VideoDev *dev=nullptr)
Definition: adsd3500_sensor.cpp:1524
Adsd3500Sensor::m_captureDev
std::string m_captureDev
Definition: adsd3500_sensor.h:207
TofiConfig
Definition: tofi_config.h:40
CTRL_SET_MODE
#define CTRL_SET_MODE
Definition: adsd3500_sensor.cpp:47
aditof::Adsd3500ModeSelector::getConfigurationTable
aditof::Status getConfigurationTable(DepthSensorModeDetails &configurationTable)
Definition: adsd3500_mode_selector.cpp:86
TofiXYZDealiasData::n_cols
int n_cols
Definition: tofi_camera_intrinsics.h:36
Adsd3500Sensor::adsd3500_read_payload_cmd
virtual aditof::Status adsd3500_read_payload_cmd(uint32_t cmd, uint8_t *readback_data, uint16_t payload_len) override
Send a read command to adsd3500. This will perform a burst read making it useful for reading chunks o...
Definition: adsd3500_sensor.cpp:1094
aditof::Adsd3500Status::IMAGER_ERROR
@ IMAGER_ERROR
Imager error.
aditof::Status::UNAVAILABLE
@ UNAVAILABLE
The requested action or resource is unavailable.
WARNING
const int WARNING
Definition: log_severity.h:59
Adsd3500Sensor::getName
virtual aditof::Status getName(std::string &name) const override
Get the name of the sensor.
Definition: adsd3500_sensor.cpp:980
aditof::Adsd3500Status
Adsd3500Status
Status of the ADSD3500 sensor.
Definition: status_definitions.h:61
DLOG
#define DLOG(x)
Definition: sdk/include/aditof/log.h:73
idx
static uint32_t idx(tarjan *t, const upb_refcounted *r)
Definition: ruby/ext/google/protobuf_c/upb.c:5925
Adsd3500Sensor::start
virtual aditof::Status start() override
Start the streaming of data from the sensor.
Definition: adsd3500_sensor.cpp:397
Adsd3500Sensor::getInternalBuffer
virtual aditof::Status getInternalBuffer(uint8_t **buffer, uint32_t &buf_data_len, const struct v4l2_buffer &buf) override
Definition: adsd3500_sensor.cpp:1636
SensorImagerType::IMAGER_ADTF3080
@ IMAGER_ADTF3080
google::protobuf::util::error::UNAVAILABLE
@ UNAVAILABLE
Definition: status.h:62
TofiXYZDealiasData::n_rows
int n_rows
Definition: tofi_camera_intrinsics.h:35
DepthRangeParams::conf_thresh
float conf_thresh
Definition: tofi_camera_intrinsics.h:80
ADSD3500_CTRL_PACKET_SIZE
#define ADSD3500_CTRL_PACKET_SIZE
Definition: adsd3500_sensor.cpp:56
Adsd3500Sensor::m_chipStatus
int m_chipStatus
Definition: adsd3500_sensor.h:220
Adsd3500Sensor::mergeIniParams
aditof::Status mergeIniParams(std::vector< iniFileStruct > &iniFileStructList)
Definition: adsd3500_sensor.cpp:2080
iniFileStruct
Definition: ini_file_definitions.h:39
Adsd3500Sensor::m_driverSubPath
std::string m_driverSubPath
Definition: adsd3500_sensor.h:206
Adsd3500Sensor::Adsd3500Sensor
Adsd3500Sensor(const std::string &driverPath, const std::string &driverSubPath, const std::string &captureDev)
Definition: adsd3500_sensor.cpp:128
Adsd3500Sensor::getDetails
virtual aditof::Status getDetails(aditof::SensorDetails &details) const override
Get a structure that contains information about the instance of the sensor.
Definition: adsd3500_sensor.cpp:969
ConfigurationData::size
uint32_t size
Definition: adsd3500_sensor.cpp:81
Adsd3500Sensor::adsd3500_read_payload
virtual aditof::Status adsd3500_read_payload(uint8_t *payload, uint16_t payload_len) override
Reads a chunk of data from adsd3500. This will perform a burst read making it useful for reading chun...
Definition: adsd3500_sensor.cpp:1203
BufferProcessor
Definition: buffer_processor.h:62
Adsd3500Sensor::m_driverPath
std::string m_driverPath
Definition: adsd3500_sensor.h:205
dirent.h
CCBVersion
CCBVersion
Definition: adsd3500_sensor.cpp:97
Adsd3500Sensor::~Adsd3500Sensor
~Adsd3500Sensor()
Definition: adsd3500_sensor.cpp:165
aditof::SensorDetails::id
std::string id
The sensor identification data to be used to differentiate between sensors. When on target,...
Definition: sensor_definitions.h:55
mode_num
uint8_t mode_num
Definition: adsd3500_sensor.cpp:69
Adsd3500Sensor::enqueueInternalBufferPrivate
aditof::Status enqueueInternalBufferPrivate(struct v4l2_buffer &buf, struct VideoDev *dev=nullptr)
Definition: adsd3500_sensor.cpp:1599
aditof::Gpio::close
int close()
Definition: gpio.cpp:79
BufferProcessor::open
aditof::Status open()
Definition: buffer_processor.cpp:98
aditof
Namespace aditof.
Definition: adsd_errs.h:40
offset
GLintptr offset
Definition: glcorearb.h:2944
aditof::Adsd3500ModeSelector::updateConfigurationTable
aditof::Status updateConfigurationTable(DepthSensorModeDetails &configurationTable)
Definition: adsd3500_mode_selector.cpp:122
TofiGetINIParams
uint32_t TofiGetINIParams(void *p_config_params, int params_group, const void *p_tofi_cal_config)
Definition: tofiConfig.cpp:117
Adsd3500Sensor::enqueueInternalBuffer
virtual aditof::Status enqueueInternalBuffer(struct v4l2_buffer &buf) override
Definition: adsd3500_sensor.cpp:1642
ConfigurationData
Definition: adsd3500_sensor.cpp:78
google::protobuf::util::error::OK
@ OK
Definition: status.h:47
Adsd3500Sensor::setIniParamsImpl
aditof::Status setIniParamsImpl(void *p_config_params, int params_group, const void *p_tofi_cal_config)
Definition: adsd3500_sensor.cpp:2041
buffer::start
void * start
Definition: buffer_processor.h:44
IniTableEntry
Definition: adsd3500_sensor.h:61
VideoDev::planes
struct v4l2_plane planes[8]
Definition: buffer_processor.h:53
testing::internal::fmt
GTEST_API_ const char * fmt
Definition: gtest.h:1835
aditof::ConnectionType::USB
@ USB
connects to target via USB
DepthRangeParams
Definition: tofi_camera_intrinsics.h:79
buffer::length
size_t length
Definition: buffer_processor.h:45
xioctl
static int xioctl(int fh, unsigned int request, void *arg)
Definition: adsd3500_sensor.cpp:117
ConfigurationData::burst_num
uint16_t burst_num
Definition: adsd3500_sensor.cpp:83
Adsd3500Sensor::adsd3500_register_interrupt_callback
virtual aditof::Status adsd3500_register_interrupt_callback(aditof::SensorInterruptCallback &cb) override
Register a function to be called when a ADSD3500 interrupt occurs.
Definition: adsd3500_sensor.cpp:1885
TofiSetINIParams
uint32_t TofiSetINIParams(void *p_config_params, int params_group, const void *p_tofi_cal_config)
Definition: tofiConfig.cpp:113
params
GLenum const GLfloat * params
Definition: glcorearb.h:2770
CCBVersion::CCB_UNKNOWN
@ CCB_UNKNOWN
ConfigurationData::burst_setup
uint16_t burst_setup[4]
Definition: adsd3500_sensor.cpp:84
Adsd3500Sensor::m_ccbmEnabled
bool m_ccbmEnabled
Definition: adsd3500_sensor.h:227
ConfigurationData::ver
uint16_t ver
Definition: adsd3500_sensor.cpp:80
EXTRA_BUFFERS_COUNT
#define EXTRA_BUFFERS_COUNT
Definition: adsd3500_sensor.cpp:40
chip_id
uint16_t chip_id
Definition: adsd3500_sensor.cpp:68
Adsd3500Sensor::m_sensorConfiguration
std::string m_sensorConfiguration
Definition: adsd3500_sensor.h:226
SensorImagerType::IMAGER_UNKNOWN
@ IMAGER_UNKNOWN
BufferProcessor::setProcessorProperties
aditof::Status setProcessorProperties(uint8_t *iniFile, uint16_t iniFileLength, uint8_t *calData, uint16_t calDataLength, uint16_t mode, bool ispEnabled)
Definition: buffer_processor.cpp:162
Adsd3500Sensor::m_sensorDetails
aditof::SensorDetails m_sensorDetails
Definition: adsd3500_sensor.h:203
buffer
Definition: buffer_processor.h:43
adsd3500_sensor.h
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:4175
Adsd3500Sensor::ImplData::ccbVersion
CCBVersion ccbVersion
Definition: adsd3500_sensor.cpp:105
google::protobuf::util::error::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Definition: status.h:50
MAX_SUBFRAMES_COUNT
#define MAX_SUBFRAMES_COUNT
Definition: adsd3500_sensor.cpp:38
SensorImagerType::IMAGER_ADSD3100
@ IMAGER_ADSD3100
aditof::Gpio
Definition: gpio.h:71
CalibrationData
Definition: network_depth_sensor.cpp:43
aditof::Status::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Invalid arguments provided.
Adsd3500Sensor::dequeueInternalBufferPrivate
aditof::Status dequeueInternalBufferPrivate(struct v4l2_buffer &buf, struct VideoDev *dev=nullptr)
Definition: adsd3500_sensor.cpp:1552
aditof::ConnectionType
ConnectionType
Types of connections.
Definition: connections.h:44
CCBVersion::CCB_VERSION2
@ CCB_VERSION2
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
BufferProcessor::processBuffer
aditof::Status processBuffer(uint16_t *buffer, const uint16_t &chipID, const uint8_t &mode_num)
Definition: buffer_processor.cpp:214
Adsd3500Sensor::m_iniFileStructList
std::vector< iniFileStruct > m_iniFileStructList
Definition: adsd3500_sensor.h:224
Adsd3500Sensor::m_imagerStatus
int m_imagerStatus
Definition: adsd3500_sensor.h:221
Adsd3500Sensor::m_depthComputeOnTarget
bool m_depthComputeOnTarget
Definition: adsd3500_sensor.h:219
i
int i
Definition: gmock-matchers_test.cc:764
Adsd3500Sensor::ImplData::fw_ver
std::string fw_ver
Definition: adsd3500_sensor.cpp:106
Adsd3500Sensor::m_modeSelector
aditof::Adsd3500ModeSelector m_modeSelector
Definition: adsd3500_sensor.h:225
VideoDev::sfd
int sfd
Definition: buffer_processor.h:50
VideoDev::videoBuffersType
enum v4l2_buf_type videoBuffersType
Definition: buffer_processor.h:54
Adsd3500Sensor::setSensorConfiguration
virtual aditof::Status setSensorConfiguration(const std::string &sensorConf) override
Set sensor configutation table.
Definition: adsd3500_sensor.cpp:1951
BufferProcessor::getDepthComputeVersion
aditof::Status getDepthComputeVersion(uint8_t &enabled)
Definition: buffer_processor.cpp:465
Adsd3500Sensor::adsd3500_write_payload
virtual aditof::Status adsd3500_write_payload(uint8_t *payload, uint16_t payload_len) override
Send a chunk of data (payload) to adsd3500. This will perform a burst write making it useful for writ...
Definition: adsd3500_sensor.cpp:1322
type
GLenum type
Definition: glcorearb.h:2695
aditof::DepthSensorModeDetails::baseResolutionWidth
int baseResolutionWidth
Processed data witdh.
Definition: sensor_definitions.h:155
InputRawDataParams
Definition: tofi_camera_intrinsics.h:60
Adsd3500Sensor::stop
virtual aditof::Status stop() override
Stop the sensor data stream.
Definition: adsd3500_sensor.cpp:439
LOG
#define LOG(x)
Definition: sdk/include/aditof/log.h:72
Adsd3500Sensor::m_chipResetDone
bool m_chipResetDone
Definition: adsd3500_sensor.h:223
tofi_config.h
req
void * req
Definition: test_req_relaxed.cpp:10
Adsd3500Sensor::convertIdToAdsd3500Status
aditof::Adsd3500Status convertIdToAdsd3500Status(int status)
Definition: adsd3500_sensor.cpp:1962
Adsd3500Sensor::queryAdsd3500
aditof::Status queryAdsd3500()
Definition: adsd3500_sensor.cpp:1652
aditof::Status::OK
@ OK
Success.
Adsd3500Sensor::ImplData::numVideoDevs
uint8_t numVideoDevs
Definition: adsd3500_sensor.cpp:100
aditof::Gpio::openForWrite
int openForWrite()
Definition: gpio.cpp:75
Adsd3500Sensor::m_firstRun
bool m_firstRun
Definition: adsd3500_sensor.h:211
CLEAR
#define CLEAR(x)
Definition: adsd3500_sensor.cpp:43
Adsd3500Sensor::setControl
virtual aditof::Status setControl(const std::string &control, const std::string &value) override
Sets a specific sensor control.
Definition: adsd3500_sensor.cpp:806
InputRawDataParams::headerSize
int headerSize
Definition: tofi_camera_intrinsics.h:63
Adsd3500Sensor::getIniParamsImpl
aditof::Status getIniParamsImpl(void *p_config_params, int params_group, const void *p_tofi_cal_config)
Definition: adsd3500_sensor.cpp:2024
Adsd3500Sensor::m_adsd3500Queried
bool m_adsd3500Queried
Definition: adsd3500_sensor.h:213
Adsd3500Sensor::setHostConnectionType
virtual aditof::Status setHostConnectionType(std::string &connectionType) override
Set the host connection type for target sdk.
Definition: adsd3500_sensor.cpp:987
Adsd3500Sensor::getHandle
virtual aditof::Status getHandle(void **handle) override
Gets a handle to be used by other devices such as Storage, Temperature, etc. This handle will allow t...
Definition: adsd3500_sensor.cpp:975
CCBVersion::CCB_VERSION0
@ CCB_VERSION0
IniTableEntry::modeNumber
uint16_t modeNumber
Definition: adsd3500_sensor.h:83
gpio.h
Adsd3500InterruptNotifier::subscribeSensor
void subscribeSensor(std::weak_ptr< Adsd3500Sensor > sensor)
Definition: adsd3500_interrupt_notifier.cpp:81
device_parameters.h
ConfigurationData::id
uint16_t id
Definition: adsd3500_sensor.cpp:79
JBLFConfigParams::jblf_apply_flag
int jblf_apply_flag
Definition: tofi_camera_intrinsics.h:67
aditof::DepthSensorModeDetails
Describes the type of entire frame that a depth sensor can capture and transmit.
Definition: sensor_definitions.h:120
std
V4L2_CID_AD_DEV_CHIP_CONFIG
#define V4L2_CID_AD_DEV_CHIP_CONFIG
Definition: adsd3500_sensor.cpp:45
ABThresholdsParams
Definition: tofi_camera_intrinsics.h:75
Adsd3500Sensor::getControl
virtual aditof::Status getControl(const std::string &control, std::string &value) const override
Gets the value of a specific sensor control.
Definition: adsd3500_sensor.cpp:915
adsd3500_interrupt_notifier.h
Adsd3500Sensor::writeConfigBlock
aditof::Status writeConfigBlock(const uint32_t offset)
Definition: adsd3500_sensor.cpp:1647
CameraIntrinsics
Definition: tofi_camera_intrinsics.h:16
VideoDev::started
bool started
Definition: buffer_processor.h:55
Adsd3500Sensor::ImplData::videoDevs
struct VideoDev * videoDevs
Definition: adsd3500_sensor.cpp:101
r
GLboolean r
Definition: glcorearb.h:3228
Adsd3500Sensor::ImplData::imagerType
SensorImagerType imagerType
Definition: adsd3500_sensor.cpp:104
Adsd3500Sensor::waitForBuffer
virtual aditof::Status waitForBuffer() override
Definition: adsd3500_sensor.cpp:1625
CalibrationData::offset
float offset
Definition: network_depth_sensor.cpp:46
SensorImagerType::IMAGER_ADSD3030
@ IMAGER_ADSD3030
strerror
char * strerror(int errno)
CalibrationData::mode
std::string mode
Definition: network_depth_sensor.cpp:44
frame_operations.h
iniFileStruct::iniKeyValPairs
std::map< std::string, std::string > iniKeyValPairs
Definition: ini_file_definitions.h:44
DeviceParameters::createIniParams
static aditof::Status createIniParams(std::vector< iniFileStruct > &iniFileStructList, std::vector< aditof::DepthSensorModeDetails > &modeDetailsList, std::string imagerType, const uint16_t &chipID)
Definition: device_parameters.cpp:10
Adsd3500Sensor::adsd3500_reset
virtual aditof::Status adsd3500_reset() override
Reset adsd3500 chip.
Definition: adsd3500_sensor.cpp:1357
Adsd3500Sensor::adsd3500_read_cmd
virtual aditof::Status adsd3500_read_cmd(uint16_t cmd, uint16_t *data, unsigned int usDelay=0) override
Send a read command to adsd3500.
Definition: adsd3500_sensor.cpp:997
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
TofiXYZDealiasData
Definition: tofi_camera_intrinsics.h:34
true
#define true
Definition: cJSON.c:65
Adsd3500Sensor::getFrame
virtual aditof::Status getFrame(uint16_t *buffer) override
Request a frame from the sensor.
Definition: adsd3500_sensor.cpp:746
Adsd3500Sensor::m_sensorFps
unsigned int m_sensorFps
Definition: adsd3500_sensor.h:212
aditof::Gpio::writeValue
int writeValue(int value)
Definition: gpio.cpp:109
aditof::DepthSensorModeDetails::numberOfPhases
uint8_t numberOfPhases
Number of phases.
Definition: sensor_definitions.h:135
aditof::SensorDetails::connectionType
ConnectionType connectionType
The type of connection with the sensor.
Definition: sensor_definitions.h:60
Adsd3500Sensor::getIniParamsArrayForMode
aditof::Status getIniParamsArrayForMode(int mode, std::string &iniStr) override
Get ini parameters for Depth Compute library as string.
Definition: adsd3500_sensor.cpp:2137
CcbMode
Definition: adsd3500_sensor.h:41
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
Adsd3500Sensor::adsd3500_unregister_interrupt_callback
virtual aditof::Status adsd3500_unregister_interrupt_callback(aditof::SensorInterruptCallback &cb) override
Unregister a function registered with adsd3500_register_interrupt_callback.
Definition: adsd3500_sensor.cpp:1896
ABThresholdsParams::ab_thresh_min
float ab_thresh_min
Definition: tofi_camera_intrinsics.h:76
CCBVersion::CCB_VERSION1
@ CCB_VERSION1
Adsd3500Sensor::m_ccbmINIContent
std::vector< IniTableEntry > m_ccbmINIContent
Definition: adsd3500_sensor.h:217
VideoDev::nVideoBuffers
unsigned int nVideoBuffers
Definition: buffer_processor.h:52
aditof::Adsd3500ModeSelector::setControl
aditof::Status setControl(const std::string &control, const std::string &value)
Definition: adsd3500_mode_selector.cpp:232
Adsd3500Sensor::adsd3500_write_cmd
virtual aditof::Status adsd3500_write_cmd(uint16_t cmd, uint16_t data, unsigned int usDelay=0) override
Send a write command to adsd3500.
Definition: adsd3500_sensor.cpp:1054
DepthRangeParams::radial_thresh_max
float radial_thresh_max
Definition: tofi_camera_intrinsics.h:82
NR_OF_MODES_FROM_CCB
#define NR_OF_MODES_FROM_CCB
Definition: adsd3500_sensor.cpp:65
S_ISCHR
#define S_ISCHR(mode)
Definition: dirent.h:202
Adsd3500Sensor::getAvailableModes
virtual aditof::Status getAvailableModes(std::vector< uint8_t > &modes) override
Return all modes that are supported by the sensor.
Definition: adsd3500_sensor.cpp:464
Adsd3500Sensor::m_interruptCallbackMap
std::unordered_map< void *, aditof::SensorInterruptCallback > m_interruptCallbackMap
Definition: adsd3500_sensor.h:215
false
#define false
Definition: cJSON.c:70
Adsd3500Sensor::ImplData::controlsCommands
std::unordered_map< std::string, __u32 > controlsCommands
Definition: adsd3500_sensor.cpp:103
Adsd3500Sensor
Definition: adsd3500_sensor.h:86
Adsd3500Sensor::dequeueInternalBuffer
virtual aditof::Status dequeueInternalBuffer(struct v4l2_buffer &buf) override
Definition: adsd3500_sensor.cpp:1630
JBLFConfigParams::jblf_window_size
int jblf_window_size
Definition: tofi_camera_intrinsics.h:68
Adsd3500Sensor::m_adsd3500Status
aditof::Adsd3500Status m_adsd3500Status
Definition: adsd3500_sensor.h:222
it
MapIter it
Definition: php/ext/google/protobuf/map.c:205
Adsd3500Sensor::ImplData::modeDetails
aditof::DepthSensorModeDetails modeDetails
Definition: adsd3500_sensor.cpp:102
ConfigurationData::start_address
uint16_t start_address
Definition: adsd3500_sensor.cpp:85
VideoDev::videoBuffers
struct buffer * videoBuffers
Definition: buffer_processor.h:51
Adsd3500Sensor::m_implData
std::unique_ptr< ImplData > m_implData
Definition: adsd3500_sensor.h:209
Adsd3500Sensor::adsd3500_write_payload_cmd
virtual aditof::Status adsd3500_write_payload_cmd(uint32_t cmd, uint8_t *payload, uint16_t payload_len) override
Send a write command to adsd3500. This will perform a burst write making it useful for writing chunks...
Definition: adsd3500_sensor.cpp:1249
aditof::SensorInterruptCallback
std::function< void(Adsd3500Status)> SensorInterruptCallback
Callback for sensor interrupts.
Definition: depth_sensor_interface.h:50


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:47