2020-10-16 22:58:05 -06:00
|
|
|
#include <assert.h>
|
2021-05-08 23:15:17 -06:00
|
|
|
#include <poll.h>
|
|
|
|
#include <stdio.h>
|
2020-10-16 22:58:05 -06:00
|
|
|
#include <sys/socket.h>
|
2021-05-08 23:15:17 -06:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include "libyuv.h"
|
|
|
|
|
|
|
|
#include "cereal/visionipc/visionipc_server.h"
|
|
|
|
#include "selfdrive/common/clutil.h"
|
|
|
|
#include "selfdrive/common/params.h"
|
|
|
|
#include "selfdrive/common/swaglog.h"
|
|
|
|
#include "selfdrive/common/util.h"
|
|
|
|
#include "selfdrive/hardware/hw.h"
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2020-06-04 19:57:25 -06:00
|
|
|
#if defined(QCOM) && !defined(QCOM_REPLAY)
|
2021-05-08 23:15:17 -06:00
|
|
|
#include "selfdrive/camerad/cameras/camera_qcom.h"
|
2020-03-31 17:34:55 -06:00
|
|
|
#elif QCOM2
|
2021-05-08 23:15:17 -06:00
|
|
|
#include "selfdrive/camerad/cameras/camera_qcom2.h"
|
2020-03-26 20:19:47 -06:00
|
|
|
#elif WEBCAM
|
2021-05-08 23:15:17 -06:00
|
|
|
#include "selfdrive/camerad/cameras/camera_webcam.h"
|
2020-01-17 11:52:42 -07:00
|
|
|
#else
|
2021-05-08 23:15:17 -06:00
|
|
|
#include "selfdrive/camerad/cameras/camera_frame_stream.h"
|
2020-01-17 11:52:42 -07:00
|
|
|
#endif
|
|
|
|
|
2021-01-05 21:19:53 -07:00
|
|
|
ExitHandler do_exit;
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2020-10-16 22:58:05 -06:00
|
|
|
void party(cl_device_id device_id, cl_context context) {
|
2021-01-08 06:54:25 -07:00
|
|
|
MultiCameraState cameras = {};
|
|
|
|
VisionIpcServer vipc_server("camerad", device_id, context);
|
2020-12-15 20:22:03 -07:00
|
|
|
|
2021-01-08 06:54:25 -07:00
|
|
|
cameras_init(&vipc_server, &cameras, device_id, context);
|
|
|
|
cameras_open(&cameras);
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2021-01-08 06:54:25 -07:00
|
|
|
vipc_server.start_listener();
|
2020-12-15 20:22:03 -07:00
|
|
|
|
2021-01-08 06:54:25 -07:00
|
|
|
cameras_run(&cameras);
|
2020-01-17 11:52:42 -07:00
|
|
|
}
|
|
|
|
|
2020-12-14 21:52:40 -07:00
|
|
|
#ifdef QCOM
|
2020-12-14 14:59:48 -07:00
|
|
|
#include "CL/cl_ext_qcom.h"
|
|
|
|
#endif
|
|
|
|
|
2020-01-17 11:52:42 -07:00
|
|
|
int main(int argc, char *argv[]) {
|
2020-12-15 20:22:03 -07:00
|
|
|
set_realtime_priority(53);
|
2021-05-06 06:39:05 -06:00
|
|
|
if (Hardware::EON()) {
|
|
|
|
set_core_affinity(2);
|
|
|
|
} else if (Hardware::TICI()) {
|
|
|
|
set_core_affinity(6);
|
|
|
|
}
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2020-10-16 22:58:05 -06:00
|
|
|
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
2020-12-14 14:59:48 -07:00
|
|
|
|
2020-12-14 21:52:40 -07:00
|
|
|
// TODO: do this for QCOM2 too
|
|
|
|
#if defined(QCOM)
|
2020-12-14 14:59:48 -07:00
|
|
|
const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0};
|
|
|
|
cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err));
|
|
|
|
#else
|
2020-11-30 04:04:49 -07:00
|
|
|
cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err));
|
2020-12-14 14:59:48 -07:00
|
|
|
#endif
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2020-10-16 22:58:05 -06:00
|
|
|
party(device_id, context);
|
2020-01-17 11:52:42 -07:00
|
|
|
|
2020-11-30 04:04:49 -07:00
|
|
|
CL_CHECK(clReleaseContext(context));
|
2020-01-17 11:52:42 -07:00
|
|
|
}
|