Skip to content

Commit

Permalink
Merge branch 'commaai:master' into PA-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Edison-CBS authored Aug 4, 2024
2 parents c70f927 + 8f9b165 commit 8a87240
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions system/camerad/cameras/camera_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class ImgProc {
krnl_ = CL_CHECK_ERR(clCreateKernel(prg_imgproc, "process_raw", &err));
CL_CHECK(clReleaseProgram(prg_imgproc));

const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0};
queue = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err));
}

void runKernel(cl_command_queue q, cl_mem cam_buf_cl, cl_mem buf_cl, int width, int height, int expo_time) {
void runKernel(cl_mem cam_buf_cl, cl_mem buf_cl, int width, int height, int expo_time) {
CL_CHECK(clSetKernelArg(krnl_, 0, sizeof(cl_mem), &cam_buf_cl));
CL_CHECK(clSetKernelArg(krnl_, 1, sizeof(cl_mem), &buf_cl));
CL_CHECK(clSetKernelArg(krnl_, 2, sizeof(cl_int), &expo_time));
Expand All @@ -45,17 +47,19 @@ class ImgProc {
const size_t localWorkSize[] = {imgproc_local_worksize, imgproc_local_worksize};

cl_event event;
CL_CHECK(clEnqueueNDRangeKernel(q, krnl_, 2, NULL, globalWorkSize, localWorkSize, 0, 0, &event));
CL_CHECK(clEnqueueNDRangeKernel(queue, krnl_, 2, NULL, globalWorkSize, localWorkSize, 0, 0, &event));
clWaitForEvents(1, &event);
CL_CHECK(clReleaseEvent(event));
}

~ImgProc() {
CL_CHECK(clReleaseKernel(krnl_));
CL_CHECK(clReleaseCommandQueue(queue));
}

private:
cl_kernel krnl_;
cl_command_queue queue;
};

void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType type) {
Expand Down Expand Up @@ -92,17 +96,13 @@ void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s,
LOGD("created %d YUV vipc buffers with size %dx%d", YUV_BUFFER_COUNT, nv12_width, nv12_height);

imgproc = new ImgProc(device_id, context, this, s, nv12_width, nv12_uv_offset);

const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0};
q = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err));
}

CameraBuf::~CameraBuf() {
for (int i = 0; i < frame_buf_count; i++) {
camera_bufs[i].free();
}
if (imgproc) delete imgproc;
if (q) CL_CHECK(clReleaseCommandQueue(q));
}

bool CameraBuf::acquire() {
Expand All @@ -118,7 +118,7 @@ bool CameraBuf::acquire() {
cur_camera_buf = &camera_bufs[cur_buf_idx];

double start_time = millis_since_boot();
imgproc->runKernel(q, camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, rgb_width, rgb_height, cur_frame_data.integ_lines);
imgproc->runKernel(camera_bufs[cur_buf_idx].buf_cl, cur_yuv_buf->buf_cl, rgb_width, rgb_height, cur_frame_data.integ_lines);
cur_frame_data.processing_time = (millis_since_boot() - start_time) / 1000.0;

VisionIpcBufExtra extra = {
Expand Down
1 change: 0 additions & 1 deletion system/camerad/cameras/camera_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class CameraBuf {
int frame_buf_count;

public:
cl_command_queue q;
FrameMetadata cur_frame_data;
VisionBuf *cur_yuv_buf;
VisionBuf *cur_camera_buf;
Expand Down
8 changes: 5 additions & 3 deletions system/loggerd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from openpilot.system.hardware.hw import Paths
from openpilot.system.loggerd.xattr_cache import getxattr, setxattr
from openpilot.common.swaglog import cloudlog
from pathlib import Path

NetworkType = log.DeviceState.NetworkType
UPLOAD_ATTR_NAME = 'user.upload'
Expand Down Expand Up @@ -62,9 +61,12 @@ def listdir_by_creation(d: str) -> list[str]:
return []

def clear_locks(root: str) -> None:
for lock_file in Path(root).rglob('*.lock'):
for logdir in os.listdir(root):
path = os.path.join(root, logdir)
try:
lock_file.unlink()
for fname in os.listdir(path):
if fname.endswith(".lock"):
os.unlink(os.path.join(path, fname))
except OSError:
cloudlog.exception("clear_locks failed")

Expand Down

0 comments on commit 8a87240

Please sign in to comment.