Wunused (#1841)
* enable Wunused, first pass * unused stuff in snpe model * these are used on phone * handle sigint and sigterm in modeld * fix phone build * camera qcom * QCOM build works * delete unused camerad vars Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: eb1aa3d831fd0d7fffd9aacec1accb0a5bdb0304
This commit is contained in:
@@ -114,6 +114,7 @@ env = Environment(
|
||||
"-g",
|
||||
"-fPIC",
|
||||
"-O2",
|
||||
"-Wunused",
|
||||
"-Werror",
|
||||
"-Wno-deprecated-register",
|
||||
"-Wno-inconsistent-missing-override",
|
||||
|
||||
@@ -61,14 +61,17 @@ bool fake_send = false;
|
||||
bool loopback_can = false;
|
||||
cereal::HealthData::HwType hw_type = cereal::HealthData::HwType::UNKNOWN;
|
||||
bool is_pigeon = false;
|
||||
const uint32_t NO_IGNITION_CNT_MAX = 2 * 60 * 60 * 30; // turn off charge after 30 hrs
|
||||
const float VBATT_START_CHARGING = 11.5;
|
||||
const float VBATT_PAUSE_CHARGING = 11.0;
|
||||
float voltage_f = 12.5; // filtered voltage
|
||||
uint32_t no_ignition_cnt = 0;
|
||||
bool connected_once = false;
|
||||
bool ignition_last = false;
|
||||
|
||||
#ifndef __x86_64__
|
||||
const uint32_t NO_IGNITION_CNT_MAX = 2 * 60 * 60 * 30; // turn off charge after 30 hrs
|
||||
const float VBATT_START_CHARGING = 11.5;
|
||||
const float VBATT_PAUSE_CHARGING = 11.0;
|
||||
#endif
|
||||
|
||||
bool safety_setter_thread_initialized = false;
|
||||
pthread_t safety_setter_thread_handle;
|
||||
|
||||
@@ -277,7 +280,6 @@ void can_recv(PubMaster &pm) {
|
||||
int err;
|
||||
uint32_t data[RECV_SIZE/4];
|
||||
int recv;
|
||||
uint32_t f1, f2;
|
||||
|
||||
uint64_t start_time = nanos_since_boot();
|
||||
|
||||
@@ -455,7 +457,7 @@ void can_health(PubMaster &pm) {
|
||||
uint16_t fan_speed_rpm = 0;
|
||||
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
int sz = libusb_control_transfer(dev_handle, 0xc0, 0xb2, 0, 0, (unsigned char*)&fan_speed_rpm, sizeof(fan_speed_rpm), TIMEOUT);
|
||||
libusb_control_transfer(dev_handle, 0xc0, 0xb2, 0, 0, (unsigned char*)&fan_speed_rpm, sizeof(fan_speed_rpm), TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
|
||||
// Write to rtc once per minute when no ignition present
|
||||
@@ -721,6 +723,7 @@ void *hardware_control_thread(void *crap) {
|
||||
|
||||
#define pigeon_send(x) _pigeon_send(x, sizeof(x)-1)
|
||||
|
||||
void hexdump(unsigned char *d, int l) __attribute__((unused));
|
||||
void hexdump(unsigned char *d, int l) {
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (i!=0 && i%0x10 == 0) printf("\n");
|
||||
|
||||
@@ -32,9 +32,7 @@ void camera_close(CameraState *s) {
|
||||
tbuffer_stop(&s->camera_tb);
|
||||
}
|
||||
|
||||
void camera_release_buffer(void *cookie, int buf_idx) {
|
||||
CameraState *s = static_cast<CameraState *>(cookie);
|
||||
}
|
||||
void camera_release_buffer(void *cookie, int buf_idx) {}
|
||||
|
||||
void camera_init(CameraState *s, int camera_id, unsigned int fps) {
|
||||
assert(camera_id < ARRAYSIZE(cameras_supported));
|
||||
@@ -48,7 +46,6 @@ void camera_init(CameraState *s, int camera_id, unsigned int fps) {
|
||||
}
|
||||
|
||||
void run_frame_stream(DualCameraState *s) {
|
||||
int err;
|
||||
SubMaster sm({"frame"});
|
||||
|
||||
CameraState *const rear_camera = &s->rear;
|
||||
@@ -121,7 +118,6 @@ void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear,
|
||||
VisionBuf *camera_bufs_front) {
|
||||
assert(camera_bufs_rear);
|
||||
assert(camera_bufs_front);
|
||||
int err;
|
||||
|
||||
// LOG("*** open front ***");
|
||||
camera_open(&s->front, camera_bufs_front, false);
|
||||
|
||||
@@ -163,16 +163,6 @@ static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, int
|
||||
|
||||
//printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->cur_frame_length, analog_gain, s->digital_gain);
|
||||
|
||||
int digital_gain = 0x100;
|
||||
|
||||
float white_balance[] = {0.4609375, 1.0, 0.546875};
|
||||
//float white_balance[] = {1.0, 1.0, 1.0};
|
||||
|
||||
int digital_gain_gr = digital_gain / white_balance[1];
|
||||
int digital_gain_gb = digital_gain / white_balance[1];
|
||||
int digital_gain_r = digital_gain / white_balance[0];
|
||||
int digital_gain_b = digital_gain / white_balance[2];
|
||||
|
||||
struct msm_camera_i2c_reg_array reg_array[] = {
|
||||
// REG_HOLD
|
||||
{0x104,0x1,0},
|
||||
|
||||
@@ -171,7 +171,7 @@ void* frontview_thread(void *arg) {
|
||||
int rgb_idx = ui_idx;
|
||||
FrameMetadata frame_data = s->cameras.front.camera_bufs_metadata[buf_idx];
|
||||
|
||||
double t1 = millis_since_boot();
|
||||
//double t1 = millis_since_boot();
|
||||
|
||||
cl_event debayer_event;
|
||||
if (s->cameras.front.ci.bayer) {
|
||||
@@ -329,8 +329,7 @@ void* frontview_thread(void *arg) {
|
||||
|
||||
tbuffer_dispatch(&s->ui_front_tb, ui_idx);
|
||||
|
||||
double t2 = millis_since_boot();
|
||||
|
||||
//double t2 = millis_since_boot();
|
||||
//LOGD("front process: %.2fms", t2-t1);
|
||||
}
|
||||
|
||||
@@ -514,8 +513,6 @@ void* processing_thread(void *arg) {
|
||||
s->yuv_metas[yuv_idx] = frame_data;
|
||||
|
||||
uint8_t* yuv_ptr_y = s->yuv_bufs[yuv_idx].y;
|
||||
uint8_t* yuv_ptr_u = s->yuv_bufs[yuv_idx].u;
|
||||
uint8_t* yuv_ptr_v = s->yuv_bufs[yuv_idx].v;
|
||||
cl_mem yuv_cl = s->yuv_cl[yuv_idx];
|
||||
rgb_to_yuv_queue(&s->rgb_to_yuv_state, q, s->rgb_bufs_cl[rgb_idx], yuv_cl);
|
||||
visionbuf_sync(&s->yuv_ion[yuv_idx], VISIONBUF_SYNC_FROM_DEVICE);
|
||||
@@ -1252,7 +1249,6 @@ void party(VisionState *s) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int err;
|
||||
set_realtime_priority(51);
|
||||
|
||||
zsys_handler_set(NULL);
|
||||
|
||||
@@ -175,6 +175,7 @@ cl_program cl_cached_program_from_hash(cl_context ctx, cl_device_id device_id, u
|
||||
return prg;
|
||||
}
|
||||
|
||||
#ifndef CLU_NO_CACHE
|
||||
static uint8_t* get_program_binary(cl_program prg, size_t *out_size) {
|
||||
int err;
|
||||
|
||||
@@ -199,6 +200,7 @@ static uint8_t* get_program_binary(cl_program prg, size_t *out_size) {
|
||||
*out_size = binary_size;
|
||||
return binary_buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
cl_program cl_cached_program_from_string(cl_context ctx, cl_device_id device_id,
|
||||
const char* src, const char* args,
|
||||
@@ -265,13 +267,14 @@ cl_program cl_cached_program_from_file(cl_context ctx, cl_device_id device_id, c
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef CLU_NO_CACHE
|
||||
static void add_index(uint64_t index_hash, uint64_t src_hash) {
|
||||
FILE *f = fopen("/tmp/clcache/index.cli", "a");
|
||||
assert(f);
|
||||
fprintf(f, "%016" PRIx64 " %016" PRIx64 "\n", index_hash, src_hash);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
cl_program cl_program_from_index(cl_context ctx, cl_device_id device_id, uint64_t index_hash) {
|
||||
int err;
|
||||
|
||||
@@ -60,8 +60,6 @@ int ipc_bind(const char* socket_path) {
|
||||
|
||||
int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds,
|
||||
int *out_num_fds) {
|
||||
int err;
|
||||
|
||||
char control_buf[CMSG_SPACE(sizeof(int) * num_fds)];
|
||||
memset(control_buf, 0, CMSG_SPACE(sizeof(int) * num_fds));
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
|
||||
// make copy due to alignment issues
|
||||
auto amsg = kj::heapArray<capnp::word>((params.size() / sizeof(capnp::word)) + 1);
|
||||
memcpy(amsg.begin(), params.data(), params.size());
|
||||
|
||||
|
||||
capnp::FlatArrayMessageReader cmsg(amsg);
|
||||
cereal::CarParams::Reader car_params = cmsg.getRoot<cereal::CarParams>();
|
||||
|
||||
@@ -53,7 +53,6 @@ int main(int argc, char *argv[]) {
|
||||
double sR = car_params.getSteerRatio();
|
||||
double x = 1.0;
|
||||
double ao = 0.0;
|
||||
double posenet_invalid_count = 0;
|
||||
std::vector<char> live_params = read_db_bytes("LiveParameters");
|
||||
if (live_params.size() > 0){
|
||||
std::string err;
|
||||
|
||||
@@ -96,6 +96,7 @@ static OMX_CALLBACKTYPE omx_callbacks = {
|
||||
#define PORT_INDEX_IN 0
|
||||
#define PORT_INDEX_OUT 1
|
||||
|
||||
static const char* omx_color_fomat_name(uint32_t format) __attribute__((unused));
|
||||
static const char* omx_color_fomat_name(uint32_t format) {
|
||||
switch (format) {
|
||||
case OMX_COLOR_FormatUnused: return "OMX_COLOR_FormatUnused";
|
||||
@@ -397,9 +398,9 @@ static void handle_out_buf(EncoderState *s, OMX_BUFFERHEADERTYPE *out_buf) {
|
||||
}
|
||||
|
||||
if (s->stream_sock_raw) {
|
||||
uint64_t current_time = nanos_since_boot();
|
||||
uint64_t diff = current_time - out_buf->nTimeStamp*1000LL;
|
||||
double msdiff = (double) diff / 1000000.0;
|
||||
//uint64_t current_time = nanos_since_boot();
|
||||
//uint64_t diff = current_time - out_buf->nTimeStamp*1000LL;
|
||||
//double msdiff = (double) diff / 1000000.0;
|
||||
// printf("encoded latency to tsEof: %f\n", msdiff);
|
||||
zmq_send(s->stream_sock_raw, &out_buf->nTimeStamp, sizeof(out_buf->nTimeStamp), ZMQ_SNDMORE);
|
||||
zmq_send(s->stream_sock_raw, buf_data, out_buf->nFilledLen, 0);
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
double randrange(double a, double b) __attribute__((unused));
|
||||
double randrange(double a, double b) {
|
||||
static std::mt19937 gen(millis_since_boot());
|
||||
|
||||
@@ -165,9 +166,9 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t current_time = nanos_since_boot();
|
||||
uint64_t diff = current_time - extra.timestamp_eof;
|
||||
double msdiff = (double) diff / 1000000.0;
|
||||
//uint64_t current_time = nanos_since_boot();
|
||||
//uint64_t diff = current_time - extra.timestamp_eof;
|
||||
//double msdiff = (double) diff / 1000000.0;
|
||||
// printf("logger latency to tsEof: %f\n", msdiff);
|
||||
|
||||
uint8_t *y = (uint8_t*)buf->addr;
|
||||
|
||||
@@ -25,6 +25,9 @@ int main(int argc, char **argv) {
|
||||
int err;
|
||||
set_realtime_priority(51);
|
||||
|
||||
signal(SIGINT, (sighandler_t)set_do_exit);
|
||||
signal(SIGTERM, (sighandler_t)set_do_exit);
|
||||
|
||||
// messaging
|
||||
SubMaster sm({"dMonitoringState"});
|
||||
PubMaster pm({"driverState"});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <eigen3/Eigen/Dense>
|
||||
|
||||
#include "common/visionbuf.h"
|
||||
@@ -20,7 +21,6 @@ mat3 cur_transform;
|
||||
pthread_mutex_t transform_lock;
|
||||
|
||||
void* live_thread(void *arg) {
|
||||
int err;
|
||||
set_thread_name("live");
|
||||
|
||||
SubMaster sm({"liveCalibration"});
|
||||
@@ -75,6 +75,9 @@ int main(int argc, char **argv) {
|
||||
int err;
|
||||
set_realtime_priority(51);
|
||||
|
||||
signal(SIGINT, (sighandler_t)set_do_exit);
|
||||
signal(SIGTERM, (sighandler_t)set_do_exit);
|
||||
|
||||
// start calibration thread
|
||||
pthread_t live_thread_handle;
|
||||
err = pthread_create(&live_thread_handle, NULL, live_thread, NULL);
|
||||
|
||||
@@ -36,7 +36,6 @@ float *frame_prepare(ModelFrame* frame, cl_command_queue q,
|
||||
cl_mem yuv_cl, int width, int height,
|
||||
mat3 transform) {
|
||||
int err;
|
||||
int i = 0;
|
||||
transform_queue(&frame->transform, q,
|
||||
yuv_cl, width, height,
|
||||
frame->transformed_y_cl, frame->transformed_u_cl, frame->transformed_v_cl,
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "snpemodel.h"
|
||||
|
||||
void PrintErrorStringAndExit() {
|
||||
const char* const errStr = zdl::DlSystem::getLastErrorString();
|
||||
std::cerr << zdl::DlSystem::getLastErrorString() << std::endl;
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ private:
|
||||
Thneed *thneed = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef QCOM
|
||||
zdl::DlSystem::Runtime_t Runtime;
|
||||
#endif
|
||||
|
||||
// snpe model stuff
|
||||
std::unique_ptr<zdl::SNPE::SNPE> snpe;
|
||||
|
||||
@@ -99,7 +99,7 @@ GPUMalloc::GPUMalloc(int size, int fd) {
|
||||
memset(&alloc, 0, sizeof(alloc));
|
||||
alloc.size = size;
|
||||
alloc.flags = 0x10000a00;
|
||||
int ret = ioctl(fd, IOCTL_KGSL_GPUOBJ_ALLOC, &alloc);
|
||||
ioctl(fd, IOCTL_KGSL_GPUOBJ_ALLOC, &alloc);
|
||||
void *addr = mmap64(NULL, alloc.mmapsize, 0x3, 0x1, fd, alloc.id*0x1000);
|
||||
assert(addr != MAP_FAILED);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ struct ProcCache {
|
||||
}
|
||||
|
||||
int main() {
|
||||
int err;
|
||||
PubMaster publisher({"procLog"});
|
||||
|
||||
double jiffy = sysconf(_SC_CLK_TCK);
|
||||
@@ -61,8 +60,8 @@ int main() {
|
||||
unsigned long utime, ntime, stime, itime;
|
||||
unsigned long iowtime, irqtime, sirqtime;
|
||||
|
||||
int count = sscanf(stat_line.data(), "cpu%d %lu %lu %lu %lu %lu %lu %lu",
|
||||
&id, &utime, &ntime, &stime, &itime, &iowtime, &irqtime, &sirqtime);
|
||||
sscanf(stat_line.data(), "cpu%d %lu %lu %lu %lu %lu %lu %lu",
|
||||
&id, &utime, &ntime, &stime, &itime, &iowtime, &irqtime, &sirqtime);
|
||||
|
||||
auto ltimeo = orphanage.newOrphan<cereal::ProcLog::CPUTimes>();
|
||||
auto ltime = ltimeo.get();
|
||||
|
||||
@@ -155,7 +155,6 @@ void gps_destroy() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
int err = 0;
|
||||
setpriority(PRIO_PROCESS, 0, -13);
|
||||
|
||||
signal(SIGINT, (sighandler_t)set_do_exit);
|
||||
|
||||
@@ -437,6 +437,7 @@ static void ui_draw_vision_maxspeed(UIState *s) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
static void ui_draw_vision_speedlimit(UIState *s) {
|
||||
char speedlim_str[32];
|
||||
float speedlimit = s->scene.speedlimit;
|
||||
@@ -493,6 +494,7 @@ static void ui_draw_vision_speedlimit(UIState *s) {
|
||||
ui_draw_text(s->vg, text_x, viz_speedlim_y + (is_speedlim_valid ? 170 : 165), "N/A", 42*2.5, color, s->font_sans_semibold);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ui_draw_vision_speed(UIState *s) {
|
||||
const UIScene *scene = &s->scene;
|
||||
@@ -542,12 +544,14 @@ static void ui_draw_vision_event(UIState *s) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
static void ui_draw_vision_map(UIState *s) {
|
||||
const int map_size = 96;
|
||||
const int map_x = (s->scene.ui_viz_rx + (map_size * 3) + (bdr_s * 3));
|
||||
const int map_y = (footer_y + ((footer_h - map_size) / 2));
|
||||
ui_draw_circle_image(s->vg, map_x, map_y, map_size, s->img_map, s->scene.map_valid);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ui_draw_vision_face(UIState *s) {
|
||||
const int face_size = 96;
|
||||
|
||||
@@ -664,7 +664,7 @@ static void* light_sensor_thread(void *args) {
|
||||
|
||||
// need to do this
|
||||
struct sensor_t const* list;
|
||||
int count = module->get_sensors_list(module, &list);
|
||||
module->get_sensors_list(module, &list);
|
||||
|
||||
int SENSOR_LIGHT = 7;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user