Skip to content

Commit

Permalink
Revert "init camera in AbstraceCamera"
Browse files Browse the repository at this point in the history
This reverts commit ef86a44.
  • Loading branch information
deanlee committed Sep 12, 2022
1 parent 5fa151e commit c55b68a
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 206 deletions.
2 changes: 1 addition & 1 deletion system/camerad/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', 'yuv', cereal, messaging, 'zmq
cenv = env.Clone()
cenv['CPPPATH'].append('include/')

camera_obj = cenv.Object(['cameras/camera_qcom2.cc', 'cameras/camera.cc', 'cameras/camera_ar0231.cc','cameras/camera_ox03c10.cc','cameras/camera_common.cc', 'cameras/camera_util.cc'])
camera_obj = cenv.Object(['cameras/camera_qcom2.cc', 'cameras/camera_ar0231.cc','cameras/camera_ox03c10.cc','cameras/camera_common.cc', 'cameras/camera_util.cc'])
cenv.Program('camerad', [
'main.cc',
camera_obj,
Expand Down
129 changes: 0 additions & 129 deletions system/camerad/cameras/camera.cc

This file was deleted.

18 changes: 2 additions & 16 deletions system/camerad/cameras/camera.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <cassert>
#include <map>
#include <mutex>
#include <optional>
Expand All @@ -14,9 +13,6 @@
#include "media/cam_sensor.h"
#include "media/cam_sensor_cmn_header.h"
#include "media/cam_sync.h"

#include "common/util.h"
#include "system/camerad/cameras/camera_util.h"
#include "system/camerad/cameras/sensor2_i2c.h"

#define CAMERA_ID_IMX298 0
Expand Down Expand Up @@ -49,12 +45,8 @@ class AbstractCamera {
virtual ~AbstractCamera(){};
virtual std::vector<struct i2c_random_wr_payload> getExposureVector(int new_g, bool dc_gain_enabled, int exposure_time, int dc_gain_weight) const = 0;
virtual void processRegisters(void *addr, cereal::FrameData::Builder &framed) {}
virtual int getSlaveAddress(int port) = 0;
static std::unique_ptr<AbstractCamera> initCamera(int video0_fd, int sensor_fd, int camera_num);

CameraInfo ci;
MemoryManager mm;

int id;
float dc_gain_factor;
int dc_gain_max_weight;
Expand All @@ -68,15 +60,11 @@ class AbstractCamera {
float min_ev, max_ev;
int registers_offset = 0;
float sensor_analog_gains[16];
uint32_t in_port_info_dt;

camera_sensor_i2c_type i2c_type;
std::vector<struct i2c_random_wr_payload> start_reg_array;
std::vector<struct i2c_random_wr_payload> init_array;

protected:
bool init(int video0_fd, int sensor_fd, int camera_num);

uint32_t in_port_info_dt;
uint32_t reg_addr;
uint32_t expected_data;
uint32_t config_val_low;
Expand All @@ -86,20 +74,18 @@ class CameraAR0231 : public AbstractCamera {
public:
CameraAR0231();
~CameraAR0231();
int getSlaveAddress(int port) override;
std::vector<struct i2c_random_wr_payload> getExposureVector(int new_g, bool dc_gain_enabled, int exposure_time, int dc_gain_weight) const override;
void processRegisters(void *addr, cereal::FrameData::Builder &framed) override;

private:
std::map<uint16_t, uint16_t> parseRegisters(uint8_t *data, std::initializer_list<uint16_t> addrs);
std::map<uint16_t, std::pair<int, int>> buildREgisterLut(uint8_t *data);
std::map<uint16_t, std::pair<int, int>> buildRegisterLut(uint8_t *data);
std::map<uint16_t, std::pair<int, int>> ar0231_register_lut;
};

class CameraOX03C10 : public AbstractCamera {
public:
CameraOX03C10();
~CameraOX03C10();
int getSlaveAddress(int port) override;
std::vector<struct i2c_random_wr_payload> getExposureVector(int new_g, bool dc_gain_enabled, int exposure_time, int dc_gain_weight) const override;
};
9 changes: 2 additions & 7 deletions system/camerad/cameras/camera_ar0231.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ CameraAR0231::~CameraAR0231() {

}

int CameraAR0231::getSlaveAddress(int port) {
assert(port >=0 && port <= 2);
return (int[]){0x20, 0x30, 0x20}[port];
}

std::vector<struct i2c_random_wr_payload> CameraAR0231::getExposureVector(int new_g, bool dc_gain_enabled, int exposure_time, int dc_gain_weight) const {
uint16_t analog_gain_reg = 0xFF00 | (new_g << 4) | new_g;
return {
Expand All @@ -78,7 +73,7 @@ std::vector<struct i2c_random_wr_payload> CameraAR0231::getExposureVector(int ne
};
}

std::map<uint16_t, std::pair<int, int>> CameraAR0231::buildREgisterLut(uint8_t *data) {
std::map<uint16_t, std::pair<int, int>> CameraAR0231::buildRegisterLut(uint8_t *data) {
// This function builds a lookup table from register address, to a pair of indices in the
// buffer where to read this address. The buffer contains padding bytes,
// as well as markers to indicate the type of the next byte.
Expand Down Expand Up @@ -132,7 +127,7 @@ std::map<uint16_t, std::pair<int, int>> CameraAR0231::buildREgisterLut(uint8_t *

std::map<uint16_t, uint16_t> CameraAR0231::parseRegisters(uint8_t *data, std::initializer_list<uint16_t> addrs) {
if (ar0231_register_lut.empty()) {
ar0231_register_lut = buildREgisterLut(data);
ar0231_register_lut = buildRegisterLut(data);
}

std::map<uint16_t, uint16_t> registers;
Expand Down
5 changes: 0 additions & 5 deletions system/camerad/cameras/camera_ox03c10.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ CameraOX03C10::CameraOX03C10() {
CameraOX03C10::~CameraOX03C10() {
}

int CameraOX03C10::getSlaveAddress(int port) {
assert(port >=0 && port <= 2);
return (int[]){0x6C, 0x20, 0x6C}[port];
}

std::vector<struct i2c_random_wr_payload> CameraOX03C10::getExposureVector(int new_g, bool dc_gain_enabled, int exposure_time, int dc_gain_weight) const {
static constexpr uint32_t ox03c10_analog_gains_reg[] = {
0x100, 0x140, 0x150, 0x190,
Expand Down
Loading

0 comments on commit c55b68a

Please sign in to comment.