Replace ifdefs with hardware abstraction layer (#20801)

* add type to class hadwareXXX

* replace ifdefs with hardware layer

* continue

* continue

* new function get_driver_view_transform

* full path to hw.h

* fix build error setup.cc

* apply review

* fix typo

* fix deprecated error:replace deprecated fromPath with new

* fix build error
albatross
Dean Lee 2021-05-06 17:41:46 +08:00 committed by GitHub
parent 937c2fa9f3
commit 757d2923d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 236 additions and 302 deletions

View File

@ -27,6 +27,7 @@
#include "common/timing.h" #include "common/timing.h"
#include "messaging.h" #include "messaging.h"
#include "locationd/ublox_msg.h" #include "locationd/ublox_msg.h"
#include "selfdrive/hardware/hw.h"
#include "panda.h" #include "panda.h"
#include "pigeon.h" #include "pigeon.h"
@ -361,18 +362,18 @@ void panda_state_thread(bool spoofing_started) {
auto ps = msg.initEvent().initPandaState(); auto ps = msg.initEvent().initPandaState();
ps.setUptime(pandaState.uptime); ps.setUptime(pandaState.uptime);
#ifdef QCOM2 if (Hardware::TICI()) {
double read_time = millis_since_boot(); double read_time = millis_since_boot();
ps.setVoltage(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input"))); ps.setVoltage(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input")));
ps.setCurrent(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input"))); ps.setCurrent(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input")));
read_time = millis_since_boot() - read_time; read_time = millis_since_boot() - read_time;
if (read_time > 50) { if (read_time > 50) {
LOGW("reading hwmon took %lfms", read_time); LOGW("reading hwmon took %lfms", read_time);
}
} else {
ps.setVoltage(pandaState.voltage);
ps.setCurrent(pandaState.current);
} }
#else
ps.setVoltage(pandaState.voltage);
ps.setCurrent(pandaState.current);
#endif
ps.setIgnitionLine(pandaState.ignition_line); ps.setIgnitionLine(pandaState.ignition_line);
ps.setIgnitionCan(pandaState.ignition_can); ps.setIgnitionCan(pandaState.ignition_can);
@ -417,17 +418,14 @@ void hardware_control_thread() {
uint16_t prev_fan_speed = 999; uint16_t prev_fan_speed = 999;
uint16_t ir_pwr = 0; uint16_t ir_pwr = 0;
uint16_t prev_ir_pwr = 999; uint16_t prev_ir_pwr = 999;
#if defined(QCOM) || defined(QCOM2)
bool prev_charging_disabled = false; bool prev_charging_disabled = false;
#endif
unsigned int cnt = 0; unsigned int cnt = 0;
while (!do_exit && panda->connected) { while (!do_exit && panda->connected) {
cnt++; cnt++;
sm.update(1000); // TODO: what happens if EINTR is sent while in sm.update? sm.update(1000); // TODO: what happens if EINTR is sent while in sm.update?
#if defined(QCOM) || defined(QCOM2) if (!Hardware::PC() && sm.updated("deviceState")){
if (sm.updated("deviceState")){
// Charging mode // Charging mode
bool charging_disabled = sm["deviceState"].getDeviceState().getChargingDisabled(); bool charging_disabled = sm["deviceState"].getDeviceState().getChargingDisabled();
if (charging_disabled != prev_charging_disabled){ if (charging_disabled != prev_charging_disabled){
@ -441,7 +439,6 @@ void hardware_control_thread() {
prev_charging_disabled = charging_disabled; prev_charging_disabled = charging_disabled;
} }
} }
#endif
// Other pandas don't have fan/IR to control // Other pandas don't have fan/IR to control
if (panda->hw_type != cereal::PandaState::PandaType::UNO && panda->hw_type != cereal::PandaState::PandaType::DOS) continue; if (panda->hw_type != cereal::PandaState::PandaType::UNO && panda->hw_type != cereal::PandaState::PandaType::DOS) continue;
@ -491,11 +488,7 @@ void pigeon_thread() {
PubMaster pm({"ubloxRaw"}); PubMaster pm({"ubloxRaw"});
bool ignition_last = false; bool ignition_last = false;
#ifdef QCOM2 Pigeon *pigeon = Hardware::TICI() ? Pigeon::connect("/dev/ttyHS0") : Pigeon::connect(panda);
Pigeon *pigeon = Pigeon::connect("/dev/ttyHS0");
#else
Pigeon *pigeon = Pigeon::connect(panda);
#endif
std::unordered_map<char, uint64_t> last_recv_time; std::unordered_map<char, uint64_t> last_recv_time;
std::unordered_map<char, int64_t> cls_max_dt = { std::unordered_map<char, int64_t> cls_max_dt = {
@ -572,11 +565,7 @@ int main() {
err = set_realtime_priority(54); err = set_realtime_priority(54);
LOG("set priority returns %d", err); LOG("set priority returns %d", err);
#ifdef QCOM2 err = set_core_affinity(Hardware::TICI() ? 4 : 3);
err = set_core_affinity(4);
#else
err = set_core_affinity(3);
#endif
LOG("set affinity returns %d", err); LOG("set affinity returns %d", err);
while (!do_exit){ while (!do_exit){

View File

@ -24,6 +24,7 @@
#include "common/util.h" #include "common/util.h"
#include "modeldata.h" #include "modeldata.h"
#include "imgproc/utils.h" #include "imgproc/utils.h"
#include "selfdrive/hardware/hw.h"
static cl_program build_debayer_program(cl_device_id device_id, cl_context context, const CameraInfo *ci, const CameraBuf *b, const CameraState *s) { static cl_program build_debayer_program(cl_device_id device_id, cl_context context, const CameraInfo *ci, const CameraBuf *b, const CameraState *s) {
char args[4096]; char args[4096];
@ -35,11 +36,8 @@ static cl_program build_debayer_program(cl_device_id device_id, cl_context conte
ci->frame_width, ci->frame_height, ci->frame_stride, ci->frame_width, ci->frame_height, ci->frame_stride,
b->rgb_width, b->rgb_height, b->rgb_stride, b->rgb_width, b->rgb_height, b->rgb_stride,
ci->bayer_flip, ci->hdr, s->camera_num); ci->bayer_flip, ci->hdr, s->camera_num);
#ifdef QCOM2 const char *cl_file = Hardware::TICI() ? "cameras/real_debayer.cl" : "cameras/debayer.cl";
return cl_program_from_file(context, device_id, "cameras/real_debayer.cl", args); return cl_program_from_file(context, device_id, cl_file, args);
#else
return cl_program_from_file(context, device_id, "cameras/debayer.cl", args);
#endif
} }
void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback) { void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback) {
@ -64,13 +62,12 @@ void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s,
rgb_width = ci->frame_width; rgb_width = ci->frame_width;
rgb_height = ci->frame_height; rgb_height = ci->frame_height;
#ifndef QCOM2
// debayering does a 2x downscale // debayering does a 2x downscale
if (ci->bayer) { if (Hardware::TICI() && ci->bayer) {
rgb_width = ci->frame_width / 2; rgb_width = ci->frame_width / 2;
rgb_height = ci->frame_height / 2; rgb_height = ci->frame_height / 2;
} }
#endif
yuv_transform = get_model_yuv_transform(ci->bayer); yuv_transform = get_model_yuv_transform(ci->bayer);
vipc_server->create_buffers(rgb_type, UI_BUF_COUNT, true, rgb_width, rgb_height); vipc_server->create_buffers(rgb_type, UI_BUF_COUNT, true, rgb_width, rgb_height);
@ -350,21 +347,27 @@ static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) {
static const bool is_rhd = Params().getBool("IsRHD"); static const bool is_rhd = Params().getBool("IsRHD");
struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;}; struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;};
const CameraBuf *b = &c->buf; const CameraBuf *b = &c->buf;
#ifndef QCOM2
bool hist_ceil = false, hl_weighted = false; bool hist_ceil = false, hl_weighted = false;
int x_offset = 0, y_offset = 0;
int frame_width = b->rgb_width, frame_height = b->rgb_height;
#ifndef QCOM2
int analog_gain = -1; int analog_gain = -1;
const int x_offset = 0, y_offset = 0;
const int frame_width = b->rgb_width, frame_height = b->rgb_height;
const ExpRect def_rect = {is_rhd ? 0 : b->rgb_width * 3 / 5, is_rhd ? b->rgb_width * 2 / 5 : b->rgb_width, 2,
b->rgb_height / 3, b->rgb_height, 1};
#else #else
bool hist_ceil = true, hl_weighted = true; int analog_gain = c->analog_gain;
int analog_gain = (int)c->analog_gain;
const int x_offset = 630, y_offset = 156;
const int frame_width = 668, frame_height = frame_width / 1.33;
const ExpRect def_rect = {96, 1832, 2, 242, 1148, 4};
#endif #endif
ExpRect def_rect;
if (!Hardware::TICI()) {
def_rect = {is_rhd ? 0 : b->rgb_width * 3 / 5, is_rhd ? b->rgb_width * 2 / 5 : b->rgb_width, 2,
b->rgb_height / 3, b->rgb_height, 1};
} else {
hist_ceil = hl_weighted = true;
x_offset = 630, y_offset = 156;
frame_width = 668, frame_height = frame_width / 1.33;
def_rect = {96, 1832, 2, 242, 1148, 4};
}
static ExpRect rect = def_rect; static ExpRect rect = def_rect;
// use driver face crop for AE // use driver face crop for AE
if (sm.updated("driverState")) { if (sm.updated("driverState")) {

View File

@ -22,6 +22,7 @@
#include "common/swaglog.h" #include "common/swaglog.h"
#include "common/util.h" #include "common/util.h"
#include "visionipc_server.h" #include "visionipc_server.h"
#include "selfdrive/hardware/hw.h"
ExitHandler do_exit; ExitHandler do_exit;
@ -43,11 +44,11 @@ void party(cl_device_id device_id, cl_context context) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
set_realtime_priority(53); set_realtime_priority(53);
#if defined(QCOM) if (Hardware::EON()) {
set_core_affinity(2); set_core_affinity(2);
#elif defined(QCOM2) } else if (Hardware::TICI()) {
set_core_affinity(6); set_core_affinity(6);
#endif }
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);

View File

@ -20,39 +20,26 @@ const double X_IDXS[TRAJECTORY_SIZE] = { 0. , 0.1875, 0.75 , 1.6875,
#ifdef __cplusplus #ifdef __cplusplus
#include "common/mat.h" #include "common/mat.h"
#ifdef QCOM2 #include "selfdrive/hardware/hw.h"
const mat3 fcam_intrinsic_matrix = (mat3){{ const mat3 fcam_intrinsic_matrix =
2648.0, 0.0, 1928.0/2, Hardware::TICI() ? (mat3){{2648.0, 0.0, 1928.0 / 2,
0.0, 2648.0, 1208.0/2, 0.0, 2648.0, 1208.0 / 2,
0.0, 0.0, 1.0 0.0, 0.0, 1.0}}
}}; : (mat3){{910., 0., 1164.0 / 2,
0., 910., 874.0 / 2,
0., 0., 1.}};
// without unwarp, focal length is for center portion only // without unwarp, focal length is for center portion only
const mat3 ecam_intrinsic_matrix = (mat3){{ const mat3 ecam_intrinsic_matrix =
620.0, 0.0, 1928.0/2, Hardware::TICI() ? (mat3){{620.0, 0.0, 1928.0 / 2,
0.0, 620.0, 1208.0/2, 0.0, 620.0, 1208.0 / 2,
0.0, 0.0, 1.0 0.0, 0.0, 1.0}}
}}; : (mat3){{0., 0., 0.,
#else 0., 0., 0.,
const mat3 fcam_intrinsic_matrix = (mat3){{ 0., 0., 0.}};
910., 0., 1164.0/2,
0., 910., 874.0/2,
0., 0., 1.
}};
const mat3 ecam_intrinsic_matrix = (mat3){{
0., 0., 0.,
0., 0., 0.,
0., 0., 0.
}};
#endif
static inline mat3 get_model_yuv_transform(bool bayer = true) { static inline mat3 get_model_yuv_transform(bool bayer = true) {
#ifndef QCOM2 float db_s = Hardware::TICI() ? 0.5 : 1.0; // debayering does a 2x downscale on TICI
float db_s = 0.5; // debayering does a 2x downscale
#else
float db_s = 1.0;
#endif
const mat3 transform = (mat3){{ const mat3 transform = (mat3){{
1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 1.0, 0.0,

View File

@ -16,7 +16,7 @@
#include <unordered_map> #include <unordered_map>
#include "common/util.h" #include "common/util.h"
#include "common/swaglog.h" #include "common/swaglog.h"
#include "selfdrive/hardware/hw.h"
// keep trying if x gets interrupted by a signal // keep trying if x gets interrupted by a signal
#define HANDLE_EINTR(x) \ #define HANDLE_EINTR(x) \
({ \ ({ \
@ -30,13 +30,8 @@
namespace { namespace {
#if defined(QCOM) || defined(QCOM2) const std::string default_params_path = !Hardware::PC() ? "/data/params" : util::getenv_default("HOME", "/.comma/params", "/data/params");
const std::string default_params_path = "/data/params"; const std::string persistent_params_path = !Hardware::PC() ? "/persist/comma/params" : default_params_path;
const std::string persistent_params_path = "/persist/comma/params";
#else
const std::string default_params_path = util::getenv_default("HOME", "/.comma/params", "/data/params");
const std::string persistent_params_path = default_params_path;
#endif
volatile sig_atomic_t params_do_exit = 0; volatile sig_atomic_t params_do_exit = 0;
void params_sig_handler(int signal) { void params_sig_handler(int signal) {

View File

@ -13,7 +13,7 @@
#include "common/util.h" #include "common/util.h"
#include "common/version.h" #include "common/version.h"
#include "selfdrive/hardware/hw.h"
#include "swaglog.h" #include "swaglog.h"
class LogState { class LogState {
@ -71,9 +71,9 @@ static void cloudlog_init() {
s.ctx_j["dirty"] = !getenv("CLEAN"); s.ctx_j["dirty"] = !getenv("CLEAN");
// device type // device type
if (util::file_exists("/EON")) { if (Hardware::EON()) {
cloudlog_bind_locked("device", "eon"); cloudlog_bind_locked("device", "eon");
} else if (util::file_exists("/TICI")) { } else if (Hardware::TICI()) {
cloudlog_bind_locked("device", "tici"); cloudlog_bind_locked("device", "tici");
} else { } else {
cloudlog_bind_locked("device", "pc"); cloudlog_bind_locked("device", "pc");

View File

@ -7,16 +7,27 @@
// no-op base hw class // no-op base hw class
class HardwareNone { class HardwareNone {
public: public:
enum Type {
typePC,
typeEON,
typeTICI
};
static constexpr float MAX_VOLUME = 0; static constexpr float MAX_VOLUME = 0;
static constexpr float MIN_VOLUME = 0; static constexpr float MIN_VOLUME = 0;
static std::string get_os_version() { return "openpilot for PC"; }; static std::string get_os_version() { return "openpilot for PC"; }
static void reboot() {}; static void reboot() {}
static void poweroff() {}; static void poweroff() {}
static void set_brightness(int percent) {}; static void set_brightness(int percent) {}
static void set_display_power(bool on) {}; static void set_display_power(bool on) {}
static bool get_ssh_enabled() { return false; }; static bool get_ssh_enabled() { return false; }
static void set_ssh_enabled(bool enabled) {}; static void set_ssh_enabled(bool enabled) {}
static Type type() { return typePC; }
static bool PC() { return type() == typePC; }
static bool EON() { return type() == typeEON; }
static bool TICI() { return type() == typeTICI; }
}; };

View File

@ -15,6 +15,7 @@ public:
static constexpr float MAX_VOLUME = 1.0; static constexpr float MAX_VOLUME = 1.0;
static constexpr float MIN_VOLUME = 0.5; static constexpr float MIN_VOLUME = 0.5;
static Type type() { return typeEON; }
static std::string get_os_version() { static std::string get_os_version() {
return "NEOS " + util::read_file("/VERSION"); return "NEOS " + util::read_file("/VERSION");
}; };

View File

@ -11,7 +11,7 @@ class HardwareTici : public HardwareNone {
public: public:
static constexpr float MAX_VOLUME = 0.5; static constexpr float MAX_VOLUME = 0.5;
static constexpr float MIN_VOLUME = 0.4; static constexpr float MIN_VOLUME = 0.4;
static Type type() { return typeTICI; }
static std::string get_os_version() { static std::string get_os_version() {
return "AGNOS " + util::read_file("/VERSION"); return "AGNOS " + util::read_file("/VERSION");
}; };

View File

@ -20,6 +20,7 @@
#include "common/params.h" #include "common/params.h"
#include "common/version.h" #include "common/version.h"
#include "messaging.h" #include "messaging.h"
#include "selfdrive/hardware/hw.h"
#include "logger.h" #include "logger.h"
@ -53,9 +54,9 @@ kj::Array<capnp::word> logger_build_init_data() {
MessageBuilder msg; MessageBuilder msg;
auto init = msg.initEvent().initInitData(); auto init = msg.initEvent().initInitData();
if (util::file_exists("/EON")) { if (Hardware::EON()) {
init.setDeviceType(cereal::InitData::DeviceType::NEO); init.setDeviceType(cereal::InitData::DeviceType::NEO);
} else if (util::file_exists("/TICI")) { } else if (Hardware::TICI()) {
init.setDeviceType(cereal::InitData::DeviceType::TICI); init.setDeviceType(cereal::InitData::DeviceType::TICI);
} else { } else {
init.setDeviceType(cereal::InitData::DeviceType::PC); init.setDeviceType(cereal::InitData::DeviceType::PC);

View File

@ -8,13 +8,11 @@
#include <kj/array.h> #include <kj/array.h>
#include <capnp/serialize.h> #include <capnp/serialize.h>
#include "common/util.h" #include "common/util.h"
#include "selfdrive/hardware/hw.h"
#if defined(QCOM) || defined(QCOM2) const std::string LOG_ROOT =
const std::string LOG_ROOT = "/data/media/0/realdata"; Hardware::PC() ? util::getenv_default("HOME", "/.comma/media/0/realdata", "/data/media/0/realdata")
#else : "/data/media/0/realdata";
const std::string LOG_ROOT = util::getenv_default("HOME", "/.comma/media/0/realdata", "/data/media/0/realdata");
#endif
#define LOGGER_MAX_HANDLES 16 #define LOGGER_MAX_HANDLES 16
class BZFile { class BZFile {

View File

@ -26,7 +26,7 @@
#include "logger.h" #include "logger.h"
#include "messaging.h" #include "messaging.h"
#include "services.h" #include "services.h"
#include "selfdrive/hardware/hw.h"
#include "visionipc.h" #include "visionipc.h"
#include "visionipc_client.h" #include "visionipc_client.h"
@ -42,16 +42,9 @@
namespace { namespace {
constexpr int MAIN_FPS = 20; constexpr int MAIN_FPS = 20;
const int MAIN_BITRATE = Hardware::TICI() ? 10000000 : 5000000;
#ifndef QCOM2 const int MAX_CAM_IDX = Hardware::TICI() ? LOG_CAMERA_ID_ECAMERA : LOG_CAMERA_ID_DCAMERA;
constexpr int MAIN_BITRATE = 5000000; const int DCAM_BITRATE = Hardware::TICI() ? MAIN_BITRATE : 2500000;
constexpr int MAX_CAM_IDX = LOG_CAMERA_ID_DCAMERA;
constexpr int DCAM_BITRATE = 2500000;
#else
constexpr int MAIN_BITRATE = 10000000;
constexpr int MAX_CAM_IDX = LOG_CAMERA_ID_ECAMERA;
constexpr int DCAM_BITRATE = MAIN_BITRATE;
#endif
#define NO_CAMERA_PATIENCE 500 // fall back to time-based rotation if all cameras are dead #define NO_CAMERA_PATIENCE 500 // fall back to time-based rotation if all cameras are dead
@ -96,11 +89,8 @@ LogCameraInfo cameras_logged[LOG_CAMERA_ID_MAX] = {
.bitrate = 256000, .bitrate = 256000,
.is_h265 = false, .is_h265 = false,
.downscale = true, .downscale = true,
#ifndef QCOM2 .frame_width = Hardware::TICI() ? 526 : 480,
.frame_width = 480, .frame_height = 360 .frame_height = Hardware::TICI() ? 330 : 360 // keep pixel count the same?
#else
.frame_width = 526, .frame_height = 330 // keep pixel count the same?
#endif
}, },
}; };
@ -279,11 +269,11 @@ void encoder_thread(int cam_idx) {
eidx.setFrameId(extra.frame_id); eidx.setFrameId(extra.frame_id);
eidx.setTimestampSof(extra.timestamp_sof); eidx.setTimestampSof(extra.timestamp_sof);
eidx.setTimestampEof(extra.timestamp_eof); eidx.setTimestampEof(extra.timestamp_eof);
#ifdef QCOM2 if (Hardware::TICI()) {
eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C); eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C);
#else } else {
eidx.setType(cam_idx == LOG_CAMERA_ID_DCAMERA ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C); eidx.setType(cam_idx == LOG_CAMERA_ID_DCAMERA ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C);
#endif }
eidx.setEncodeId(cnt); eidx.setEncodeId(cnt);
eidx.setSegmentNum(rotate_state.cur_seg); eidx.setSegmentNum(rotate_state.cur_seg);
eidx.setSegmentId(out_id); eidx.setSegmentId(out_id);
@ -368,18 +358,14 @@ int main(int argc, char** argv) {
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_FCAMERA)); encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_FCAMERA));
s.rotate_state[LOG_CAMERA_ID_FCAMERA].enabled = true; s.rotate_state[LOG_CAMERA_ID_FCAMERA].enabled = true;
#if defined(QCOM) || defined(QCOM2) if (!Hardware::PC() && Params().getBool("RecordFront")) {
bool record_front = Params().getBool("RecordFront");
if (record_front) {
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_DCAMERA)); encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_DCAMERA));
s.rotate_state[LOG_CAMERA_ID_DCAMERA].enabled = true; s.rotate_state[LOG_CAMERA_ID_DCAMERA].enabled = true;
} }
if (Hardware::TICI()) {
#ifdef QCOM2 encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_ECAMERA));
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_ECAMERA)); s.rotate_state[LOG_CAMERA_ID_ECAMERA].enabled = true;
s.rotate_state[LOG_CAMERA_ID_ECAMERA].enabled = true; }
#endif
#endif
uint64_t msg_count = 0; uint64_t msg_count = 0;
uint64_t bytes_count = 0; uint64_t bytes_count = 0;
@ -453,9 +439,7 @@ int main(int argc, char** argv) {
new_segment &= (((r.stream_frame_id >= r.last_rotate_frame_id + SEGMENT_LENGTH * MAIN_FPS) && new_segment &= (((r.stream_frame_id >= r.last_rotate_frame_id + SEGMENT_LENGTH * MAIN_FPS) &&
(!r.should_rotate) && (r.initialized)) || (!r.should_rotate) && (r.initialized)) ||
(!r.enabled)); (!r.enabled));
#ifndef QCOM2 if (!Hardware::TICI()) break; // only look at fcamera frame id if not QCOM2
break; // only look at fcamera frame id if not QCOM2
#endif
} }
} else { } else {
if (tms - last_rotate_tms > SEGMENT_LENGTH * 1000) { if (tms - last_rotate_tms > SEGMENT_LENGTH * 1000) {

View File

@ -8,7 +8,7 @@
#include "common/clutil.h" #include "common/clutil.h"
#include "common/util.h" #include "common/util.h"
#include "common/params.h" #include "common/params.h"
#include "selfdrive/hardware/hw.h"
#include "models/driving.h" #include "models/driving.h"
#include "messaging.h" #include "messaging.h"
@ -133,17 +133,12 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
set_realtime_priority(54); set_realtime_priority(54);
#ifdef QCOM if (Hardware::EON()) {
set_core_affinity(2); set_core_affinity(2);
#elif QCOM2 } else if (Hardware::TICI()) {
set_core_affinity(7); set_core_affinity(7);
#endif }
bool wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false;
bool wide_camera = false;
#ifdef QCOM2
wide_camera = Params().getBool("EnableWideCamera");
#endif
// start calibration thread // start calibration thread
std::thread thread = std::thread(calibration_thread, wide_camera); std::thread thread = std::thread(calibration_thread, wide_camera);

View File

@ -1,10 +1,11 @@
#include <string.h> #include <string.h>
#include <libyuv.h>
#include "selfdrive/hardware/hw.h"
#include "dmonitoring.h" #include "dmonitoring.h"
#include "common/mat.h" #include "common/mat.h"
#include "common/timing.h" #include "common/timing.h"
#include "common/params.h" #include "common/params.h"
#include <libyuv.h>
#define MODEL_WIDTH 320 #define MODEL_WIDTH 320
#define MODEL_HEIGHT 640 #define MODEL_HEIGHT 640
@ -17,12 +18,8 @@
#endif #endif
void dmonitoring_init(DMonitoringModelState* s) { void dmonitoring_init(DMonitoringModelState* s) {
#if defined(QCOM) || defined(QCOM2) const char *model_path = Hardware::PC() ? "../../models/dmonitoring_model.dlc"
const char* model_path = "../../models/dmonitoring_model_q.dlc"; : "../../models/dmonitoring_model_q.dlc";
#else
const char* model_path = "../../models/dmonitoring_model.dlc";
#endif
int runtime = USE_DSP_RUNTIME; int runtime = USE_DSP_RUNTIME;
s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, runtime); s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, runtime);
s->is_rhd = Params().getBool("IsRHD"); s->is_rhd = Params().getBool("IsRHD");
@ -55,24 +52,26 @@ void crop_yuv(uint8_t *raw, int width, int height, uint8_t *y, uint8_t *u, uint8
} }
DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height) { DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height) {
#ifndef QCOM2 Rect crop_rect;
Rect crop_rect = {0, 0, height / 2, height}; if (Hardware::TICI()) {
if (!s->is_rhd) { const int full_width_tici = 1928;
crop_rect.x += width - crop_rect.w; const int full_height_tici = 1208;
const int adapt_width_tici = 668;
const int cropped_height = adapt_width_tici / 1.33;
crop_rect = {full_width_tici / 2 - adapt_width_tici / 2,
full_height_tici / 2 - cropped_height / 2 - 196,
cropped_height / 2,
cropped_height};
if (!s->is_rhd) {
crop_rect.x += adapt_width_tici - crop_rect.w + 32;
}
} else {
crop_rect = {0, 0, height / 2, height};
if (!s->is_rhd) {
crop_rect.x += width - crop_rect.w;
}
} }
#else
const int full_width_tici = 1928;
const int full_height_tici = 1208;
const int adapt_width_tici = 668;
const int cropped_height = adapt_width_tici / 1.33;
Rect crop_rect = {full_width_tici / 2 - adapt_width_tici / 2,
full_height_tici / 2 - cropped_height / 2 - 196,
cropped_height / 2,
cropped_height};
if (!s->is_rhd) {
crop_rect.x += adapt_width_tici - crop_rect.w + 32;
}
#endif
int resized_width = MODEL_WIDTH; int resized_width = MODEL_WIDTH;
int resized_height = MODEL_HEIGHT; int resized_height = MODEL_HEIGHT;

View File

@ -3,6 +3,7 @@
#include "qt/window.h" #include "qt/window.h"
#include "qt/qt_window.h" #include "qt/qt_window.h"
#include "selfdrive/hardware/hw.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QSurfaceFormat fmt; QSurfaceFormat fmt;
@ -15,15 +16,12 @@ int main(int argc, char *argv[]) {
#endif #endif
QSurfaceFormat::setDefaultFormat(fmt); QSurfaceFormat::setDefaultFormat(fmt);
#ifdef QCOM if (Hardware::EON()) {
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem"));
#ifdef QCOM QSslConfiguration::setDefaultConfiguration(ssl);
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration(); }
ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem", QSsl::Pem, QRegExp::Wildcard));
QSslConfiguration::setDefaultConfiguration(ssl);
#endif
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;

View File

@ -19,16 +19,12 @@
#include "nanovg_gl.h" #include "nanovg_gl.h"
#include "nanovg_gl_utils.h" #include "nanovg_gl_utils.h"
#include "paint.h" #include "paint.h"
#include "selfdrive/hardware/hw.h"
// TODO: this is also hardcoded in common/transformations/camera.py // TODO: this is also hardcoded in common/transformations/camera.py
// TODO: choose based on frame input size // TODO: choose based on frame input size
#ifdef QCOM2 const float y_offset = Hardware::TICI() ? 150.0 : 0.0;
const float y_offset = 150.0; const float zoom = Hardware::TICI() ? 2912.8 : 2138.5;
const float zoom = 2912.8;
#else
const float y_offset = 0.0;
const float zoom = 2138.5;
#endif
static void ui_draw_text(const UIState *s, float x, float y, const char *string, float size, NVGcolor color, const char *font_name) { static void ui_draw_text(const UIState *s, float x, float y, const char *string, float size, NVGcolor color, const char *font_name) {
nvgFontFace(s->vg, font_name); nvgFontFace(s->vg, font_name);
@ -129,11 +125,11 @@ static void draw_frame(UIState *s) {
if (s->last_frame) { if (s->last_frame) {
glBindTexture(GL_TEXTURE_2D, s->texture[s->last_frame->idx]->frame_tex); glBindTexture(GL_TEXTURE_2D, s->texture[s->last_frame->idx]->frame_tex);
#ifndef QCOM if (!Hardware::EON()) {
// this is handled in ion on QCOM // this is handled in ion on QCOM
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->last_frame->width, s->last_frame->height, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->last_frame->width, s->last_frame->height,
0, GL_RGB, GL_UNSIGNED_BYTE, s->last_frame->addr); 0, GL_RGB, GL_UNSIGNED_BYTE, s->last_frame->addr);
#endif }
} }
glUseProgram(s->gl_shader->prog); glUseProgram(s->gl_shader->prog);
@ -246,13 +242,9 @@ static void ui_draw_driver_view(UIState *s) {
// blackout // blackout
const int blackout_x_r = valid_rect.right(); const int blackout_x_r = valid_rect.right();
#ifndef QCOM2 const Rect &blackout_rect = Hardware::TICI() ? s->viz_rect : rect;
const int blackout_w_r = rect.right() - valid_rect.right(); const int blackout_w_r = blackout_rect.right() - valid_rect.right();
const int blackout_x_l = rect.x; const int blackout_x_l = blackout_rect.x;
#else
const int blackout_w_r = s->viz_rect.right() - valid_rect.right();
const int blackout_x_l = s->viz_rect.x;
#endif
const int blackout_w_l = valid_rect.x - blackout_x_l; const int blackout_w_l = valid_rect.x - blackout_x_l;
ui_fill_rect(s->vg, {blackout_x_l, rect.y, blackout_w_l, rect.h}, COLOR_BLACK_ALPHA(144)); ui_fill_rect(s->vg, {blackout_x_l, rect.y, blackout_w_l, rect.h}, COLOR_BLACK_ALPHA(144));
ui_fill_rect(s->vg, {blackout_x_r, rect.y, blackout_w_r, rect.h}, COLOR_BLACK_ALPHA(144)); ui_fill_rect(s->vg, {blackout_x_r, rect.y, blackout_w_r, rect.h}, COLOR_BLACK_ALPHA(144));
@ -426,41 +418,42 @@ static const mat4 device_transform = {{
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0,
}}; }};
static const float driver_view_ratio = 1.333; static mat4 get_driver_view_transform() {
#ifndef QCOM2 const float driver_view_ratio = 1.333;
// frame from 4/3 to 16/9 display mat4 transform;
static const mat4 driver_view_transform = {{ if (Hardware::TICI()) {
driver_view_ratio*(1080-2*bdr_s)/(1920-2*bdr_s), 0.0, 0.0, 0.0, // from dmonitoring.cc
0.0, 1.0, 0.0, 0.0, const int full_width_tici = 1928;
0.0, 0.0, 1.0, 0.0, const int full_height_tici = 1208;
0.0, 0.0, 0.0, 1.0, const int adapt_width_tici = 668;
}}; const int crop_x_offset = 32;
#else const int crop_y_offset = -196;
// from dmonitoring.cc const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici;
static const int full_width_tici = 1928; const float xscale = yscale*(1080-2*bdr_s)/(2160-2*bdr_s)*full_width_tici/full_height_tici;
static const int full_height_tici = 1208; transform = (mat4){{
static const int adapt_width_tici = 668; xscale, 0.0, 0.0, xscale*crop_x_offset/full_width_tici*2,
static const int crop_x_offset = 32; 0.0, yscale, 0.0, yscale*crop_y_offset/full_height_tici*2,
static const int crop_y_offset = -196; 0.0, 0.0, 1.0, 0.0,
static const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici; 0.0, 0.0, 0.0, 1.0,
static const float xscale = yscale*(1080-2*bdr_s)/(2160-2*bdr_s)*full_width_tici/full_height_tici; }};
static const mat4 driver_view_transform = {{ } else {
xscale, 0.0, 0.0, xscale*crop_x_offset/full_width_tici*2, // frame from 4/3 to 16/9 display
0.0, yscale, 0.0, yscale*crop_y_offset/full_height_tici*2, transform = (mat4){{
0.0, 0.0, 1.0, 0.0, driver_view_ratio*(1080-2*bdr_s)/(1920-2*bdr_s), 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0,
}}; 0.0, 0.0, 1.0, 0.0,
#endif 0.0, 0.0, 0.0, 1.0,
}};
}
return transform;
}
void ui_nvg_init(UIState *s) { void ui_nvg_init(UIState *s) {
// init drawing // init drawing
#ifdef QCOM
// on QCOM, we enable MSAA // on EON, we enable MSAA
s->vg = nvgCreate(0); s->vg = Hardware::EON() ? nvgCreate(0) : nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
#else
s->vg = nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
#endif
assert(s->vg); assert(s->vg);
// init fonts // init fonts
@ -554,7 +547,7 @@ void ui_nvg_init(UIState *s) {
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0,
}}; }};
s->front_frame_mat = matmul(device_transform, driver_view_transform); s->front_frame_mat = matmul(device_transform, get_driver_view_transform());
s->rear_frame_mat = matmul(device_transform, frame_transform); s->rear_frame_mat = matmul(device_transform, frame_transform);
// Apply transformation such that video pixel coordinates match video // Apply transformation such that video pixel coordinates match video

View File

@ -13,12 +13,11 @@
#include "api.h" #include "api.h"
#include "common/params.h" #include "common/params.h"
#include "common/util.h" #include "common/util.h"
#include "selfdrive/hardware/hw.h"
#if defined(QCOM) || defined(QCOM2) const std::string private_key_path =
const std::string private_key_path = "/persist/comma/id_rsa"; !Hardware::PC() ? util::getenv_default("HOME", "/.comma/persist/comma/id_rsa", "/persist/comma/id_rsa")
#else : "/persist/comma/id_rsa";
const std::string private_key_path = util::getenv_default("HOME", "/.comma/persist/comma/id_rsa", "/persist/comma/id_rsa");
#endif
QByteArray CommaApi::rsa_sign(const QByteArray &data) { QByteArray CommaApi::rsa_sign(const QByteArray &data) {
auto file = QFile(private_key_path.c_str()); auto file = QFile(private_key_path.c_str());

View File

@ -49,13 +49,13 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
"../assets/offroad/icon_shell.png", "../assets/offroad/icon_shell.png",
this)); this));
#ifndef QCOM2 if (Hardware::TICI()) {
toggles.append(new ParamControl("IsUploadRawEnabled", toggles.append(new ParamControl("IsUploadRawEnabled",
"Upload Raw Logs", "Upload Raw Logs",
"Upload full logs and full resolution video by default while on WiFi. If not enabled, individual logs can be marked for upload at my.comma.ai/useradmin.", "Upload full logs and full resolution video by default while on WiFi. If not enabled, individual logs can be marked for upload at my.comma.ai/useradmin.",
"../assets/offroad/icon_network.png", "../assets/offroad/icon_network.png",
this)); this));
#endif }
ParamControl *record_toggle = new ParamControl("RecordFront", ParamControl *record_toggle = new ParamControl("RecordFront",
"Record and Upload Driver Camera", "Record and Upload Driver Camera",
@ -69,19 +69,18 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
"../assets/offroad/icon_road.png", "../assets/offroad/icon_road.png",
this)); this));
#ifdef QCOM2 if (Hardware::TICI()) {
toggles.append(new ParamControl("EnableWideCamera", toggles.append(new ParamControl("EnableWideCamera",
"Enable use of Wide Angle Camera", "Enable use of Wide Angle Camera",
"Use wide angle camera for driving and ui. Only takes effect after reboot.", "Use wide angle camera for driving and ui. Only takes effect after reboot.",
"../assets/offroad/icon_openpilot.png", "../assets/offroad/icon_openpilot.png",
this)); this));
toggles.append(new ParamControl("EnableLteOnroad", toggles.append(new ParamControl("EnableLteOnroad",
"Enable LTE while onroad", "Enable LTE while onroad",
"", "",
"../assets/offroad/icon_network.png", "../assets/offroad/icon_network.png",
this)); this));
}
#endif
bool record_lock = Params().getBool("RecordFrontLock"); bool record_lock = Params().getBool("RecordFrontLock");
record_toggle->setEnabled(!record_lock); record_toggle->setEnabled(!record_lock);

View File

@ -2,19 +2,15 @@
#include <QWidget> #include <QWidget>
#include <QApplication> #include <QApplication>
#include "selfdrive/hardware/hw.h"
#ifdef QCOM2 #ifdef QCOM2
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#include <QPlatformSurfaceEvent> #include <QPlatformSurfaceEvent>
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#endif #endif
const int vwp_w = Hardware::TICI() ? 2160 : 1920;
#ifdef QCOM2 const int vwp_h = 1080;
const int vwp_w = 2160, vwp_h = 1080;
#else
const int vwp_w = 1920, vwp_h = 1080;
#endif
inline void setMainWindow(QWidget *w) { inline void setMainWindow(QWidget *w) {
const float scale = getenv("SCALE") != NULL ? std::stof(getenv("SCALE")) : 1.0; const float scale = getenv("SCALE") != NULL ? std::stof(getenv("SCALE")) : 1.0;

View File

@ -10,6 +10,7 @@
#include "offroad/networking.h" #include "offroad/networking.h"
#include "widgets/input.h" #include "widgets/input.h"
#include "qt_window.h" #include "qt_window.h"
#include "selfdrive/hardware/hw.h"
#define USER_AGENT "AGNOSSetup-0.1" #define USER_AGENT "AGNOSSetup-0.1"
@ -141,9 +142,9 @@ QWidget * Setup::download_failed() {
QPushButton *reboot_btn = new QPushButton("Reboot"); QPushButton *reboot_btn = new QPushButton("Reboot");
nav_layout->addWidget(reboot_btn, 0, Qt::AlignBottom | Qt::AlignLeft); nav_layout->addWidget(reboot_btn, 0, Qt::AlignBottom | Qt::AlignLeft);
QObject::connect(reboot_btn, &QPushButton::released, this, [=]() { QObject::connect(reboot_btn, &QPushButton::released, this, [=]() {
#ifdef QCOM2 if (Hardware::TICI()) {
std::system("sudo reboot"); std::system("sudo reboot");
#endif }
}); });
QPushButton *restart_btn = new QPushButton("Start over"); QPushButton *restart_btn = new QPushButton("Start over");

View File

@ -1,6 +1,7 @@
#include "common/util.h" #include "common/util.h"
#include "sidebar.h" #include "sidebar.h"
#include "qt_window.h" #include "qt_window.h"
#include "selfdrive/hardware/hw.h"
StatusWidget::StatusWidget(bool has_substatus, QWidget *parent) : QFrame(parent) { StatusWidget::StatusWidget(bool has_substatus, QWidget *parent) : QFrame(parent) {
layout = new QVBoxLayout(); layout = new QVBoxLayout();
@ -178,11 +179,9 @@ void Sidebar::update(const UIState &s) {
panda_color = COLOR_DANGER; panda_color = COLOR_DANGER;
panda_message = "NO\nPANDA"; panda_message = "NO\nPANDA";
} }
#ifdef QCOM2 else if (Hardware::TICI() && s.scene.started) {
else if (s.scene.started) {
panda_color = s.scene.gpsOK ? COLOR_GOOD : COLOR_WARNING; panda_color = s.scene.gpsOK ? COLOR_GOOD : COLOR_WARNING;
panda_message = QString("SAT CNT\n%1").arg(s.scene.satelliteCount); panda_message = QString("SAT CNT\n%1").arg(s.scene.satelliteCount);
} }
#endif
panda->update(panda_message, panda_color); panda->update(panda_message, panda_color);
} }

View File

@ -2,6 +2,7 @@
#include "input.h" #include "input.h"
#include "qt_window.h" #include "qt_window.h"
#include "selfdrive/hardware/hw.h"
InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(parent) { InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(parent) {
layout = new QVBoxLayout(); layout = new QVBoxLayout();
@ -172,8 +173,8 @@ bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) {
int ConfirmationDialog::exec() { int ConfirmationDialog::exec() {
// TODO: make this work without fullscreen // TODO: make this work without fullscreen
#ifdef QCOM2 if (Hardware::TICI()) {
setMainWindow(this); setMainWindow(this);
#endif }
return QDialog::exec(); return QDialog::exec();
} }

View File

@ -1,14 +1,10 @@
#include "replay.h" #include "replay.h"
#include "selfdrive/hardware/hw.h"
Replay::Replay(QString route_, int seek) : route(route_) { Replay::Replay(QString route_, int seek) : route(route_) {
unlogger = new Unlogger(&events, &events_lock, &frs, seek); unlogger = new Unlogger(&events, &events_lock, &frs, seek);
current_segment = 0; current_segment = 0;
bool create_jwt = true; bool create_jwt = !Hardware::PC();
#if !defined(QCOM) && !defined(QCOM2)
create_jwt = false;
#endif
http = new HttpRequest(this, "https://api.commadotai.com/v1/route/" + route + "/files", "", create_jwt); http = new HttpRequest(this, "https://api.commadotai.com/v1/route/" + route + "/files", "", create_jwt);
QObject::connect(http, &HttpRequest::receivedResponse, this, &Replay::parseResponse); QObject::connect(http, &HttpRequest::receivedResponse, this, &Replay::parseResponse);
} }

View File

@ -8,7 +8,7 @@
#include "common/swaglog.h" #include "common/swaglog.h"
#include "common/visionimg.h" #include "common/visionimg.h"
#include "common/watchdog.h" #include "common/watchdog.h"
#include "hardware/hw.h" #include "selfdrive/hardware/hw.h"
#include "ui.h" #include "ui.h"
#include "paint.h" #include "paint.h"
#include "qt_window.h" #include "qt_window.h"
@ -192,11 +192,10 @@ static void update_state(UIState *s) {
} }
if (sm.updated("sensorEvents")) { if (sm.updated("sensorEvents")) {
for (auto sensor : sm["sensorEvents"].getSensorEvents()) { for (auto sensor : sm["sensorEvents"].getSensorEvents()) {
if (sensor.which() == cereal::SensorEventData::LIGHT) { if (!Hardware::TICI() && sensor.which() == cereal::SensorEventData::LIGHT) {
#ifndef QCOM2
scene.light_sensor = sensor.getLight(); scene.light_sensor = sensor.getLight();
#endif }
} else if (!scene.started && sensor.which() == cereal::SensorEventData::ACCELERATION) { if (!scene.started && sensor.which() == cereal::SensorEventData::ACCELERATION) {
auto accel = sensor.getAcceleration().getV(); auto accel = sensor.getAcceleration().getV();
if (accel.totalSize().wordCount){ // TODO: sometimes empty lists are received. Figure out why if (accel.totalSize().wordCount){ // TODO: sometimes empty lists are received. Figure out why
scene.accel_sensor = accel[2]; scene.accel_sensor = accel[2];
@ -209,13 +208,11 @@ static void update_state(UIState *s) {
} }
} }
} }
#ifdef QCOM2 if (Hardware::TICI() && sm.updated("roadCameraState")) {
if (sm.updated("roadCameraState")) {
auto camera_state = sm["roadCameraState"].getRoadCameraState(); auto camera_state = sm["roadCameraState"].getRoadCameraState();
float gain = camera_state.getGainFrac() * (camera_state.getGlobalGain() > 100 ? 2.5 : 1.0) / 10.0; float gain = camera_state.getGainFrac() * (camera_state.getGlobalGain() > 100 ? 2.5 : 1.0) / 10.0;
scene.light_sensor = std::clamp<float>((1023.0 / 1757.0) * (1757.0 - camera_state.getIntegLines()) * (1.0 - gain), 0.0, 1023.0); scene.light_sensor = std::clamp<float>((1023.0 / 1757.0) * (1757.0 - camera_state.getIntegLines()) * (1.0 - gain), 0.0, 1023.0);
} }
#endif
scene.started = scene.deviceState.getStarted() || scene.driver_view; scene.started = scene.deviceState.getStarted() || scene.driver_view;
} }
@ -244,10 +241,8 @@ static void update_vision(UIState *s) {
VisionBuf * buf = s->vipc_client->recv(); VisionBuf * buf = s->vipc_client->recv();
if (buf != nullptr){ if (buf != nullptr){
s->last_frame = buf; s->last_frame = buf;
} else { } else if (!Hardware::PC()) {
#if defined(QCOM) || defined(QCOM2)
LOGE("visionIPC receive timeout"); LOGE("visionIPC receive timeout");
#endif
} }
} }
} }
@ -295,11 +290,7 @@ QUIState::QUIState(QObject *parent) : QObject(parent) {
ui_state.fb_h = vwp_h; ui_state.fb_h = vwp_h;
ui_state.scene.started = false; ui_state.scene.started = false;
ui_state.last_frame = nullptr; ui_state.last_frame = nullptr;
ui_state.wide_camera = false; ui_state.wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false;
#ifdef QCOM2
ui_state.wide_camera = Params().getBool("EnableWideCamera");
#endif
ui_state.vipc_client_rear = new VisionIpcClient("camerad", ui_state.wide_camera ? VISION_STREAM_RGB_WIDE : VISION_STREAM_RGB_BACK, true); ui_state.vipc_client_rear = new VisionIpcClient("camerad", ui_state.wide_camera ? VISION_STREAM_RGB_WIDE : VISION_STREAM_RGB_BACK, true);
ui_state.vipc_client_front = new VisionIpcClient("camerad", VISION_STREAM_RGB_FRONT, true); ui_state.vipc_client_front = new VisionIpcClient("camerad", VISION_STREAM_RGB_FRONT, true);
@ -359,12 +350,9 @@ void Device::setAwake(bool on, bool reset) {
void Device::updateBrightness(const UIState &s) { void Device::updateBrightness(const UIState &s) {
float clipped_brightness = std::min(100.0f, (s.scene.light_sensor * brightness_m) + brightness_b); float clipped_brightness = std::min(100.0f, (s.scene.light_sensor * brightness_m) + brightness_b);
if (Hardware::TICI() && !s.scene.started) {
#ifdef QCOM2
if (!s.scene.started) {
clipped_brightness = BACKLIGHT_OFFROAD; clipped_brightness = BACKLIGHT_OFFROAD;
} }
#endif
int brightness = brightness_filter.update(clipped_brightness); int brightness = brightness_filter.update(clipped_brightness);
if (!awake) { if (!awake) {