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 erroralbatross
parent
937c2fa9f3
commit
757d2923d2
|
@ -27,6 +27,7 @@
|
|||
#include "common/timing.h"
|
||||
#include "messaging.h"
|
||||
#include "locationd/ublox_msg.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#include "panda.h"
|
||||
#include "pigeon.h"
|
||||
|
@ -361,18 +362,18 @@ void panda_state_thread(bool spoofing_started) {
|
|||
auto ps = msg.initEvent().initPandaState();
|
||||
ps.setUptime(pandaState.uptime);
|
||||
|
||||
#ifdef QCOM2
|
||||
double read_time = millis_since_boot();
|
||||
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")));
|
||||
read_time = millis_since_boot() - read_time;
|
||||
if (read_time > 50) {
|
||||
LOGW("reading hwmon took %lfms", read_time);
|
||||
if (Hardware::TICI()) {
|
||||
double read_time = millis_since_boot();
|
||||
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")));
|
||||
read_time = millis_since_boot() - read_time;
|
||||
if (read_time > 50) {
|
||||
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.setIgnitionCan(pandaState.ignition_can);
|
||||
|
@ -417,17 +418,14 @@ void hardware_control_thread() {
|
|||
uint16_t prev_fan_speed = 999;
|
||||
uint16_t ir_pwr = 0;
|
||||
uint16_t prev_ir_pwr = 999;
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
bool prev_charging_disabled = false;
|
||||
#endif
|
||||
unsigned int cnt = 0;
|
||||
|
||||
while (!do_exit && panda->connected) {
|
||||
cnt++;
|
||||
sm.update(1000); // TODO: what happens if EINTR is sent while in sm.update?
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
if (sm.updated("deviceState")){
|
||||
if (!Hardware::PC() && sm.updated("deviceState")){
|
||||
// Charging mode
|
||||
bool charging_disabled = sm["deviceState"].getDeviceState().getChargingDisabled();
|
||||
if (charging_disabled != prev_charging_disabled){
|
||||
|
@ -441,7 +439,6 @@ void hardware_control_thread() {
|
|||
prev_charging_disabled = charging_disabled;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
|
@ -491,11 +488,7 @@ void pigeon_thread() {
|
|||
PubMaster pm({"ubloxRaw"});
|
||||
bool ignition_last = false;
|
||||
|
||||
#ifdef QCOM2
|
||||
Pigeon *pigeon = Pigeon::connect("/dev/ttyHS0");
|
||||
#else
|
||||
Pigeon *pigeon = Pigeon::connect(panda);
|
||||
#endif
|
||||
Pigeon *pigeon = Hardware::TICI() ? Pigeon::connect("/dev/ttyHS0") : Pigeon::connect(panda);
|
||||
|
||||
std::unordered_map<char, uint64_t> last_recv_time;
|
||||
std::unordered_map<char, int64_t> cls_max_dt = {
|
||||
|
@ -572,11 +565,7 @@ int main() {
|
|||
err = set_realtime_priority(54);
|
||||
LOG("set priority returns %d", err);
|
||||
|
||||
#ifdef QCOM2
|
||||
err = set_core_affinity(4);
|
||||
#else
|
||||
err = set_core_affinity(3);
|
||||
#endif
|
||||
err = set_core_affinity(Hardware::TICI() ? 4 : 3);
|
||||
LOG("set affinity returns %d", err);
|
||||
|
||||
while (!do_exit){
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "common/util.h"
|
||||
#include "modeldata.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) {
|
||||
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,
|
||||
b->rgb_width, b->rgb_height, b->rgb_stride,
|
||||
ci->bayer_flip, ci->hdr, s->camera_num);
|
||||
#ifdef QCOM2
|
||||
return cl_program_from_file(context, device_id, "cameras/real_debayer.cl", args);
|
||||
#else
|
||||
return cl_program_from_file(context, device_id, "cameras/debayer.cl", args);
|
||||
#endif
|
||||
const char *cl_file = Hardware::TICI() ? "cameras/real_debayer.cl" : "cameras/debayer.cl";
|
||||
return cl_program_from_file(context, device_id, cl_file, args);
|
||||
}
|
||||
|
||||
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_height = ci->frame_height;
|
||||
#ifndef QCOM2
|
||||
// debayering does a 2x downscale
|
||||
if (ci->bayer) {
|
||||
if (Hardware::TICI() && ci->bayer) {
|
||||
rgb_width = ci->frame_width / 2;
|
||||
rgb_height = ci->frame_height / 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
yuv_transform = get_model_yuv_transform(ci->bayer);
|
||||
|
||||
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");
|
||||
struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;};
|
||||
const CameraBuf *b = &c->buf;
|
||||
#ifndef QCOM2
|
||||
|
||||
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;
|
||||
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
|
||||
bool hist_ceil = true, hl_weighted = true;
|
||||
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};
|
||||
int analog_gain = c->analog_gain;
|
||||
#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;
|
||||
// use driver face crop for AE
|
||||
if (sm.updated("driverState")) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "common/swaglog.h"
|
||||
#include "common/util.h"
|
||||
#include "visionipc_server.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
ExitHandler do_exit;
|
||||
|
||||
|
@ -43,11 +44,11 @@ void party(cl_device_id device_id, cl_context context) {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
set_realtime_priority(53);
|
||||
#if defined(QCOM)
|
||||
set_core_affinity(2);
|
||||
#elif defined(QCOM2)
|
||||
set_core_affinity(6);
|
||||
#endif
|
||||
if (Hardware::EON()) {
|
||||
set_core_affinity(2);
|
||||
} else if (Hardware::TICI()) {
|
||||
set_core_affinity(6);
|
||||
}
|
||||
|
||||
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
||||
|
||||
|
|
|
@ -20,39 +20,26 @@ const double X_IDXS[TRAJECTORY_SIZE] = { 0. , 0.1875, 0.75 , 1.6875,
|
|||
#ifdef __cplusplus
|
||||
|
||||
#include "common/mat.h"
|
||||
#ifdef QCOM2
|
||||
const mat3 fcam_intrinsic_matrix = (mat3){{
|
||||
2648.0, 0.0, 1928.0/2,
|
||||
0.0, 2648.0, 1208.0/2,
|
||||
0.0, 0.0, 1.0
|
||||
}};
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
const mat3 fcam_intrinsic_matrix =
|
||||
Hardware::TICI() ? (mat3){{2648.0, 0.0, 1928.0 / 2,
|
||||
0.0, 2648.0, 1208.0 / 2,
|
||||
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
|
||||
const mat3 ecam_intrinsic_matrix = (mat3){{
|
||||
620.0, 0.0, 1928.0/2,
|
||||
0.0, 620.0, 1208.0/2,
|
||||
0.0, 0.0, 1.0
|
||||
}};
|
||||
#else
|
||||
const mat3 fcam_intrinsic_matrix = (mat3){{
|
||||
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
|
||||
const mat3 ecam_intrinsic_matrix =
|
||||
Hardware::TICI() ? (mat3){{620.0, 0.0, 1928.0 / 2,
|
||||
0.0, 620.0, 1208.0 / 2,
|
||||
0.0, 0.0, 1.0}}
|
||||
: (mat3){{0., 0., 0.,
|
||||
0., 0., 0.,
|
||||
0., 0., 0.}};
|
||||
|
||||
static inline mat3 get_model_yuv_transform(bool bayer = true) {
|
||||
#ifndef QCOM2
|
||||
float db_s = 0.5; // debayering does a 2x downscale
|
||||
#else
|
||||
float db_s = 1.0;
|
||||
#endif
|
||||
float db_s = Hardware::TICI() ? 0.5 : 1.0; // debayering does a 2x downscale on TICI
|
||||
const mat3 transform = (mat3){{
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <unordered_map>
|
||||
#include "common/util.h"
|
||||
#include "common/swaglog.h"
|
||||
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
// keep trying if x gets interrupted by a signal
|
||||
#define HANDLE_EINTR(x) \
|
||||
({ \
|
||||
|
@ -30,13 +30,8 @@
|
|||
|
||||
namespace {
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
const std::string default_params_path = "/data/params";
|
||||
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
|
||||
const std::string default_params_path = !Hardware::PC() ? "/data/params" : util::getenv_default("HOME", "/.comma/params", "/data/params");
|
||||
const std::string persistent_params_path = !Hardware::PC() ? "/persist/comma/params" : default_params_path;
|
||||
|
||||
volatile sig_atomic_t params_do_exit = 0;
|
||||
void params_sig_handler(int signal) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "common/util.h"
|
||||
#include "common/version.h"
|
||||
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "swaglog.h"
|
||||
|
||||
class LogState {
|
||||
|
@ -71,9 +71,9 @@ static void cloudlog_init() {
|
|||
s.ctx_j["dirty"] = !getenv("CLEAN");
|
||||
|
||||
// device type
|
||||
if (util::file_exists("/EON")) {
|
||||
if (Hardware::EON()) {
|
||||
cloudlog_bind_locked("device", "eon");
|
||||
} else if (util::file_exists("/TICI")) {
|
||||
} else if (Hardware::TICI()) {
|
||||
cloudlog_bind_locked("device", "tici");
|
||||
} else {
|
||||
cloudlog_bind_locked("device", "pc");
|
||||
|
|
|
@ -7,16 +7,27 @@
|
|||
// no-op base hw class
|
||||
class HardwareNone {
|
||||
public:
|
||||
enum Type {
|
||||
typePC,
|
||||
typeEON,
|
||||
typeTICI
|
||||
};
|
||||
|
||||
static constexpr float MAX_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 poweroff() {};
|
||||
static void set_brightness(int percent) {};
|
||||
static void set_display_power(bool on) {};
|
||||
static void reboot() {}
|
||||
static void poweroff() {}
|
||||
static void set_brightness(int percent) {}
|
||||
static void set_display_power(bool on) {}
|
||||
|
||||
static bool get_ssh_enabled() { return false; };
|
||||
static void set_ssh_enabled(bool enabled) {};
|
||||
static bool get_ssh_enabled() { return false; }
|
||||
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; }
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
static constexpr float MAX_VOLUME = 1.0;
|
||||
static constexpr float MIN_VOLUME = 0.5;
|
||||
|
||||
static Type type() { return typeEON; }
|
||||
static std::string get_os_version() {
|
||||
return "NEOS " + util::read_file("/VERSION");
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ class HardwareTici : public HardwareNone {
|
|||
public:
|
||||
static constexpr float MAX_VOLUME = 0.5;
|
||||
static constexpr float MIN_VOLUME = 0.4;
|
||||
|
||||
static Type type() { return typeTICI; }
|
||||
static std::string get_os_version() {
|
||||
return "AGNOS " + util::read_file("/VERSION");
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "common/params.h"
|
||||
#include "common/version.h"
|
||||
#include "messaging.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
|
@ -53,9 +54,9 @@ kj::Array<capnp::word> logger_build_init_data() {
|
|||
MessageBuilder msg;
|
||||
auto init = msg.initEvent().initInitData();
|
||||
|
||||
if (util::file_exists("/EON")) {
|
||||
if (Hardware::EON()) {
|
||||
init.setDeviceType(cereal::InitData::DeviceType::NEO);
|
||||
} else if (util::file_exists("/TICI")) {
|
||||
} else if (Hardware::TICI()) {
|
||||
init.setDeviceType(cereal::InitData::DeviceType::TICI);
|
||||
} else {
|
||||
init.setDeviceType(cereal::InitData::DeviceType::PC);
|
||||
|
|
|
@ -8,13 +8,11 @@
|
|||
#include <kj/array.h>
|
||||
#include <capnp/serialize.h>
|
||||
#include "common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
const std::string LOG_ROOT = "/data/media/0/realdata";
|
||||
#else
|
||||
const std::string LOG_ROOT = util::getenv_default("HOME", "/.comma/media/0/realdata", "/data/media/0/realdata");
|
||||
#endif
|
||||
|
||||
const std::string LOG_ROOT =
|
||||
Hardware::PC() ? util::getenv_default("HOME", "/.comma/media/0/realdata", "/data/media/0/realdata")
|
||||
: "/data/media/0/realdata";
|
||||
#define LOGGER_MAX_HANDLES 16
|
||||
|
||||
class BZFile {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "logger.h"
|
||||
#include "messaging.h"
|
||||
#include "services.h"
|
||||
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "visionipc.h"
|
||||
#include "visionipc_client.h"
|
||||
|
||||
|
@ -42,16 +42,9 @@
|
|||
namespace {
|
||||
|
||||
constexpr int MAIN_FPS = 20;
|
||||
|
||||
#ifndef QCOM2
|
||||
constexpr int MAIN_BITRATE = 5000000;
|
||||
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
|
||||
const int MAIN_BITRATE = Hardware::TICI() ? 10000000 : 5000000;
|
||||
const int MAX_CAM_IDX = Hardware::TICI() ? LOG_CAMERA_ID_ECAMERA : LOG_CAMERA_ID_DCAMERA;
|
||||
const int DCAM_BITRATE = Hardware::TICI() ? MAIN_BITRATE : 2500000;
|
||||
|
||||
#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,
|
||||
.is_h265 = false,
|
||||
.downscale = true,
|
||||
#ifndef QCOM2
|
||||
.frame_width = 480, .frame_height = 360
|
||||
#else
|
||||
.frame_width = 526, .frame_height = 330 // keep pixel count the same?
|
||||
#endif
|
||||
.frame_width = Hardware::TICI() ? 526 : 480,
|
||||
.frame_height = Hardware::TICI() ? 330 : 360 // keep pixel count the same?
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -279,11 +269,11 @@ void encoder_thread(int cam_idx) {
|
|||
eidx.setFrameId(extra.frame_id);
|
||||
eidx.setTimestampSof(extra.timestamp_sof);
|
||||
eidx.setTimestampEof(extra.timestamp_eof);
|
||||
#ifdef QCOM2
|
||||
eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C);
|
||||
#else
|
||||
eidx.setType(cam_idx == LOG_CAMERA_ID_DCAMERA ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C);
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
eidx.setType(cereal::EncodeIndex::Type::FULL_H_E_V_C);
|
||||
} else {
|
||||
eidx.setType(cam_idx == LOG_CAMERA_ID_DCAMERA ? cereal::EncodeIndex::Type::FRONT : cereal::EncodeIndex::Type::FULL_H_E_V_C);
|
||||
}
|
||||
eidx.setEncodeId(cnt);
|
||||
eidx.setSegmentNum(rotate_state.cur_seg);
|
||||
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));
|
||||
s.rotate_state[LOG_CAMERA_ID_FCAMERA].enabled = true;
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
bool record_front = Params().getBool("RecordFront");
|
||||
if (record_front) {
|
||||
if (!Hardware::PC() && Params().getBool("RecordFront")) {
|
||||
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_DCAMERA));
|
||||
s.rotate_state[LOG_CAMERA_ID_DCAMERA].enabled = true;
|
||||
}
|
||||
|
||||
#ifdef QCOM2
|
||||
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_ECAMERA));
|
||||
s.rotate_state[LOG_CAMERA_ID_ECAMERA].enabled = true;
|
||||
#endif
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
encoder_threads.push_back(std::thread(encoder_thread, LOG_CAMERA_ID_ECAMERA));
|
||||
s.rotate_state[LOG_CAMERA_ID_ECAMERA].enabled = true;
|
||||
}
|
||||
|
||||
uint64_t msg_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) &&
|
||||
(!r.should_rotate) && (r.initialized)) ||
|
||||
(!r.enabled));
|
||||
#ifndef QCOM2
|
||||
break; // only look at fcamera frame id if not QCOM2
|
||||
#endif
|
||||
if (!Hardware::TICI()) break; // only look at fcamera frame id if not QCOM2
|
||||
}
|
||||
} else {
|
||||
if (tms - last_rotate_tms > SEGMENT_LENGTH * 1000) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "common/clutil.h"
|
||||
#include "common/util.h"
|
||||
#include "common/params.h"
|
||||
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "models/driving.h"
|
||||
#include "messaging.h"
|
||||
|
||||
|
@ -133,17 +133,12 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client) {
|
|||
int main(int argc, char **argv) {
|
||||
set_realtime_priority(54);
|
||||
|
||||
#ifdef QCOM
|
||||
set_core_affinity(2);
|
||||
#elif QCOM2
|
||||
set_core_affinity(7);
|
||||
#endif
|
||||
|
||||
bool wide_camera = false;
|
||||
|
||||
#ifdef QCOM2
|
||||
wide_camera = Params().getBool("EnableWideCamera");
|
||||
#endif
|
||||
if (Hardware::EON()) {
|
||||
set_core_affinity(2);
|
||||
} else if (Hardware::TICI()) {
|
||||
set_core_affinity(7);
|
||||
}
|
||||
bool wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false;
|
||||
|
||||
// start calibration thread
|
||||
std::thread thread = std::thread(calibration_thread, wide_camera);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <string.h>
|
||||
#include <libyuv.h>
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "dmonitoring.h"
|
||||
#include "common/mat.h"
|
||||
#include "common/timing.h"
|
||||
#include "common/params.h"
|
||||
|
||||
#include <libyuv.h>
|
||||
|
||||
#define MODEL_WIDTH 320
|
||||
#define MODEL_HEIGHT 640
|
||||
|
@ -17,12 +18,8 @@
|
|||
#endif
|
||||
|
||||
void dmonitoring_init(DMonitoringModelState* s) {
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
const char* model_path = "../../models/dmonitoring_model_q.dlc";
|
||||
#else
|
||||
const char* model_path = "../../models/dmonitoring_model.dlc";
|
||||
#endif
|
||||
|
||||
const char *model_path = Hardware::PC() ? "../../models/dmonitoring_model.dlc"
|
||||
: "../../models/dmonitoring_model_q.dlc";
|
||||
int runtime = USE_DSP_RUNTIME;
|
||||
s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, runtime);
|
||||
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) {
|
||||
#ifndef QCOM2
|
||||
Rect crop_rect = {0, 0, height / 2, height};
|
||||
if (!s->is_rhd) {
|
||||
crop_rect.x += width - crop_rect.w;
|
||||
Rect crop_rect;
|
||||
if (Hardware::TICI()) {
|
||||
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;
|
||||
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_height = MODEL_HEIGHT;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "qt/window.h"
|
||||
#include "qt/qt_window.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QSurfaceFormat fmt;
|
||||
|
@ -15,15 +16,12 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
#ifdef QCOM
|
||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
#endif
|
||||
|
||||
#ifdef QCOM
|
||||
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
|
||||
ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem", QSsl::Pem, QRegExp::Wildcard));
|
||||
QSslConfiguration::setDefaultConfiguration(ssl);
|
||||
#endif
|
||||
if (Hardware::EON()) {
|
||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
|
||||
ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem"));
|
||||
QSslConfiguration::setDefaultConfiguration(ssl);
|
||||
}
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
|
|
@ -19,16 +19,12 @@
|
|||
#include "nanovg_gl.h"
|
||||
#include "nanovg_gl_utils.h"
|
||||
#include "paint.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
// TODO: this is also hardcoded in common/transformations/camera.py
|
||||
// TODO: choose based on frame input size
|
||||
#ifdef QCOM2
|
||||
const float y_offset = 150.0;
|
||||
const float zoom = 2912.8;
|
||||
#else
|
||||
const float y_offset = 0.0;
|
||||
const float zoom = 2138.5;
|
||||
#endif
|
||||
const float y_offset = Hardware::TICI() ? 150.0 : 0.0;
|
||||
const float zoom = Hardware::TICI() ? 2912.8 : 2138.5;
|
||||
|
||||
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);
|
||||
|
@ -129,11 +125,11 @@ static void draw_frame(UIState *s) {
|
|||
|
||||
if (s->last_frame) {
|
||||
glBindTexture(GL_TEXTURE_2D, s->texture[s->last_frame->idx]->frame_tex);
|
||||
#ifndef QCOM
|
||||
// this is handled in ion on QCOM
|
||||
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);
|
||||
#endif
|
||||
if (!Hardware::EON()) {
|
||||
// this is handled in ion on QCOM
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
glUseProgram(s->gl_shader->prog);
|
||||
|
@ -246,13 +242,9 @@ static void ui_draw_driver_view(UIState *s) {
|
|||
|
||||
// blackout
|
||||
const int blackout_x_r = valid_rect.right();
|
||||
#ifndef QCOM2
|
||||
const int blackout_w_r = rect.right() - valid_rect.right();
|
||||
const int blackout_x_l = 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 Rect &blackout_rect = Hardware::TICI() ? s->viz_rect : rect;
|
||||
const int blackout_w_r = blackout_rect.right() - valid_rect.right();
|
||||
const int blackout_x_l = blackout_rect.x;
|
||||
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_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,
|
||||
}};
|
||||
|
||||
static const float driver_view_ratio = 1.333;
|
||||
#ifndef QCOM2
|
||||
// frame from 4/3 to 16/9 display
|
||||
static const mat4 driver_view_transform = {{
|
||||
driver_view_ratio*(1080-2*bdr_s)/(1920-2*bdr_s), 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
#else
|
||||
// from dmonitoring.cc
|
||||
static const int full_width_tici = 1928;
|
||||
static const int full_height_tici = 1208;
|
||||
static const int adapt_width_tici = 668;
|
||||
static const int crop_x_offset = 32;
|
||||
static const int crop_y_offset = -196;
|
||||
static const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici;
|
||||
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 = {{
|
||||
xscale, 0.0, 0.0, xscale*crop_x_offset/full_width_tici*2,
|
||||
0.0, yscale, 0.0, yscale*crop_y_offset/full_height_tici*2,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
#endif
|
||||
static mat4 get_driver_view_transform() {
|
||||
const float driver_view_ratio = 1.333;
|
||||
mat4 transform;
|
||||
if (Hardware::TICI()) {
|
||||
// from dmonitoring.cc
|
||||
const int full_width_tici = 1928;
|
||||
const int full_height_tici = 1208;
|
||||
const int adapt_width_tici = 668;
|
||||
const int crop_x_offset = 32;
|
||||
const int crop_y_offset = -196;
|
||||
const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici;
|
||||
const float xscale = yscale*(1080-2*bdr_s)/(2160-2*bdr_s)*full_width_tici/full_height_tici;
|
||||
transform = (mat4){{
|
||||
xscale, 0.0, 0.0, xscale*crop_x_offset/full_width_tici*2,
|
||||
0.0, yscale, 0.0, yscale*crop_y_offset/full_height_tici*2,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
|
||||
} else {
|
||||
// frame from 4/3 to 16/9 display
|
||||
transform = (mat4){{
|
||||
driver_view_ratio*(1080-2*bdr_s)/(1920-2*bdr_s), 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
||||
void ui_nvg_init(UIState *s) {
|
||||
// init drawing
|
||||
#ifdef QCOM
|
||||
// on QCOM, we enable MSAA
|
||||
s->vg = nvgCreate(0);
|
||||
#else
|
||||
s->vg = nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
|
||||
#endif
|
||||
|
||||
// on EON, we enable MSAA
|
||||
s->vg = Hardware::EON() ? nvgCreate(0) : nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
|
||||
assert(s->vg);
|
||||
|
||||
// init fonts
|
||||
|
@ -554,7 +547,7 @@ void ui_nvg_init(UIState *s) {
|
|||
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);
|
||||
|
||||
// Apply transformation such that video pixel coordinates match video
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
#include "api.h"
|
||||
#include "common/params.h"
|
||||
#include "common/util.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
const std::string private_key_path = "/persist/comma/id_rsa";
|
||||
#else
|
||||
const std::string private_key_path = util::getenv_default("HOME", "/.comma/persist/comma/id_rsa", "/persist/comma/id_rsa");
|
||||
#endif
|
||||
const std::string private_key_path =
|
||||
!Hardware::PC() ? util::getenv_default("HOME", "/.comma/persist/comma/id_rsa", "/persist/comma/id_rsa")
|
||||
: "/persist/comma/id_rsa";
|
||||
|
||||
QByteArray CommaApi::rsa_sign(const QByteArray &data) {
|
||||
auto file = QFile(private_key_path.c_str());
|
||||
|
|
|
@ -49,13 +49,13 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
|
|||
"../assets/offroad/icon_shell.png",
|
||||
this));
|
||||
|
||||
#ifndef QCOM2
|
||||
toggles.append(new ParamControl("IsUploadRawEnabled",
|
||||
"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.",
|
||||
"../assets/offroad/icon_network.png",
|
||||
this));
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
toggles.append(new ParamControl("IsUploadRawEnabled",
|
||||
"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.",
|
||||
"../assets/offroad/icon_network.png",
|
||||
this));
|
||||
}
|
||||
|
||||
ParamControl *record_toggle = new ParamControl("RecordFront",
|
||||
"Record and Upload Driver Camera",
|
||||
|
@ -69,19 +69,18 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
|
|||
"../assets/offroad/icon_road.png",
|
||||
this));
|
||||
|
||||
#ifdef QCOM2
|
||||
toggles.append(new ParamControl("EnableWideCamera",
|
||||
"Enable use of Wide Angle Camera",
|
||||
"Use wide angle camera for driving and ui. Only takes effect after reboot.",
|
||||
"../assets/offroad/icon_openpilot.png",
|
||||
this));
|
||||
toggles.append(new ParamControl("EnableLteOnroad",
|
||||
"Enable LTE while onroad",
|
||||
"",
|
||||
"../assets/offroad/icon_network.png",
|
||||
this));
|
||||
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
toggles.append(new ParamControl("EnableWideCamera",
|
||||
"Enable use of Wide Angle Camera",
|
||||
"Use wide angle camera for driving and ui. Only takes effect after reboot.",
|
||||
"../assets/offroad/icon_openpilot.png",
|
||||
this));
|
||||
toggles.append(new ParamControl("EnableLteOnroad",
|
||||
"Enable LTE while onroad",
|
||||
"",
|
||||
"../assets/offroad/icon_network.png",
|
||||
this));
|
||||
}
|
||||
|
||||
bool record_lock = Params().getBool("RecordFrontLock");
|
||||
record_toggle->setEnabled(!record_lock);
|
||||
|
|
|
@ -2,19 +2,15 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef QCOM2
|
||||
const int vwp_w = 2160, vwp_h = 1080;
|
||||
#else
|
||||
const int vwp_w = 1920, vwp_h = 1080;
|
||||
#endif
|
||||
const int vwp_w = Hardware::TICI() ? 2160 : 1920;
|
||||
const int vwp_h = 1080;
|
||||
|
||||
inline void setMainWindow(QWidget *w) {
|
||||
const float scale = getenv("SCALE") != NULL ? std::stof(getenv("SCALE")) : 1.0;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "offroad/networking.h"
|
||||
#include "widgets/input.h"
|
||||
#include "qt_window.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
#define USER_AGENT "AGNOSSetup-0.1"
|
||||
|
||||
|
@ -141,9 +142,9 @@ QWidget * Setup::download_failed() {
|
|||
QPushButton *reboot_btn = new QPushButton("Reboot");
|
||||
nav_layout->addWidget(reboot_btn, 0, Qt::AlignBottom | Qt::AlignLeft);
|
||||
QObject::connect(reboot_btn, &QPushButton::released, this, [=]() {
|
||||
#ifdef QCOM2
|
||||
std::system("sudo reboot");
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
std::system("sudo reboot");
|
||||
}
|
||||
});
|
||||
|
||||
QPushButton *restart_btn = new QPushButton("Start over");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "common/util.h"
|
||||
#include "sidebar.h"
|
||||
#include "qt_window.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
StatusWidget::StatusWidget(bool has_substatus, QWidget *parent) : QFrame(parent) {
|
||||
layout = new QVBoxLayout();
|
||||
|
@ -178,11 +179,9 @@ void Sidebar::update(const UIState &s) {
|
|||
panda_color = COLOR_DANGER;
|
||||
panda_message = "NO\nPANDA";
|
||||
}
|
||||
#ifdef QCOM2
|
||||
else if (s.scene.started) {
|
||||
else if (Hardware::TICI() && s.scene.started) {
|
||||
panda_color = s.scene.gpsOK ? COLOR_GOOD : COLOR_WARNING;
|
||||
panda_message = QString("SAT CNT\n%1").arg(s.scene.satelliteCount);
|
||||
}
|
||||
#endif
|
||||
panda->update(panda_message, panda_color);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "input.h"
|
||||
#include "qt_window.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(parent) {
|
||||
layout = new QVBoxLayout();
|
||||
|
@ -172,8 +173,8 @@ bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) {
|
|||
|
||||
int ConfirmationDialog::exec() {
|
||||
// TODO: make this work without fullscreen
|
||||
#ifdef QCOM2
|
||||
setMainWindow(this);
|
||||
#endif
|
||||
if (Hardware::TICI()) {
|
||||
setMainWindow(this);
|
||||
}
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
#include "replay.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
Replay::Replay(QString route_, int seek) : route(route_) {
|
||||
unlogger = new Unlogger(&events, &events_lock, &frs, seek);
|
||||
current_segment = 0;
|
||||
bool create_jwt = true;
|
||||
|
||||
#if !defined(QCOM) && !defined(QCOM2)
|
||||
create_jwt = false;
|
||||
#endif
|
||||
|
||||
bool create_jwt = !Hardware::PC();
|
||||
http = new HttpRequest(this, "https://api.commadotai.com/v1/route/" + route + "/files", "", create_jwt);
|
||||
QObject::connect(http, &HttpRequest::receivedResponse, this, &Replay::parseResponse);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "common/swaglog.h"
|
||||
#include "common/visionimg.h"
|
||||
#include "common/watchdog.h"
|
||||
#include "hardware/hw.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
#include "ui.h"
|
||||
#include "paint.h"
|
||||
#include "qt_window.h"
|
||||
|
@ -192,11 +192,10 @@ static void update_state(UIState *s) {
|
|||
}
|
||||
if (sm.updated("sensorEvents")) {
|
||||
for (auto sensor : sm["sensorEvents"].getSensorEvents()) {
|
||||
if (sensor.which() == cereal::SensorEventData::LIGHT) {
|
||||
#ifndef QCOM2
|
||||
if (!Hardware::TICI() && sensor.which() == cereal::SensorEventData::LIGHT) {
|
||||
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();
|
||||
if (accel.totalSize().wordCount){ // TODO: sometimes empty lists are received. Figure out why
|
||||
scene.accel_sensor = accel[2];
|
||||
|
@ -209,13 +208,11 @@ static void update_state(UIState *s) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef QCOM2
|
||||
if (sm.updated("roadCameraState")) {
|
||||
if (Hardware::TICI() && sm.updated("roadCameraState")) {
|
||||
auto camera_state = sm["roadCameraState"].getRoadCameraState();
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
scene.started = scene.deviceState.getStarted() || scene.driver_view;
|
||||
}
|
||||
|
||||
|
@ -244,10 +241,8 @@ static void update_vision(UIState *s) {
|
|||
VisionBuf * buf = s->vipc_client->recv();
|
||||
if (buf != nullptr){
|
||||
s->last_frame = buf;
|
||||
} else {
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
} else if (!Hardware::PC()) {
|
||||
LOGE("visionIPC receive timeout");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,11 +290,7 @@ QUIState::QUIState(QObject *parent) : QObject(parent) {
|
|||
ui_state.fb_h = vwp_h;
|
||||
ui_state.scene.started = false;
|
||||
ui_state.last_frame = nullptr;
|
||||
ui_state.wide_camera = false;
|
||||
|
||||
#ifdef QCOM2
|
||||
ui_state.wide_camera = Params().getBool("EnableWideCamera");
|
||||
#endif
|
||||
ui_state.wide_camera = Hardware::TICI() ? Params().getBool("EnableWideCamera") : false;
|
||||
|
||||
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);
|
||||
|
@ -359,12 +350,9 @@ void Device::setAwake(bool on, bool reset) {
|
|||
|
||||
void Device::updateBrightness(const UIState &s) {
|
||||
float clipped_brightness = std::min(100.0f, (s.scene.light_sensor * brightness_m) + brightness_b);
|
||||
|
||||
#ifdef QCOM2
|
||||
if (!s.scene.started) {
|
||||
if (Hardware::TICI() && !s.scene.started) {
|
||||
clipped_brightness = BACKLIGHT_OFFROAD;
|
||||
}
|
||||
#endif
|
||||
|
||||
int brightness = brightness_filter.update(clipped_brightness);
|
||||
if (!awake) {
|
||||
|
|
Loading…
Reference in New Issue