selfdrive/camerad
parent
ef93a715e1
commit
84560ccd55
|
@ -0,0 +1,19 @@
|
|||
Import('env', 'arch', 'messaging', 'common', 'gpucommon', 'visionipc', 'cereal')
|
||||
|
||||
libs = ['m', 'pthread', common, 'jpeg', 'json', cereal, 'OpenCL', messaging, 'czmq', 'zmq', 'capnp', 'kj', 'capnp_c', visionipc, gpucommon]
|
||||
|
||||
if arch == "aarch64":
|
||||
libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui']
|
||||
cameras = ['cameras/camera_qcom.c']
|
||||
else:
|
||||
libs += []
|
||||
cameras = ['cameras/camera_frame_stream.cc']
|
||||
|
||||
env.SharedLibrary('snapshot/visionipc',
|
||||
["#selfdrive/common/visionipc.c", "#selfdrive/common/ipc.c"])
|
||||
|
||||
env.Program('camerad', [
|
||||
'main.cc',
|
||||
'transforms/rgb_to_yuv.c',
|
||||
cameras,
|
||||
], LIBS=libs)
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _SELFDRIVE_VISIOND_VISIOND_H_
|
||||
#define _SELFDRIVE_VISIOND_VISIOND_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef struct { uint8_t *y, *u, *v; } YUVBuf;
|
||||
|
||||
#endif // _SELFDRIVE_VISIOND_VISIOND_H_
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef CAMERA_COMMON_H
|
||||
#define CAMERA_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CAMERA_ID_IMX298 0
|
||||
#define CAMERA_ID_IMX179 1
|
||||
#define CAMERA_ID_S5K3P8SP 2
|
||||
#define CAMERA_ID_OV8865 3
|
||||
#define CAMERA_ID_IMX298_FLIPPED 4
|
||||
#define CAMERA_ID_OV10640 5
|
||||
#define CAMERA_ID_MAX 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CameraInfo {
|
||||
const char* name;
|
||||
int frame_width, frame_height;
|
||||
int frame_stride;
|
||||
bool bayer;
|
||||
int bayer_flip;
|
||||
bool hdr;
|
||||
} CameraInfo;
|
||||
|
||||
typedef struct FrameMetadata {
|
||||
uint32_t frame_id;
|
||||
uint64_t timestamp_eof;
|
||||
unsigned int frame_length;
|
||||
unsigned int integ_lines;
|
||||
unsigned int global_gain;
|
||||
unsigned int lens_pos;
|
||||
float lens_sag;
|
||||
float lens_err;
|
||||
float lens_true_pos;
|
||||
float gain_frac;
|
||||
} FrameMetadata;
|
||||
|
||||
extern CameraInfo cameras_supported[CAMERA_ID_MAX];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,166 @@
|
|||
#include "camera_frame_stream.h"
|
||||
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <libyuv.h>
|
||||
#include <capnp/serialize.h>
|
||||
#include "cereal/gen/cpp/log.capnp.h"
|
||||
#include "messaging.hpp"
|
||||
|
||||
#include "common/util.h"
|
||||
#include "common/timing.h"
|
||||
#include "common/swaglog.h"
|
||||
#include "buffering.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
extern volatile sig_atomic_t do_exit;
|
||||
|
||||
#define FRAME_WIDTH 1164
|
||||
#define FRAME_HEIGHT 874
|
||||
|
||||
namespace {
|
||||
void camera_open(CameraState *s, VisionBuf *camera_bufs, bool rear) {
|
||||
assert(camera_bufs);
|
||||
s->camera_bufs = camera_bufs;
|
||||
}
|
||||
|
||||
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_init(CameraState *s, int camera_id, unsigned int fps) {
|
||||
assert(camera_id < ARRAYSIZE(cameras_supported));
|
||||
s->ci = cameras_supported[camera_id];
|
||||
assert(s->ci.frame_width != 0);
|
||||
|
||||
s->frame_size = s->ci.frame_height * s->ci.frame_stride;
|
||||
s->fps = fps;
|
||||
|
||||
tbuffer_init2(&s->camera_tb, FRAME_BUF_COUNT, "frame", camera_release_buffer, s);
|
||||
}
|
||||
|
||||
void run_frame_stream(DualCameraState *s) {
|
||||
int err;
|
||||
Context * context = Context::create();
|
||||
SubSocket * recorder_sock = SubSocket::create(context, "frame");
|
||||
assert(recorder_sock != NULL);
|
||||
|
||||
CameraState *const rear_camera = &s->rear;
|
||||
auto *tb = &rear_camera->camera_tb;
|
||||
|
||||
while (!do_exit) {
|
||||
Message * msg = recorder_sock->receive();
|
||||
|
||||
auto amsg = kj::heapArray<capnp::word>((msg->getSize() / sizeof(capnp::word)) + 1);
|
||||
memcpy(amsg.begin(), msg->getData(), msg->getSize());
|
||||
|
||||
capnp::FlatArrayMessageReader cmsg(amsg);
|
||||
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
|
||||
auto frame = event.getFrame();
|
||||
|
||||
const int buf_idx = tbuffer_select(tb);
|
||||
rear_camera->camera_bufs_metadata[buf_idx] = {
|
||||
.frame_id = frame.getFrameId(),
|
||||
.timestamp_eof = frame.getTimestampEof(),
|
||||
.frame_length = static_cast<unsigned>(frame.getFrameLength()),
|
||||
.integ_lines = static_cast<unsigned>(frame.getIntegLines()),
|
||||
.global_gain = static_cast<unsigned>(frame.getGlobalGain()),
|
||||
};
|
||||
|
||||
cl_command_queue q = rear_camera->camera_bufs[buf_idx].copy_q;
|
||||
cl_mem yuv_cl = rear_camera->camera_bufs[buf_idx].buf_cl;
|
||||
cl_event map_event;
|
||||
void *yuv_buf = (void *)clEnqueueMapBuffer(q, yuv_cl, CL_TRUE,
|
||||
CL_MAP_WRITE, 0, frame.getImage().size(),
|
||||
0, NULL, &map_event, &err);
|
||||
assert(err == 0);
|
||||
clWaitForEvents(1, &map_event);
|
||||
clReleaseEvent(map_event);
|
||||
memcpy(yuv_buf, frame.getImage().begin(), frame.getImage().size());
|
||||
|
||||
clEnqueueUnmapMemObject(q, yuv_cl, yuv_buf, 0, NULL, &map_event);
|
||||
clWaitForEvents(1, &map_event);
|
||||
clReleaseEvent(map_event);
|
||||
tbuffer_dispatch(tb, buf_idx);
|
||||
delete msg;
|
||||
|
||||
}
|
||||
delete recorder_sock;
|
||||
delete context;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CameraInfo cameras_supported[CAMERA_ID_MAX] = {
|
||||
[CAMERA_ID_IMX298] = {
|
||||
.frame_width = FRAME_WIDTH,
|
||||
.frame_height = FRAME_HEIGHT,
|
||||
.frame_stride = FRAME_WIDTH*3,
|
||||
.bayer = false,
|
||||
.bayer_flip = false,
|
||||
},
|
||||
[CAMERA_ID_OV8865] = {
|
||||
.frame_width = 1632,
|
||||
.frame_height = 1224,
|
||||
.frame_stride = 2040, // seems right
|
||||
.bayer = false,
|
||||
.bayer_flip = 3,
|
||||
.hdr = false
|
||||
},
|
||||
};
|
||||
|
||||
void cameras_init(DualCameraState *s) {
|
||||
memset(s, 0, sizeof(*s));
|
||||
|
||||
camera_init(&s->rear, CAMERA_ID_IMX298, 20);
|
||||
s->rear.transform = (mat3){{
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
}};
|
||||
|
||||
camera_init(&s->front, CAMERA_ID_OV8865, 10);
|
||||
s->front.transform = (mat3){{
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
}};
|
||||
}
|
||||
|
||||
void camera_autoexposure(CameraState *s, float grey_frac) {}
|
||||
|
||||
void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear,
|
||||
VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats,
|
||||
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);
|
||||
|
||||
// LOG("*** open rear ***");
|
||||
camera_open(&s->rear, camera_bufs_rear, true);
|
||||
}
|
||||
|
||||
void cameras_close(DualCameraState *s) {
|
||||
camera_close(&s->rear);
|
||||
}
|
||||
|
||||
void cameras_run(DualCameraState *s) {
|
||||
set_thread_name("frame_streaming");
|
||||
run_frame_stream(s);
|
||||
cameras_close(s);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef CAMERA_FRAME_STREAM_H
|
||||
#define CAMERA_FRAME_STREAM_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#include "common/mat.h"
|
||||
|
||||
#include "buffering.h"
|
||||
#include "common/visionbuf.h"
|
||||
#include "camera_common.h"
|
||||
|
||||
#define FRAME_BUF_COUNT 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CameraState {
|
||||
int camera_id;
|
||||
CameraInfo ci;
|
||||
int frame_size;
|
||||
|
||||
VisionBuf *camera_bufs;
|
||||
FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT];
|
||||
TBuffer camera_tb;
|
||||
|
||||
int fps;
|
||||
float digital_gain;
|
||||
|
||||
float cur_gain_frac;
|
||||
|
||||
mat3 transform;
|
||||
} CameraState;
|
||||
|
||||
|
||||
typedef struct DualCameraState {
|
||||
int ispif_fd;
|
||||
|
||||
CameraState rear;
|
||||
CameraState front;
|
||||
} DualCameraState;
|
||||
|
||||
void cameras_init(DualCameraState *s);
|
||||
void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front);
|
||||
void cameras_run(DualCameraState *s);
|
||||
void cameras_close(DualCameraState *s);
|
||||
void camera_autoexposure(CameraState *s, float grey_frac);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,131 @@
|
|||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "msmb_isp.h"
|
||||
#include "msmb_ispif.h"
|
||||
#include "msmb_camera.h"
|
||||
#include "msm_cam_sensor.h"
|
||||
|
||||
#include "common/mat.h"
|
||||
#include "common/visionbuf.h"
|
||||
#include "common/buffering.h"
|
||||
|
||||
#include "camera_common.h"
|
||||
|
||||
#define FRAME_BUF_COUNT 4
|
||||
#define METADATA_BUF_COUNT 4
|
||||
|
||||
#define DEVICE_OP3 0
|
||||
#define DEVICE_OP3T 1
|
||||
#define DEVICE_LP3 2
|
||||
|
||||
#define NUM_FOCUS 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CameraState CameraState;
|
||||
|
||||
typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, int frame_length);
|
||||
|
||||
typedef struct StreamState {
|
||||
struct msm_isp_buf_request buf_request;
|
||||
struct msm_vfe_axi_stream_request_cmd stream_req;
|
||||
struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT];
|
||||
VisionBuf *bufs;
|
||||
} StreamState;
|
||||
|
||||
typedef struct CameraState {
|
||||
int camera_num;
|
||||
int camera_id;
|
||||
CameraInfo ci;
|
||||
int frame_size;
|
||||
|
||||
int device;
|
||||
|
||||
void* ops_sock;
|
||||
|
||||
uint32_t pixel_clock;
|
||||
uint32_t line_length_pclk;
|
||||
unsigned int max_gain;
|
||||
|
||||
int csid_fd;
|
||||
int csiphy_fd;
|
||||
int sensor_fd;
|
||||
int isp_fd;
|
||||
int eeprom_fd;
|
||||
// rear only
|
||||
int ois_fd, actuator_fd;
|
||||
uint16_t infinity_dac;
|
||||
|
||||
struct msm_vfe_axi_stream_cfg_cmd stream_cfg;
|
||||
|
||||
size_t eeprom_size;
|
||||
uint8_t *eeprom;
|
||||
|
||||
// uint32_t camera_bufs_ids[FRAME_BUF_COUNT];
|
||||
FrameMetadata camera_bufs_metadata[FRAME_BUF_COUNT];
|
||||
TBuffer camera_tb;
|
||||
|
||||
pthread_mutex_t frame_info_lock;
|
||||
FrameMetadata frame_metadata[METADATA_BUF_COUNT];
|
||||
int frame_metadata_idx;
|
||||
float cur_exposure_frac;
|
||||
float cur_gain_frac;
|
||||
int cur_gain;
|
||||
int cur_frame_length;
|
||||
int cur_integ_lines;
|
||||
|
||||
float digital_gain;
|
||||
|
||||
StreamState ss[3];
|
||||
|
||||
uint64_t last_t;
|
||||
|
||||
camera_apply_exposure_func apply_exposure;
|
||||
|
||||
int16_t focus[NUM_FOCUS];
|
||||
uint8_t confidence[NUM_FOCUS];
|
||||
|
||||
float focus_err;
|
||||
|
||||
uint16_t cur_step_pos;
|
||||
uint16_t cur_lens_pos;
|
||||
uint64_t last_sag_ts;
|
||||
float last_sag_acc_z;
|
||||
float lens_true_pos;
|
||||
|
||||
int fps;
|
||||
|
||||
mat3 transform;
|
||||
} CameraState;
|
||||
|
||||
|
||||
typedef struct DualCameraState {
|
||||
int device;
|
||||
|
||||
int ispif_fd;
|
||||
|
||||
CameraState rear;
|
||||
CameraState front;
|
||||
} DualCameraState;
|
||||
|
||||
void cameras_init(DualCameraState *s);
|
||||
void cameras_open(DualCameraState *s, VisionBuf *camera_bufs_rear, VisionBuf *camera_bufs_focus, VisionBuf *camera_bufs_stats, VisionBuf *camera_bufs_front);
|
||||
void cameras_run(DualCameraState *s);
|
||||
void cameras_close(DualCameraState *s);
|
||||
|
||||
void camera_autoexposure(CameraState *s, float grey_frac);
|
||||
void actuator_move(CameraState *s, uint16_t target);
|
||||
int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,130 @@
|
|||
const __constant float3 color_correction[3] = {
|
||||
// Matrix from WBraw -> sRGBD65 (normalized)
|
||||
(float3)( 1.62393627, -0.2092988, 0.00119886),
|
||||
(float3)(-0.45734315, 1.5534676, -0.59296798),
|
||||
(float3)(-0.16659312, -0.3441688, 1.59176912),
|
||||
};
|
||||
|
||||
float3 color_correct(float3 x) {
|
||||
float3 ret = (0,0,0);
|
||||
|
||||
// white balance of daylight
|
||||
x /= (float3)(0.4609375, 1.0, 0.546875);
|
||||
x = max(0.0, min(1.0, x));
|
||||
|
||||
// fix up the colors
|
||||
ret += x.x * color_correction[0];
|
||||
ret += x.y * color_correction[1];
|
||||
ret += x.z * color_correction[2];
|
||||
return ret;
|
||||
}
|
||||
|
||||
float3 srgb_gamma(float3 p) {
|
||||
// go all out and add an sRGB gamma curve
|
||||
const float3 ph = (1.0f + 0.055f)*pow(p, 1/2.4f) - 0.055f;
|
||||
const float3 pl = p*12.92f;
|
||||
return select(ph, pl, islessequal(p, 0.0031308f));
|
||||
}
|
||||
|
||||
__constant int dpcm_lookup[512] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, 935, 951, 967, 983, 999, 1015, 1031, 1047, 1063, 1079, 1095, 1111, 1127, 1143, 1159, 1175, 1191, 1207, 1223, 1239, 1255, 1271, 1287, 1303, 1319, 1335, 1351, 1367, 1383, 1399, 1415, 1431, -935, -951, -967, -983, -999, -1015, -1031, -1047, -1063, -1079, -1095, -1111, -1127, -1143, -1159, -1175, -1191, -1207, -1223, -1239, -1255, -1271, -1287, -1303, -1319, -1335, -1351, -1367, -1383, -1399, -1415, -1431, 419, 427, 435, 443, 451, 459, 467, 475, 483, 491, 499, 507, 515, 523, 531, 539, 547, 555, 563, 571, 579, 587, 595, 603, 611, 619, 627, 635, 643, 651, 659, 667, 675, 683, 691, 699, 707, 715, 723, 731, 739, 747, 755, 763, 771, 779, 787, 795, 803, 811, 819, 827, 835, 843, 851, 859, 867, 875, 883, 891, 899, 907, 915, 923, -419, -427, -435, -443, -451, -459, -467, -475, -483, -491, -499, -507, -515, -523, -531, -539, -547, -555, -563, -571, -579, -587, -595, -603, -611, -619, -627, -635, -643, -651, -659, -667, -675, -683, -691, -699, -707, -715, -723, -731, -739, -747, -755, -763, -771, -779, -787, -795, -803, -811, -819, -827, -835, -843, -851, -859, -867, -875, -883, -891, -899, -907, -915, -923, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, -161, -165, -169, -173, -177, -181, -185, -189, -193, -197, -201, -205, -209, -213, -217, -221, -225, -229, -233, -237, -241, -245, -249, -253, -257, -261, -265, -269, -273, -277, -281, -285, -289, -293, -297, -301, -305, -309, -313, -317, -321, -325, -329, -333, -337, -341, -345, -349, -353, -357, -361, -365, -369, -373, -377, -381, -385, -389, -393, -397, -401, -405, -409, -413, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, -32, -34, -36, -38, -40, -42, -44, -46, -48, -50, -52, -54, -56, -58, -60, -62, -64, -66, -68, -70, -72, -74, -76, -78, -80, -82, -84, -86, -88, -90, -92, -94, -96, -98, -100, -102, -104, -106, -108, -110, -112, -114, -116, -118, -120, -122, -124, -126, -128, -130, -132, -134, -136, -138, -140, -142, -144, -146, -148, -150, -152, -154, -156, -158};
|
||||
|
||||
inline uint4 decompress(uint4 p, uint4 pl) {
|
||||
uint4 r1 = (pl + (uint4)(dpcm_lookup[p.s0], dpcm_lookup[p.s1], dpcm_lookup[p.s2], dpcm_lookup[p.s3]));
|
||||
uint4 r2 = ((p-0x200)<<5) | 0xF;
|
||||
r2 += select((uint4)(0,0,0,0), (uint4)(1,1,1,1), r2 <= pl);
|
||||
return select(r2, r1, p < 0x200);
|
||||
}
|
||||
|
||||
__kernel void debayer10(__global uchar const * const in,
|
||||
__global uchar * out, float digital_gain)
|
||||
{
|
||||
const int oy = get_global_id(0);
|
||||
if (oy >= RGB_HEIGHT) return;
|
||||
const int iy = oy * 2;
|
||||
|
||||
uint4 pint_last;
|
||||
for (int ox = 0; ox < RGB_WIDTH; ox += 2) {
|
||||
const int ix = (ox/2) * 5;
|
||||
|
||||
// TODO: why doesn't this work for the frontview
|
||||
/*const uchar8 v1 = vload8(0, &in[iy * FRAME_STRIDE + ix]);
|
||||
const uchar ex1 = v1.s4;
|
||||
const uchar8 v2 = vload8(0, &in[(iy+1) * FRAME_STRIDE + ix]);
|
||||
const uchar ex2 = v2.s4;*/
|
||||
|
||||
const uchar4 v1 = vload4(0, &in[iy * FRAME_STRIDE + ix]);
|
||||
const uchar ex1 = in[iy * FRAME_STRIDE + ix + 4];
|
||||
const uchar4 v2 = vload4(0, &in[(iy+1) * FRAME_STRIDE + ix]);
|
||||
const uchar ex2 = in[(iy+1) * FRAME_STRIDE + ix + 4];
|
||||
|
||||
uint4 pinta[2];
|
||||
pinta[0] = (uint4)(
|
||||
(((uint)v1.s0 << 2) + ( (ex1 >> 0) & 3)),
|
||||
(((uint)v1.s1 << 2) + ( (ex1 >> 2) & 3)),
|
||||
(((uint)v2.s0 << 2) + ( (ex2 >> 0) & 3)),
|
||||
(((uint)v2.s1 << 2) + ( (ex2 >> 2) & 3)));
|
||||
pinta[1] = (uint4)(
|
||||
(((uint)v1.s2 << 2) + ( (ex1 >> 4) & 3)),
|
||||
(((uint)v1.s3 << 2) + ( (ex1 >> 6) & 3)),
|
||||
(((uint)v2.s2 << 2) + ( (ex2 >> 4) & 3)),
|
||||
(((uint)v2.s3 << 2) + ( (ex2 >> 6) & 3)));
|
||||
|
||||
#pragma unroll
|
||||
for (uint px = 0; px < 2; px++) {
|
||||
uint4 pint = pinta[px];
|
||||
|
||||
#if HDR
|
||||
// decompress HDR
|
||||
pint = (ox == 0 && px == 0) ? ((pint<<4) | 8) : decompress(pint, pint_last);
|
||||
pint_last = pint;
|
||||
#endif
|
||||
|
||||
float4 p = convert_float4(pint);
|
||||
|
||||
// 64 is the black level of the sensor, remove
|
||||
// (changed to 56 for HDR)
|
||||
const float black_level = 56.0f;
|
||||
p = (p - black_level);
|
||||
|
||||
// correct vignetting (no pow function?)
|
||||
// see https://www.eecis.udel.edu/~jye/lab_research/09/JiUp.pdf the A (4th order)
|
||||
const float r = ((oy - RGB_HEIGHT/2)*(oy - RGB_HEIGHT/2) + (ox - RGB_WIDTH/2)*(ox - RGB_WIDTH/2));
|
||||
const float fake_f = 700.0f; // should be 910, but this fits...
|
||||
const float lil_a = (1.0f + r/(fake_f*fake_f));
|
||||
p = p * lil_a * lil_a;
|
||||
|
||||
// rescale to 1.0
|
||||
#if HDR
|
||||
p /= (16384.0f-black_level);
|
||||
#else
|
||||
p /= (1024.0f-black_level);
|
||||
#endif
|
||||
|
||||
// digital gain
|
||||
p *= digital_gain;
|
||||
|
||||
// use both green channels
|
||||
#if BAYER_FLIP == 3
|
||||
float3 c1 = (float3)(p.s3, (p.s1+p.s2)/2.0f, p.s0);
|
||||
#elif BAYER_FLIP == 2
|
||||
float3 c1 = (float3)(p.s2, (p.s0+p.s3)/2.0f, p.s1);
|
||||
#elif BAYER_FLIP == 1
|
||||
float3 c1 = (float3)(p.s1, (p.s0+p.s3)/2.0f, p.s2);
|
||||
#elif BAYER_FLIP == 0
|
||||
float3 c1 = (float3)(p.s0, (p.s1+p.s2)/2.0f, p.s3);
|
||||
#endif
|
||||
|
||||
// color correction
|
||||
c1 = color_correct(c1);
|
||||
|
||||
#if HDR
|
||||
// srgb gamma isn't right for YUV, so it's disabled for now
|
||||
c1 = srgb_gamma(c1);
|
||||
#endif
|
||||
|
||||
// output BGR
|
||||
const int ooff = oy * RGB_STRIDE/3 + ox;
|
||||
vstore3(convert_uchar3_sat(c1.zyx * 255.0f), ooff+px, out);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,829 @@
|
|||
#ifndef __LINUX_MSM_CAM_SENSOR_H
|
||||
#define __LINUX_MSM_CAM_SENSOR_H
|
||||
|
||||
#ifdef MSM_CAMERA_BIONIC
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
//#include <linux/v4l2-mediabus.h>
|
||||
#include "msm_camsensor_sdk.h"
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/i2c.h>
|
||||
#ifdef CONFIG_COMPAT
|
||||
#include <linux/compat.h>
|
||||
#endif
|
||||
|
||||
#define I2C_SEQ_REG_SETTING_MAX 5
|
||||
|
||||
#define MSM_SENSOR_MCLK_8HZ 8000000
|
||||
#define MSM_SENSOR_MCLK_16HZ 16000000
|
||||
#define MSM_SENSOR_MCLK_24HZ 24000000
|
||||
|
||||
#define MAX_SENSOR_NAME 32
|
||||
#define MAX_ACTUATOR_AF_TOTAL_STEPS 1024
|
||||
|
||||
#define MAX_OIS_MOD_NAME_SIZE 32
|
||||
#define MAX_OIS_NAME_SIZE 32
|
||||
#define MAX_OIS_REG_SETTINGS 800
|
||||
|
||||
#define MOVE_NEAR 0
|
||||
#define MOVE_FAR 1
|
||||
|
||||
#define MSM_ACTUATOR_MOVE_SIGNED_FAR -1
|
||||
#define MSM_ACTUATOR_MOVE_SIGNED_NEAR 1
|
||||
|
||||
#define MAX_ACTUATOR_REGION 5
|
||||
|
||||
#define MAX_EEPROM_NAME 32
|
||||
|
||||
#define MAX_AF_ITERATIONS 3
|
||||
#define MAX_NUMBER_OF_STEPS 47
|
||||
#define MAX_REGULATOR 5
|
||||
|
||||
#define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */
|
||||
#define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4')
|
||||
/* 14 BGBG.. GRGR.. */
|
||||
#define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4')
|
||||
/* 14 GBGB.. RGRG.. */
|
||||
#define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4')
|
||||
/* 14 GRGR.. BGBG.. */
|
||||
#define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4')
|
||||
/* 14 RGRG.. GBGB.. */
|
||||
|
||||
enum flash_type {
|
||||
LED_FLASH = 1,
|
||||
STROBE_FLASH,
|
||||
GPIO_FLASH
|
||||
};
|
||||
|
||||
enum msm_sensor_resolution_t {
|
||||
MSM_SENSOR_RES_FULL,
|
||||
MSM_SENSOR_RES_QTR,
|
||||
MSM_SENSOR_RES_2,
|
||||
MSM_SENSOR_RES_3,
|
||||
MSM_SENSOR_RES_4,
|
||||
MSM_SENSOR_RES_5,
|
||||
MSM_SENSOR_RES_6,
|
||||
MSM_SENSOR_RES_7,
|
||||
MSM_SENSOR_INVALID_RES,
|
||||
};
|
||||
|
||||
enum msm_camera_stream_type_t {
|
||||
MSM_CAMERA_STREAM_PREVIEW,
|
||||
MSM_CAMERA_STREAM_SNAPSHOT,
|
||||
MSM_CAMERA_STREAM_VIDEO,
|
||||
MSM_CAMERA_STREAM_INVALID,
|
||||
};
|
||||
|
||||
enum sensor_sub_module_t {
|
||||
SUB_MODULE_SENSOR,
|
||||
SUB_MODULE_CHROMATIX,
|
||||
SUB_MODULE_ACTUATOR,
|
||||
SUB_MODULE_EEPROM,
|
||||
SUB_MODULE_LED_FLASH,
|
||||
SUB_MODULE_STROBE_FLASH,
|
||||
SUB_MODULE_CSID,
|
||||
SUB_MODULE_CSID_3D,
|
||||
SUB_MODULE_CSIPHY,
|
||||
SUB_MODULE_CSIPHY_3D,
|
||||
SUB_MODULE_OIS,
|
||||
SUB_MODULE_EXT,
|
||||
SUB_MODULE_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
MSM_CAMERA_EFFECT_MODE_OFF,
|
||||
MSM_CAMERA_EFFECT_MODE_MONO,
|
||||
MSM_CAMERA_EFFECT_MODE_NEGATIVE,
|
||||
MSM_CAMERA_EFFECT_MODE_SOLARIZE,
|
||||
MSM_CAMERA_EFFECT_MODE_SEPIA,
|
||||
MSM_CAMERA_EFFECT_MODE_POSTERIZE,
|
||||
MSM_CAMERA_EFFECT_MODE_WHITEBOARD,
|
||||
MSM_CAMERA_EFFECT_MODE_BLACKBOARD,
|
||||
MSM_CAMERA_EFFECT_MODE_AQUA,
|
||||
MSM_CAMERA_EFFECT_MODE_EMBOSS,
|
||||
MSM_CAMERA_EFFECT_MODE_SKETCH,
|
||||
MSM_CAMERA_EFFECT_MODE_NEON,
|
||||
MSM_CAMERA_EFFECT_MODE_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
MSM_CAMERA_WB_MODE_AUTO,
|
||||
MSM_CAMERA_WB_MODE_CUSTOM,
|
||||
MSM_CAMERA_WB_MODE_INCANDESCENT,
|
||||
MSM_CAMERA_WB_MODE_FLUORESCENT,
|
||||
MSM_CAMERA_WB_MODE_WARM_FLUORESCENT,
|
||||
MSM_CAMERA_WB_MODE_DAYLIGHT,
|
||||
MSM_CAMERA_WB_MODE_CLOUDY_DAYLIGHT,
|
||||
MSM_CAMERA_WB_MODE_TWILIGHT,
|
||||
MSM_CAMERA_WB_MODE_SHADE,
|
||||
MSM_CAMERA_WB_MODE_OFF,
|
||||
MSM_CAMERA_WB_MODE_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
MSM_CAMERA_SCENE_MODE_OFF,
|
||||
MSM_CAMERA_SCENE_MODE_AUTO,
|
||||
MSM_CAMERA_SCENE_MODE_LANDSCAPE,
|
||||
MSM_CAMERA_SCENE_MODE_SNOW,
|
||||
MSM_CAMERA_SCENE_MODE_BEACH,
|
||||
MSM_CAMERA_SCENE_MODE_SUNSET,
|
||||
MSM_CAMERA_SCENE_MODE_NIGHT,
|
||||
MSM_CAMERA_SCENE_MODE_PORTRAIT,
|
||||
MSM_CAMERA_SCENE_MODE_BACKLIGHT,
|
||||
MSM_CAMERA_SCENE_MODE_SPORTS,
|
||||
MSM_CAMERA_SCENE_MODE_ANTISHAKE,
|
||||
MSM_CAMERA_SCENE_MODE_FLOWERS,
|
||||
MSM_CAMERA_SCENE_MODE_CANDLELIGHT,
|
||||
MSM_CAMERA_SCENE_MODE_FIREWORKS,
|
||||
MSM_CAMERA_SCENE_MODE_PARTY,
|
||||
MSM_CAMERA_SCENE_MODE_NIGHT_PORTRAIT,
|
||||
MSM_CAMERA_SCENE_MODE_THEATRE,
|
||||
MSM_CAMERA_SCENE_MODE_ACTION,
|
||||
MSM_CAMERA_SCENE_MODE_AR,
|
||||
MSM_CAMERA_SCENE_MODE_FACE_PRIORITY,
|
||||
MSM_CAMERA_SCENE_MODE_BARCODE,
|
||||
MSM_CAMERA_SCENE_MODE_HDR,
|
||||
MSM_CAMERA_SCENE_MODE_MAX
|
||||
};
|
||||
|
||||
enum csid_cfg_type_t {
|
||||
CSID_INIT,
|
||||
CSID_CFG,
|
||||
CSID_TESTMODE_CFG,
|
||||
CSID_RELEASE,
|
||||
};
|
||||
|
||||
enum csiphy_cfg_type_t {
|
||||
CSIPHY_INIT,
|
||||
CSIPHY_CFG,
|
||||
CSIPHY_RELEASE,
|
||||
};
|
||||
|
||||
enum camera_vreg_type {
|
||||
VREG_TYPE_DEFAULT,
|
||||
VREG_TYPE_CUSTOM,
|
||||
};
|
||||
|
||||
enum sensor_af_t {
|
||||
SENSOR_AF_FOCUSSED,
|
||||
SENSOR_AF_NOT_FOCUSSED,
|
||||
};
|
||||
|
||||
enum cci_i2c_master_t {
|
||||
MASTER_0,
|
||||
MASTER_1,
|
||||
MASTER_MAX,
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_array_write_config {
|
||||
struct msm_camera_i2c_reg_setting conf_array;
|
||||
uint16_t slave_addr;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_read_config {
|
||||
uint16_t slave_addr;
|
||||
uint16_t reg_addr;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
uint16_t data;
|
||||
};
|
||||
|
||||
struct msm_camera_csi2_params {
|
||||
struct msm_camera_csid_params csid_params;
|
||||
struct msm_camera_csiphy_params csiphy_params;
|
||||
uint8_t csi_clk_scale_enable;
|
||||
};
|
||||
|
||||
struct msm_camera_csi_lane_params {
|
||||
uint16_t csi_lane_assign;
|
||||
uint16_t csi_lane_mask;
|
||||
};
|
||||
|
||||
struct csi_lane_params_t {
|
||||
uint16_t csi_lane_assign;
|
||||
uint8_t csi_lane_mask;
|
||||
uint8_t csi_if;
|
||||
int8_t csid_core[2];
|
||||
uint8_t csi_phy_sel;
|
||||
};
|
||||
|
||||
struct msm_sensor_info_t {
|
||||
char sensor_name[MAX_SENSOR_NAME];
|
||||
uint32_t session_id;
|
||||
int32_t subdev_id[SUB_MODULE_MAX];
|
||||
int32_t subdev_intf[SUB_MODULE_MAX];
|
||||
uint8_t is_mount_angle_valid;
|
||||
uint32_t sensor_mount_angle;
|
||||
int modes_supported;
|
||||
enum camb_position_t position;
|
||||
};
|
||||
|
||||
struct camera_vreg_t {
|
||||
const char *reg_name;
|
||||
int min_voltage;
|
||||
int max_voltage;
|
||||
int op_mode;
|
||||
uint32_t delay;
|
||||
const char *custom_vreg_name;
|
||||
enum camera_vreg_type type;
|
||||
};
|
||||
|
||||
struct sensorb_cfg_data {
|
||||
int cfgtype;
|
||||
union {
|
||||
struct msm_sensor_info_t sensor_info;
|
||||
struct msm_sensor_init_params sensor_init_params;
|
||||
void *setting;
|
||||
struct msm_sensor_i2c_sync_params sensor_i2c_sync_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct csid_cfg_data {
|
||||
enum csid_cfg_type_t cfgtype;
|
||||
union {
|
||||
uint32_t csid_version;
|
||||
struct msm_camera_csid_params *csid_params;
|
||||
struct msm_camera_csid_testmode_parms *csid_testmode_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct csiphy_cfg_data {
|
||||
enum csiphy_cfg_type_t cfgtype;
|
||||
union {
|
||||
struct msm_camera_csiphy_params *csiphy_params;
|
||||
struct msm_camera_csi_lane_params *csi_lane_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
enum eeprom_cfg_type_t {
|
||||
CFG_EEPROM_GET_INFO,
|
||||
CFG_EEPROM_GET_CAL_DATA,
|
||||
CFG_EEPROM_READ_CAL_DATA,
|
||||
CFG_EEPROM_WRITE_DATA,
|
||||
CFG_EEPROM_GET_MM_INFO,
|
||||
CFG_EEPROM_INIT,
|
||||
};
|
||||
|
||||
struct eeprom_get_t {
|
||||
uint32_t num_bytes;
|
||||
};
|
||||
|
||||
struct eeprom_read_t {
|
||||
uint8_t *dbuffer;
|
||||
uint32_t num_bytes;
|
||||
};
|
||||
|
||||
struct eeprom_write_t {
|
||||
uint8_t *dbuffer;
|
||||
uint32_t num_bytes;
|
||||
};
|
||||
|
||||
struct eeprom_get_cmm_t {
|
||||
uint32_t cmm_support;
|
||||
uint32_t cmm_compression;
|
||||
uint32_t cmm_size;
|
||||
};
|
||||
|
||||
struct msm_eeprom_info_t {
|
||||
struct msm_sensor_power_setting_array *power_setting_array;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
struct msm_eeprom_memory_map_array *mem_map_array;
|
||||
};
|
||||
|
||||
struct msm_eeprom_cfg_data {
|
||||
enum eeprom_cfg_type_t cfgtype;
|
||||
uint8_t is_supported;
|
||||
union {
|
||||
char eeprom_name[MAX_SENSOR_NAME];
|
||||
struct eeprom_get_t get_data;
|
||||
struct eeprom_read_t read_data;
|
||||
struct eeprom_write_t write_data;
|
||||
struct eeprom_get_cmm_t get_cmm_data;
|
||||
struct msm_eeprom_info_t eeprom_info;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
struct msm_sensor_power_setting32 {
|
||||
enum msm_sensor_power_seq_type_t seq_type;
|
||||
uint16_t seq_val;
|
||||
compat_uint_t config_val;
|
||||
uint16_t delay;
|
||||
compat_uptr_t data[10];
|
||||
};
|
||||
|
||||
struct msm_sensor_power_setting_array32 {
|
||||
struct msm_sensor_power_setting32 power_setting_a[MAX_POWER_CONFIG];
|
||||
compat_uptr_t power_setting;
|
||||
uint16_t size;
|
||||
struct msm_sensor_power_setting32
|
||||
power_down_setting_a[MAX_POWER_CONFIG];
|
||||
compat_uptr_t power_down_setting;
|
||||
uint16_t size_down;
|
||||
};
|
||||
|
||||
struct msm_camera_sensor_slave_info32 {
|
||||
char sensor_name[32];
|
||||
char eeprom_name[32];
|
||||
char actuator_name[32];
|
||||
char ois_name[32];
|
||||
char flash_name[32];
|
||||
enum msm_sensor_camera_id_t camera_id;
|
||||
uint16_t slave_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
struct msm_sensor_id_info_t sensor_id_info;
|
||||
struct msm_sensor_power_setting_array32 power_setting_array;
|
||||
uint8_t is_init_params_valid;
|
||||
struct msm_sensor_init_params sensor_init_params;
|
||||
enum msm_sensor_output_format_t output_format;
|
||||
};
|
||||
|
||||
struct msm_camera_csid_lut_params32 {
|
||||
uint8_t num_cid;
|
||||
struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID];
|
||||
compat_uptr_t vc_cfg[MAX_CID];
|
||||
};
|
||||
|
||||
struct msm_camera_csid_params32 {
|
||||
uint8_t lane_cnt;
|
||||
uint16_t lane_assign;
|
||||
uint8_t phy_sel;
|
||||
uint32_t csi_clk;
|
||||
struct msm_camera_csid_lut_params32 lut_params;
|
||||
uint8_t csi_3p_sel;
|
||||
};
|
||||
|
||||
struct msm_camera_csi2_params32 {
|
||||
struct msm_camera_csid_params32 csid_params;
|
||||
struct msm_camera_csiphy_params csiphy_params;
|
||||
uint8_t csi_clk_scale_enable;
|
||||
};
|
||||
|
||||
struct csid_cfg_data32 {
|
||||
enum csid_cfg_type_t cfgtype;
|
||||
union {
|
||||
uint32_t csid_version;
|
||||
compat_uptr_t csid_params;
|
||||
compat_uptr_t csid_testmode_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct eeprom_read_t32 {
|
||||
compat_uptr_t dbuffer;
|
||||
uint32_t num_bytes;
|
||||
};
|
||||
|
||||
struct eeprom_write_t32 {
|
||||
compat_uptr_t dbuffer;
|
||||
uint32_t num_bytes;
|
||||
};
|
||||
|
||||
struct msm_eeprom_info_t32 {
|
||||
compat_uptr_t power_setting_array;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
compat_uptr_t mem_map_array;
|
||||
};
|
||||
|
||||
struct msm_eeprom_cfg_data32 {
|
||||
enum eeprom_cfg_type_t cfgtype;
|
||||
uint8_t is_supported;
|
||||
union {
|
||||
char eeprom_name[MAX_SENSOR_NAME];
|
||||
struct eeprom_get_t get_data;
|
||||
struct eeprom_read_t32 read_data;
|
||||
struct eeprom_write_t32 write_data;
|
||||
struct msm_eeprom_info_t32 eeprom_info;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_seq_reg_setting32 {
|
||||
compat_uptr_t reg_setting;
|
||||
uint16_t size;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
uint16_t delay;
|
||||
};
|
||||
#endif
|
||||
|
||||
enum msm_sensor_cfg_type_t {
|
||||
CFG_SET_SLAVE_INFO,
|
||||
CFG_SLAVE_READ_I2C,
|
||||
CFG_WRITE_I2C_ARRAY,
|
||||
CFG_SLAVE_WRITE_I2C_ARRAY,
|
||||
CFG_WRITE_I2C_SEQ_ARRAY,
|
||||
CFG_POWER_UP,
|
||||
CFG_POWER_DOWN,
|
||||
CFG_SET_STOP_STREAM_SETTING,
|
||||
CFG_GET_SENSOR_INFO,
|
||||
CFG_GET_SENSOR_INIT_PARAMS,
|
||||
CFG_SET_INIT_SETTING,
|
||||
CFG_SET_RESOLUTION,
|
||||
CFG_SET_STOP_STREAM,
|
||||
CFG_SET_START_STREAM,
|
||||
CFG_SET_SATURATION,
|
||||
CFG_SET_CONTRAST,
|
||||
CFG_SET_SHARPNESS,
|
||||
CFG_SET_ISO,
|
||||
CFG_SET_EXPOSURE_COMPENSATION,
|
||||
CFG_SET_ANTIBANDING,
|
||||
CFG_SET_BESTSHOT_MODE,
|
||||
CFG_SET_EFFECT,
|
||||
CFG_SET_WHITE_BALANCE,
|
||||
CFG_SET_AUTOFOCUS,
|
||||
CFG_CANCEL_AUTOFOCUS,
|
||||
CFG_SET_STREAM_TYPE,
|
||||
CFG_SET_I2C_SYNC_PARAM,
|
||||
CFG_WRITE_I2C_ARRAY_ASYNC,
|
||||
CFG_WRITE_I2C_ARRAY_SYNC,
|
||||
CFG_WRITE_I2C_ARRAY_SYNC_BLOCK,
|
||||
};
|
||||
|
||||
enum msm_actuator_cfg_type_t {
|
||||
CFG_GET_ACTUATOR_INFO,
|
||||
CFG_SET_ACTUATOR_INFO,
|
||||
CFG_SET_DEFAULT_FOCUS,
|
||||
CFG_MOVE_FOCUS,
|
||||
CFG_SET_POSITION,
|
||||
CFG_ACTUATOR_POWERDOWN,
|
||||
CFG_ACTUATOR_POWERUP,
|
||||
CFG_ACTUATOR_INIT,
|
||||
};
|
||||
|
||||
enum msm_ois_cfg_type_t {
|
||||
CFG_OIS_INIT,
|
||||
CFG_OIS_POWERDOWN,
|
||||
CFG_OIS_POWERUP,
|
||||
CFG_OIS_CONTROL,
|
||||
CFG_OIS_I2C_WRITE_SEQ_TABLE,
|
||||
};
|
||||
|
||||
enum msm_ois_i2c_operation {
|
||||
MSM_OIS_WRITE = 0,
|
||||
MSM_OIS_POLL,
|
||||
};
|
||||
|
||||
struct reg_settings_ois_t {
|
||||
uint16_t reg_addr;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
uint32_t reg_data;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
enum msm_ois_i2c_operation i2c_operation;
|
||||
uint32_t delay;
|
||||
#define OIS_REG_DATA_SEQ_MAX 128
|
||||
unsigned char reg_data_seq[OIS_REG_DATA_SEQ_MAX];
|
||||
uint32_t reg_data_seq_size;
|
||||
};
|
||||
|
||||
struct msm_ois_params_t {
|
||||
uint16_t data_size;
|
||||
uint16_t setting_size;
|
||||
uint32_t i2c_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_camera_i2c_reg_addr_type i2c_addr_type;
|
||||
enum msm_camera_i2c_data_type i2c_data_type;
|
||||
struct reg_settings_ois_t *settings;
|
||||
};
|
||||
|
||||
struct msm_ois_set_info_t {
|
||||
struct msm_ois_params_t ois_params;
|
||||
};
|
||||
|
||||
struct msm_actuator_move_params_t {
|
||||
int8_t dir;
|
||||
int8_t sign_dir;
|
||||
int16_t dest_step_pos;
|
||||
int32_t num_steps;
|
||||
uint16_t curr_lens_pos;
|
||||
struct damping_params_t *ringing_params;
|
||||
};
|
||||
|
||||
struct msm_actuator_tuning_params_t {
|
||||
int16_t initial_code;
|
||||
uint16_t pwd_step;
|
||||
uint16_t region_size;
|
||||
uint32_t total_steps;
|
||||
struct region_params_t *region_params;
|
||||
};
|
||||
|
||||
struct park_lens_data_t {
|
||||
uint32_t damping_step;
|
||||
uint32_t damping_delay;
|
||||
uint32_t hw_params;
|
||||
uint32_t max_step;
|
||||
};
|
||||
|
||||
struct msm_actuator_params_t {
|
||||
enum actuator_type act_type;
|
||||
uint8_t reg_tbl_size;
|
||||
uint16_t data_size;
|
||||
uint16_t init_setting_size;
|
||||
uint32_t i2c_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_actuator_addr_type i2c_addr_type;
|
||||
enum msm_actuator_data_type i2c_data_type;
|
||||
struct msm_actuator_reg_params_t *reg_tbl_params;
|
||||
struct reg_settings_t *init_settings;
|
||||
struct park_lens_data_t park_lens;
|
||||
};
|
||||
|
||||
struct msm_actuator_set_info_t {
|
||||
struct msm_actuator_params_t actuator_params;
|
||||
struct msm_actuator_tuning_params_t af_tuning_params;
|
||||
};
|
||||
|
||||
struct msm_actuator_get_info_t {
|
||||
uint32_t focal_length_num;
|
||||
uint32_t focal_length_den;
|
||||
uint32_t f_number_num;
|
||||
uint32_t f_number_den;
|
||||
uint32_t f_pix_num;
|
||||
uint32_t f_pix_den;
|
||||
uint32_t total_f_dist_num;
|
||||
uint32_t total_f_dist_den;
|
||||
uint32_t hor_view_angle_num;
|
||||
uint32_t hor_view_angle_den;
|
||||
uint32_t ver_view_angle_num;
|
||||
uint32_t ver_view_angle_den;
|
||||
};
|
||||
|
||||
enum af_camera_name {
|
||||
ACTUATOR_MAIN_CAM_0,
|
||||
ACTUATOR_MAIN_CAM_1,
|
||||
ACTUATOR_MAIN_CAM_2,
|
||||
ACTUATOR_MAIN_CAM_3,
|
||||
ACTUATOR_MAIN_CAM_4,
|
||||
ACTUATOR_MAIN_CAM_5,
|
||||
ACTUATOR_WEB_CAM_0,
|
||||
ACTUATOR_WEB_CAM_1,
|
||||
ACTUATOR_WEB_CAM_2,
|
||||
};
|
||||
|
||||
struct msm_ois_cfg_data {
|
||||
int cfgtype;
|
||||
union {
|
||||
struct msm_ois_set_info_t set_info;
|
||||
struct msm_camera_i2c_seq_reg_setting *settings;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct msm_actuator_set_position_t {
|
||||
uint16_t number_of_steps;
|
||||
uint32_t hw_params;
|
||||
uint16_t pos[MAX_NUMBER_OF_STEPS];
|
||||
uint16_t delay[MAX_NUMBER_OF_STEPS];
|
||||
};
|
||||
|
||||
struct msm_actuator_cfg_data {
|
||||
int cfgtype;
|
||||
uint8_t is_af_supported;
|
||||
union {
|
||||
struct msm_actuator_move_params_t move;
|
||||
struct msm_actuator_set_info_t set_info;
|
||||
struct msm_actuator_get_info_t get_info;
|
||||
struct msm_actuator_set_position_t setpos;
|
||||
enum af_camera_name cam_name;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
enum msm_camera_led_config_t {
|
||||
MSM_CAMERA_LED_OFF,
|
||||
MSM_CAMERA_LED_LOW,
|
||||
MSM_CAMERA_LED_HIGH,
|
||||
MSM_CAMERA_LED_INIT,
|
||||
MSM_CAMERA_LED_RELEASE,
|
||||
};
|
||||
|
||||
struct msm_camera_led_cfg_t {
|
||||
enum msm_camera_led_config_t cfgtype;
|
||||
int32_t torch_current[MAX_LED_TRIGGERS];
|
||||
int32_t flash_current[MAX_LED_TRIGGERS];
|
||||
int32_t flash_duration[MAX_LED_TRIGGERS];
|
||||
};
|
||||
|
||||
struct msm_flash_init_info_t {
|
||||
enum msm_flash_driver_type flash_driver_type;
|
||||
uint32_t slave_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
struct msm_sensor_power_setting_array *power_setting_array;
|
||||
struct msm_camera_i2c_reg_setting_array *settings;
|
||||
};
|
||||
|
||||
struct msm_flash_cfg_data_t {
|
||||
enum msm_flash_cfg_type_t cfg_type;
|
||||
int32_t flash_current[MAX_LED_TRIGGERS];
|
||||
int32_t flash_duration[MAX_LED_TRIGGERS];
|
||||
union {
|
||||
struct msm_flash_init_info_t *flash_init_info;
|
||||
struct msm_camera_i2c_reg_setting_array *settings;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
/* sensor init structures and enums */
|
||||
enum msm_sensor_init_cfg_type_t {
|
||||
CFG_SINIT_PROBE,
|
||||
CFG_SINIT_PROBE_DONE,
|
||||
CFG_SINIT_PROBE_WAIT_DONE,
|
||||
};
|
||||
|
||||
struct sensor_init_cfg_data {
|
||||
enum msm_sensor_init_cfg_type_t cfgtype;
|
||||
struct msm_sensor_info_t probed_info;
|
||||
char entity_name[MAX_SENSOR_NAME];
|
||||
union {
|
||||
void *setting;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_RELEASE \
|
||||
_IO('V', BASE_VIDIOC_PRIVATE + 2)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t)
|
||||
|
||||
#define VIDIOC_MSM_CSIPHY_IO_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_CSID_IO_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_ACTUATOR_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_FLASH_LED_DATA_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t)
|
||||
|
||||
#define VIDIOC_MSM_EEPROM_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_GET_AF_STATUS \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 9, uint32_t)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_INIT_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_OIS_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data)
|
||||
|
||||
#define VIDIOC_MSM_FLASH_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t)
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
struct msm_camera_i2c_reg_setting32 {
|
||||
compat_uptr_t reg_setting;
|
||||
uint16_t size;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
uint16_t delay;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_array_write_config32 {
|
||||
struct msm_camera_i2c_reg_setting32 conf_array;
|
||||
uint16_t slave_addr;
|
||||
};
|
||||
|
||||
struct msm_actuator_tuning_params_t32 {
|
||||
int16_t initial_code;
|
||||
uint16_t pwd_step;
|
||||
uint16_t region_size;
|
||||
uint32_t total_steps;
|
||||
compat_uptr_t region_params;
|
||||
};
|
||||
|
||||
struct msm_actuator_params_t32 {
|
||||
enum actuator_type act_type;
|
||||
uint8_t reg_tbl_size;
|
||||
uint16_t data_size;
|
||||
uint16_t init_setting_size;
|
||||
uint32_t i2c_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_actuator_addr_type i2c_addr_type;
|
||||
enum msm_actuator_data_type i2c_data_type;
|
||||
compat_uptr_t reg_tbl_params;
|
||||
compat_uptr_t init_settings;
|
||||
struct park_lens_data_t park_lens;
|
||||
};
|
||||
|
||||
struct msm_actuator_set_info_t32 {
|
||||
struct msm_actuator_params_t32 actuator_params;
|
||||
struct msm_actuator_tuning_params_t32 af_tuning_params;
|
||||
};
|
||||
|
||||
struct sensor_init_cfg_data32 {
|
||||
enum msm_sensor_init_cfg_type_t cfgtype;
|
||||
struct msm_sensor_info_t probed_info;
|
||||
char entity_name[MAX_SENSOR_NAME];
|
||||
union {
|
||||
compat_uptr_t setting;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct msm_actuator_move_params_t32 {
|
||||
int8_t dir;
|
||||
int8_t sign_dir;
|
||||
int16_t dest_step_pos;
|
||||
int32_t num_steps;
|
||||
uint16_t curr_lens_pos;
|
||||
compat_uptr_t ringing_params;
|
||||
};
|
||||
|
||||
struct msm_actuator_cfg_data32 {
|
||||
int cfgtype;
|
||||
uint8_t is_af_supported;
|
||||
union {
|
||||
struct msm_actuator_move_params_t32 move;
|
||||
struct msm_actuator_set_info_t32 set_info;
|
||||
struct msm_actuator_get_info_t get_info;
|
||||
struct msm_actuator_set_position_t setpos;
|
||||
enum af_camera_name cam_name;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct csiphy_cfg_data32 {
|
||||
enum csiphy_cfg_type_t cfgtype;
|
||||
union {
|
||||
compat_uptr_t csiphy_params;
|
||||
compat_uptr_t csi_lane_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct sensorb_cfg_data32 {
|
||||
int cfgtype;
|
||||
union {
|
||||
struct msm_sensor_info_t sensor_info;
|
||||
struct msm_sensor_init_params sensor_init_params;
|
||||
compat_uptr_t setting;
|
||||
struct msm_sensor_i2c_sync_params sensor_i2c_sync_params;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct msm_ois_params_t32 {
|
||||
uint16_t data_size;
|
||||
uint16_t setting_size;
|
||||
uint32_t i2c_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_camera_i2c_reg_addr_type i2c_addr_type;
|
||||
enum msm_camera_i2c_data_type i2c_data_type;
|
||||
compat_uptr_t settings;
|
||||
};
|
||||
|
||||
struct msm_ois_set_info_t32 {
|
||||
struct msm_ois_params_t32 ois_params;
|
||||
};
|
||||
|
||||
struct msm_ois_cfg_data32 {
|
||||
int cfgtype;
|
||||
union {
|
||||
struct msm_ois_set_info_t32 set_info;
|
||||
compat_uptr_t settings;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
struct msm_flash_init_info_t32 {
|
||||
enum msm_flash_driver_type flash_driver_type;
|
||||
uint32_t slave_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
compat_uptr_t power_setting_array;
|
||||
compat_uptr_t settings;
|
||||
};
|
||||
|
||||
struct msm_flash_cfg_data_t32 {
|
||||
enum msm_flash_cfg_type_t cfg_type;
|
||||
int32_t flash_current[MAX_LED_TRIGGERS];
|
||||
int32_t flash_duration[MAX_LED_TRIGGERS];
|
||||
union {
|
||||
compat_uptr_t flash_init_info;
|
||||
compat_uptr_t settings;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
#define VIDIOC_MSM_ACTUATOR_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_INIT_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_CSIPHY_IO_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_SENSOR_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_EEPROM_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_OIS_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_CSID_IO_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data32)
|
||||
|
||||
#define VIDIOC_MSM_FLASH_CFG32 \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t32)
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_MSM_CAM_SENSOR_H */
|
|
@ -0,0 +1,386 @@
|
|||
#ifndef __LINUX_MSM_CAMSENSOR_SDK_H
|
||||
#define __LINUX_MSM_CAMSENSOR_SDK_H
|
||||
|
||||
#define KVERSION 0x1
|
||||
|
||||
#define MAX_POWER_CONFIG 12
|
||||
#define GPIO_OUT_LOW (0 << 1)
|
||||
#define GPIO_OUT_HIGH (1 << 1)
|
||||
#define CSI_EMBED_DATA 0x12
|
||||
#define CSI_RESERVED_DATA_0 0x13
|
||||
#define CSI_YUV422_8 0x1E
|
||||
#define CSI_RAW8 0x2A
|
||||
#define CSI_RAW10 0x2B
|
||||
#define CSI_RAW12 0x2C
|
||||
#define CSI_DECODE_6BIT 0
|
||||
#define CSI_DECODE_8BIT 1
|
||||
#define CSI_DECODE_10BIT 2
|
||||
#define CSI_DECODE_12BIT 3
|
||||
#define CSI_DECODE_DPCM_10_8_10 5
|
||||
#define MAX_CID 16
|
||||
#define I2C_SEQ_REG_DATA_MAX 1024
|
||||
#define I2C_REG_DATA_MAX (8*1024)
|
||||
|
||||
#define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */
|
||||
#define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4')
|
||||
/* 14 BGBG.. GRGR.. */
|
||||
#define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4')
|
||||
/* 14 GBGB.. RGRG.. */
|
||||
#define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4')
|
||||
/* 14 GRGR.. BGBG.. */
|
||||
#define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4')
|
||||
/* 14 RGRG.. GBGB.. */
|
||||
|
||||
#define MAX_ACTUATOR_REG_TBL_SIZE 8
|
||||
#define MAX_ACTUATOR_REGION 5
|
||||
#define NUM_ACTUATOR_DIR 2
|
||||
#define MAX_ACTUATOR_SCENARIO 8
|
||||
#define MAX_ACT_MOD_NAME_SIZE 32
|
||||
#define MAX_ACT_NAME_SIZE 32
|
||||
#define MAX_ACTUATOR_INIT_SET 120
|
||||
#define MAX_I2C_REG_SET 12
|
||||
|
||||
#define MAX_LED_TRIGGERS 3
|
||||
|
||||
#define MSM_EEPROM_MEMORY_MAP_MAX_SIZE 80
|
||||
#define MSM_EEPROM_MAX_MEM_MAP_CNT 8
|
||||
|
||||
enum msm_sensor_camera_id_t {
|
||||
CAMERA_0,
|
||||
CAMERA_1,
|
||||
CAMERA_2,
|
||||
CAMERA_3,
|
||||
MAX_CAMERAS,
|
||||
};
|
||||
|
||||
enum i2c_freq_mode_t {
|
||||
I2C_STANDARD_MODE,
|
||||
I2C_FAST_MODE,
|
||||
I2C_CUSTOM_MODE,
|
||||
I2C_FAST_PLUS_MODE,
|
||||
I2C_MAX_MODES,
|
||||
};
|
||||
|
||||
enum camb_position_t {
|
||||
BACK_CAMERA_B,
|
||||
FRONT_CAMERA_B,
|
||||
AUX_CAMERA_B = 0x100,
|
||||
INVALID_CAMERA_B,
|
||||
};
|
||||
|
||||
enum msm_sensor_power_seq_type_t {
|
||||
SENSOR_CLK,
|
||||
SENSOR_GPIO,
|
||||
SENSOR_VREG,
|
||||
SENSOR_I2C_MUX,
|
||||
SENSOR_I2C,
|
||||
};
|
||||
|
||||
enum msm_camera_i2c_reg_addr_type {
|
||||
MSM_CAMERA_I2C_BYTE_ADDR = 1,
|
||||
MSM_CAMERA_I2C_WORD_ADDR,
|
||||
MSM_CAMERA_I2C_3B_ADDR,
|
||||
MSM_CAMERA_I2C_ADDR_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum msm_camera_i2c_data_type {
|
||||
MSM_CAMERA_I2C_BYTE_DATA = 1,
|
||||
MSM_CAMERA_I2C_WORD_DATA,
|
||||
MSM_CAMERA_I2C_DWORD_DATA,
|
||||
MSM_CAMERA_I2C_SET_BYTE_MASK,
|
||||
MSM_CAMERA_I2C_UNSET_BYTE_MASK,
|
||||
MSM_CAMERA_I2C_SET_WORD_MASK,
|
||||
MSM_CAMERA_I2C_UNSET_WORD_MASK,
|
||||
MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA,
|
||||
MSM_CAMERA_I2C_SEQ_DATA,
|
||||
MSM_CAMERA_I2C_DATA_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum msm_sensor_power_seq_gpio_t {
|
||||
SENSOR_GPIO_RESET,
|
||||
SENSOR_GPIO_STANDBY,
|
||||
SENSOR_GPIO_AF_PWDM,
|
||||
SENSOR_GPIO_VIO,
|
||||
SENSOR_GPIO_VANA,
|
||||
SENSOR_GPIO_VDIG,
|
||||
SENSOR_GPIO_VAF,
|
||||
SENSOR_GPIO_FL_EN,
|
||||
SENSOR_GPIO_FL_NOW,
|
||||
SENSOR_GPIO_FL_RESET,
|
||||
SENSOR_GPIO_CUSTOM1,
|
||||
SENSOR_GPIO_CUSTOM2,
|
||||
SENSOR_GPIO_MAX,
|
||||
};
|
||||
|
||||
enum msm_camera_vreg_name_t {
|
||||
CAM_VDIG,
|
||||
CAM_VIO,
|
||||
CAM_VANA,
|
||||
CAM_VAF,
|
||||
CAM_V_CUSTOM1,
|
||||
CAM_V_CUSTOM2,
|
||||
CAM_VREG_MAX,
|
||||
};
|
||||
|
||||
enum msm_sensor_clk_type_t {
|
||||
SENSOR_CAM_MCLK,
|
||||
SENSOR_CAM_CLK,
|
||||
SENSOR_CAM_CLK_MAX,
|
||||
};
|
||||
|
||||
enum camerab_mode_t {
|
||||
CAMERA_MODE_2D_B = (1<<0),
|
||||
CAMERA_MODE_3D_B = (1<<1),
|
||||
CAMERA_MODE_INVALID = (1<<2),
|
||||
};
|
||||
|
||||
enum msm_actuator_data_type {
|
||||
MSM_ACTUATOR_BYTE_DATA = 1,
|
||||
MSM_ACTUATOR_WORD_DATA,
|
||||
};
|
||||
|
||||
enum msm_actuator_addr_type {
|
||||
MSM_ACTUATOR_BYTE_ADDR = 1,
|
||||
MSM_ACTUATOR_WORD_ADDR,
|
||||
};
|
||||
|
||||
enum msm_actuator_write_type {
|
||||
MSM_ACTUATOR_WRITE_HW_DAMP,
|
||||
MSM_ACTUATOR_WRITE_DAC,
|
||||
MSM_ACTUATOR_WRITE,
|
||||
MSM_ACTUATOR_WRITE_DIR_REG,
|
||||
MSM_ACTUATOR_POLL,
|
||||
MSM_ACTUATOR_READ_WRITE,
|
||||
};
|
||||
|
||||
enum msm_actuator_i2c_operation {
|
||||
MSM_ACT_WRITE = 0,
|
||||
MSM_ACT_POLL,
|
||||
};
|
||||
|
||||
enum actuator_type {
|
||||
ACTUATOR_VCM,
|
||||
ACTUATOR_PIEZO,
|
||||
ACTUATOR_HVCM,
|
||||
ACTUATOR_BIVCM,
|
||||
};
|
||||
|
||||
enum msm_flash_driver_type {
|
||||
FLASH_DRIVER_PMIC,
|
||||
FLASH_DRIVER_I2C,
|
||||
FLASH_DRIVER_GPIO,
|
||||
FLASH_DRIVER_DEFAULT
|
||||
};
|
||||
|
||||
enum msm_flash_cfg_type_t {
|
||||
CFG_FLASH_INIT,
|
||||
CFG_FLASH_RELEASE,
|
||||
CFG_FLASH_OFF,
|
||||
CFG_FLASH_LOW,
|
||||
CFG_FLASH_HIGH,
|
||||
};
|
||||
|
||||
enum msm_sensor_output_format_t {
|
||||
MSM_SENSOR_BAYER,
|
||||
MSM_SENSOR_YCBCR,
|
||||
MSM_SENSOR_META,
|
||||
};
|
||||
|
||||
struct msm_sensor_power_setting {
|
||||
enum msm_sensor_power_seq_type_t seq_type;
|
||||
unsigned short seq_val;
|
||||
long config_val;
|
||||
unsigned short delay;
|
||||
void *data[10];
|
||||
};
|
||||
|
||||
struct msm_sensor_power_setting_array {
|
||||
struct msm_sensor_power_setting power_setting_a[MAX_POWER_CONFIG];
|
||||
struct msm_sensor_power_setting *power_setting;
|
||||
unsigned short size;
|
||||
struct msm_sensor_power_setting power_down_setting_a[MAX_POWER_CONFIG];
|
||||
struct msm_sensor_power_setting *power_down_setting;
|
||||
unsigned short size_down;
|
||||
};
|
||||
|
||||
enum msm_camera_i2c_operation {
|
||||
MSM_CAM_WRITE = 0,
|
||||
MSM_CAM_POLL,
|
||||
MSM_CAM_READ,
|
||||
};
|
||||
|
||||
struct msm_sensor_i2c_sync_params {
|
||||
unsigned int cid;
|
||||
int csid;
|
||||
unsigned short line;
|
||||
unsigned short delay;
|
||||
};
|
||||
|
||||
struct msm_camera_reg_settings_t {
|
||||
uint16_t reg_addr;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
uint16_t reg_data;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
enum msm_camera_i2c_operation i2c_operation;
|
||||
uint16_t delay;
|
||||
};
|
||||
|
||||
struct msm_eeprom_mem_map_t {
|
||||
int slave_addr;
|
||||
struct msm_camera_reg_settings_t
|
||||
mem_settings[MSM_EEPROM_MEMORY_MAP_MAX_SIZE];
|
||||
int memory_map_size;
|
||||
};
|
||||
|
||||
struct msm_eeprom_memory_map_array {
|
||||
struct msm_eeprom_mem_map_t memory_map[MSM_EEPROM_MAX_MEM_MAP_CNT];
|
||||
uint32_t msm_size_of_max_mappings;
|
||||
};
|
||||
|
||||
struct msm_sensor_init_params {
|
||||
/* mask of modes supported: 2D, 3D */
|
||||
int modes_supported;
|
||||
/* sensor position: front, back */
|
||||
enum camb_position_t position;
|
||||
/* sensor mount angle */
|
||||
unsigned int sensor_mount_angle;
|
||||
};
|
||||
|
||||
struct msm_sensor_id_info_t {
|
||||
unsigned short sensor_id_reg_addr;
|
||||
unsigned short sensor_id;
|
||||
unsigned short sensor_id_mask;
|
||||
// added in LeEco
|
||||
unsigned char module_id;
|
||||
unsigned char vcm_id;
|
||||
};
|
||||
|
||||
struct msm_camera_sensor_slave_info {
|
||||
char sensor_name[32];
|
||||
char eeprom_name[32];
|
||||
char actuator_name[32];
|
||||
char ois_name[32];
|
||||
char flash_name[32];
|
||||
enum msm_sensor_camera_id_t camera_id;
|
||||
unsigned short slave_addr;
|
||||
enum i2c_freq_mode_t i2c_freq_mode;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
struct msm_sensor_id_info_t sensor_id_info;
|
||||
struct msm_sensor_power_setting_array power_setting_array;
|
||||
unsigned char is_init_params_valid;
|
||||
struct msm_sensor_init_params sensor_init_params;
|
||||
enum msm_sensor_output_format_t output_format;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_reg_array {
|
||||
unsigned short reg_addr;
|
||||
unsigned short reg_data;
|
||||
unsigned int delay;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_reg_setting {
|
||||
struct msm_camera_i2c_reg_array *reg_setting;
|
||||
unsigned short size;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
unsigned short delay;
|
||||
};
|
||||
|
||||
struct msm_camera_csid_vc_cfg {
|
||||
unsigned char cid;
|
||||
unsigned char dt;
|
||||
unsigned char decode_format;
|
||||
};
|
||||
|
||||
struct msm_camera_csid_lut_params {
|
||||
unsigned char num_cid;
|
||||
struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID];
|
||||
struct msm_camera_csid_vc_cfg *vc_cfg[MAX_CID];
|
||||
};
|
||||
|
||||
struct msm_camera_csid_params {
|
||||
unsigned char lane_cnt;
|
||||
unsigned short lane_assign;
|
||||
unsigned char phy_sel;
|
||||
unsigned int csi_clk;
|
||||
struct msm_camera_csid_lut_params lut_params;
|
||||
unsigned char csi_3p_sel;
|
||||
};
|
||||
|
||||
struct msm_camera_csid_testmode_parms {
|
||||
unsigned int num_bytes_per_line;
|
||||
unsigned int num_lines;
|
||||
unsigned int h_blanking_count;
|
||||
unsigned int v_blanking_count;
|
||||
unsigned int payload_mode;
|
||||
};
|
||||
|
||||
struct msm_camera_csiphy_params {
|
||||
unsigned char lane_cnt;
|
||||
unsigned char settle_cnt;
|
||||
unsigned short lane_mask;
|
||||
unsigned char combo_mode;
|
||||
unsigned char csid_core;
|
||||
unsigned int csiphy_clk;
|
||||
unsigned char csi_3phase;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_seq_reg_array {
|
||||
unsigned short reg_addr;
|
||||
unsigned char reg_data[I2C_SEQ_REG_DATA_MAX];
|
||||
unsigned short reg_data_size;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_seq_reg_setting {
|
||||
struct msm_camera_i2c_seq_reg_array *reg_setting;
|
||||
unsigned short size;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
unsigned short delay;
|
||||
};
|
||||
|
||||
struct msm_actuator_reg_params_t {
|
||||
enum msm_actuator_write_type reg_write_type;
|
||||
unsigned int hw_mask;
|
||||
unsigned short reg_addr;
|
||||
unsigned short hw_shift;
|
||||
unsigned short data_shift;
|
||||
unsigned short data_type;
|
||||
unsigned short addr_type;
|
||||
unsigned short reg_data;
|
||||
unsigned short delay;
|
||||
};
|
||||
|
||||
|
||||
struct damping_params_t {
|
||||
unsigned int damping_step;
|
||||
unsigned int damping_delay;
|
||||
unsigned int hw_params;
|
||||
};
|
||||
|
||||
struct region_params_t {
|
||||
/* [0] = ForwardDirection Macro boundary
|
||||
[1] = ReverseDirection Inf boundary
|
||||
*/
|
||||
unsigned short step_bound[2];
|
||||
unsigned short code_per_step;
|
||||
/* qvalue for converting float type numbers to integer format */
|
||||
unsigned int qvalue;
|
||||
};
|
||||
|
||||
struct reg_settings_t {
|
||||
unsigned short reg_addr;
|
||||
enum msm_actuator_addr_type addr_type;
|
||||
unsigned short reg_data;
|
||||
enum msm_actuator_data_type data_type;
|
||||
enum msm_actuator_i2c_operation i2c_operation;
|
||||
unsigned int delay;
|
||||
};
|
||||
|
||||
struct msm_camera_i2c_reg_setting_array {
|
||||
struct msm_camera_i2c_reg_array reg_setting_a[MAX_I2C_REG_SET];
|
||||
unsigned short size;
|
||||
enum msm_camera_i2c_reg_addr_type addr_type;
|
||||
enum msm_camera_i2c_data_type data_type;
|
||||
unsigned short delay;
|
||||
};
|
||||
#endif /* __LINUX_MSM_CAM_SENSOR_H */
|
|
@ -0,0 +1,220 @@
|
|||
#ifndef __LINUX_MSMB_CAMERA_H
|
||||
#define __LINUX_MSMB_CAMERA_H
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#define MSM_CAM_LOGSYNC_FILE_NAME "logsync"
|
||||
#define MSM_CAM_LOGSYNC_FILE_BASEDIR "camera"
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 30, struct msm_v4l2_event_data)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_META \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 31, struct msm_v4l2_event_data)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_CMD_ACK \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 32, struct msm_v4l2_event_data)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 33, struct msm_v4l2_event_data)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data)
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY32 \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 30, struct v4l2_event32)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_META32 \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 31, struct v4l2_event32)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_CMD_ACK32 \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 32, struct v4l2_event32)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR32 \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 33, struct v4l2_event32)
|
||||
|
||||
#define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG32 \
|
||||
_IOW('V', BASE_VIDIOC_PRIVATE + 34, struct v4l2_event32)
|
||||
|
||||
#endif
|
||||
|
||||
#define QCAMERA_DEVICE_GROUP_ID 1
|
||||
#define QCAMERA_VNODE_GROUP_ID 2
|
||||
#define MSM_CAMERA_NAME "msm_camera"
|
||||
#define MSM_CONFIGURATION_NAME "msm_config"
|
||||
|
||||
#define MSM_CAMERA_SUBDEV_CSIPHY 0
|
||||
#define MSM_CAMERA_SUBDEV_CSID 1
|
||||
#define MSM_CAMERA_SUBDEV_ISPIF 2
|
||||
#define MSM_CAMERA_SUBDEV_VFE 3
|
||||
#define MSM_CAMERA_SUBDEV_AXI 4
|
||||
#define MSM_CAMERA_SUBDEV_VPE 5
|
||||
#define MSM_CAMERA_SUBDEV_SENSOR 6
|
||||
#define MSM_CAMERA_SUBDEV_ACTUATOR 7
|
||||
#define MSM_CAMERA_SUBDEV_EEPROM 8
|
||||
#define MSM_CAMERA_SUBDEV_CPP 9
|
||||
#define MSM_CAMERA_SUBDEV_CCI 10
|
||||
#define MSM_CAMERA_SUBDEV_LED_FLASH 11
|
||||
#define MSM_CAMERA_SUBDEV_STROBE_FLASH 12
|
||||
#define MSM_CAMERA_SUBDEV_BUF_MNGR 13
|
||||
#define MSM_CAMERA_SUBDEV_SENSOR_INIT 14
|
||||
#define MSM_CAMERA_SUBDEV_OIS 15
|
||||
#define MSM_CAMERA_SUBDEV_FLASH 16
|
||||
#define MSM_CAMERA_SUBDEV_EXT 17
|
||||
|
||||
#define MSM_MAX_CAMERA_SENSORS 5
|
||||
|
||||
/* The below macro is defined to put an upper limit on maximum
|
||||
* number of buffer requested per stream. In case of extremely
|
||||
* large value for number of buffer due to data structure corruption
|
||||
* we return error to avoid integer overflow. Group processing
|
||||
* can have max of 9 groups of 8 bufs each. This value may be
|
||||
* configured in future*/
|
||||
#define MSM_CAMERA_MAX_STREAM_BUF 72
|
||||
|
||||
/* Max batch size of processing */
|
||||
#define MSM_CAMERA_MAX_USER_BUFF_CNT 16
|
||||
|
||||
/* featur base */
|
||||
#define MSM_CAMERA_FEATURE_BASE 0x00010000
|
||||
#define MSM_CAMERA_FEATURE_SHUTDOWN (MSM_CAMERA_FEATURE_BASE + 1)
|
||||
|
||||
#define MSM_CAMERA_STATUS_BASE 0x00020000
|
||||
#define MSM_CAMERA_STATUS_FAIL (MSM_CAMERA_STATUS_BASE + 1)
|
||||
#define MSM_CAMERA_STATUS_SUCCESS (MSM_CAMERA_STATUS_BASE + 2)
|
||||
|
||||
/* event type */
|
||||
#define MSM_CAMERA_V4L2_EVENT_TYPE (V4L2_EVENT_PRIVATE_START + 0x00002000)
|
||||
|
||||
/* event id */
|
||||
#define MSM_CAMERA_EVENT_MIN 0
|
||||
#define MSM_CAMERA_NEW_SESSION (MSM_CAMERA_EVENT_MIN + 1)
|
||||
#define MSM_CAMERA_DEL_SESSION (MSM_CAMERA_EVENT_MIN + 2)
|
||||
#define MSM_CAMERA_SET_PARM (MSM_CAMERA_EVENT_MIN + 3)
|
||||
#define MSM_CAMERA_GET_PARM (MSM_CAMERA_EVENT_MIN + 4)
|
||||
#define MSM_CAMERA_MAPPING_CFG (MSM_CAMERA_EVENT_MIN + 5)
|
||||
#define MSM_CAMERA_MAPPING_SES (MSM_CAMERA_EVENT_MIN + 6)
|
||||
#define MSM_CAMERA_MSM_NOTIFY (MSM_CAMERA_EVENT_MIN + 7)
|
||||
#define MSM_CAMERA_EVENT_MAX (MSM_CAMERA_EVENT_MIN + 8)
|
||||
|
||||
/* data.command */
|
||||
#define MSM_CAMERA_PRIV_S_CROP (V4L2_CID_PRIVATE_BASE + 1)
|
||||
#define MSM_CAMERA_PRIV_G_CROP (V4L2_CID_PRIVATE_BASE + 2)
|
||||
#define MSM_CAMERA_PRIV_G_FMT (V4L2_CID_PRIVATE_BASE + 3)
|
||||
#define MSM_CAMERA_PRIV_S_FMT (V4L2_CID_PRIVATE_BASE + 4)
|
||||
#define MSM_CAMERA_PRIV_TRY_FMT (V4L2_CID_PRIVATE_BASE + 5)
|
||||
#define MSM_CAMERA_PRIV_METADATA (V4L2_CID_PRIVATE_BASE + 6)
|
||||
#define MSM_CAMERA_PRIV_QUERY_CAP (V4L2_CID_PRIVATE_BASE + 7)
|
||||
#define MSM_CAMERA_PRIV_STREAM_ON (V4L2_CID_PRIVATE_BASE + 8)
|
||||
#define MSM_CAMERA_PRIV_STREAM_OFF (V4L2_CID_PRIVATE_BASE + 9)
|
||||
#define MSM_CAMERA_PRIV_NEW_STREAM (V4L2_CID_PRIVATE_BASE + 10)
|
||||
#define MSM_CAMERA_PRIV_DEL_STREAM (V4L2_CID_PRIVATE_BASE + 11)
|
||||
#define MSM_CAMERA_PRIV_SHUTDOWN (V4L2_CID_PRIVATE_BASE + 12)
|
||||
#define MSM_CAMERA_PRIV_STREAM_INFO_SYNC \
|
||||
(V4L2_CID_PRIVATE_BASE + 13)
|
||||
#define MSM_CAMERA_PRIV_G_SESSION_ID (V4L2_CID_PRIVATE_BASE + 14)
|
||||
#define MSM_CAMERA_PRIV_CMD_MAX 20
|
||||
|
||||
/* data.status - success */
|
||||
#define MSM_CAMERA_CMD_SUCESS 0x00000001
|
||||
#define MSM_CAMERA_BUF_MAP_SUCESS 0x00000002
|
||||
|
||||
/* data.status - error */
|
||||
#define MSM_CAMERA_ERR_EVT_BASE 0x00010000
|
||||
#define MSM_CAMERA_ERR_CMD_FAIL (MSM_CAMERA_ERR_EVT_BASE + 1)
|
||||
#define MSM_CAMERA_ERR_MAPPING (MSM_CAMERA_ERR_EVT_BASE + 2)
|
||||
#define MSM_CAMERA_ERR_DEVICE_BUSY (MSM_CAMERA_ERR_EVT_BASE + 3)
|
||||
|
||||
/* The msm_v4l2_event_data structure should match the
|
||||
* v4l2_event.u.data field.
|
||||
* should not exceed 16 elements */
|
||||
struct msm_v4l2_event_data {
|
||||
/*word 0*/
|
||||
unsigned int command;
|
||||
/*word 1*/
|
||||
unsigned int status;
|
||||
/*word 2*/
|
||||
unsigned int session_id;
|
||||
/*word 3*/
|
||||
unsigned int stream_id;
|
||||
/*word 4*/
|
||||
unsigned int map_op;
|
||||
/*word 5*/
|
||||
unsigned int map_buf_idx;
|
||||
/*word 6*/
|
||||
unsigned int notify;
|
||||
/*word 7*/
|
||||
unsigned int arg_value;
|
||||
/*word 8*/
|
||||
unsigned int ret_value;
|
||||
/*word 9*/
|
||||
unsigned int v4l2_event_type;
|
||||
/*word 10*/
|
||||
unsigned int v4l2_event_id;
|
||||
/*word 11*/
|
||||
unsigned int handle;
|
||||
/*word 12*/
|
||||
unsigned int nop6;
|
||||
/*word 13*/
|
||||
unsigned int nop7;
|
||||
/*word 14*/
|
||||
unsigned int nop8;
|
||||
/*word 15*/
|
||||
unsigned int nop9;
|
||||
};
|
||||
|
||||
/* map to v4l2_format.fmt.raw_data */
|
||||
struct msm_v4l2_format_data {
|
||||
enum v4l2_buf_type type;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int pixelformat; /* FOURCC */
|
||||
unsigned char num_planes;
|
||||
unsigned int plane_sizes[VIDEO_MAX_PLANES];
|
||||
};
|
||||
|
||||
/* MSM Four-character-code (FOURCC) */
|
||||
#define msm_v4l2_fourcc(a, b, c, d)\
|
||||
((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\
|
||||
((__u32)(d) << 24))
|
||||
|
||||
/* Composite stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
|
||||
/* AEC stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_AE v4l2_fourcc('S', 'T', 'A', 'E')
|
||||
/* AF stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_AF v4l2_fourcc('S', 'T', 'A', 'F')
|
||||
/* AWB stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_AWB v4l2_fourcc('S', 'T', 'W', 'B')
|
||||
/* IHIST stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T')
|
||||
/* Column count stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_CS v4l2_fourcc('S', 'T', 'C', 'S')
|
||||
/* Row count stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_RS v4l2_fourcc('S', 'T', 'R', 'S')
|
||||
/* Bayer Grid stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_BG v4l2_fourcc('S', 'T', 'B', 'G')
|
||||
/* Bayer focus stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_BF v4l2_fourcc('S', 'T', 'B', 'F')
|
||||
/* Bayer hist stats */
|
||||
#define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T')
|
||||
|
||||
enum smmu_attach_mode {
|
||||
NON_SECURE_MODE = 0x01,
|
||||
SECURE_MODE = 0x02,
|
||||
MAX_PROTECTION_MODE = 0x03,
|
||||
};
|
||||
|
||||
struct msm_camera_smmu_attach_type {
|
||||
enum smmu_attach_mode attach;
|
||||
};
|
||||
|
||||
struct msm_camera_user_buf_cont_t {
|
||||
unsigned int buf_cnt;
|
||||
unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
|
||||
};
|
||||
|
||||
#endif /* __LINUX_MSMB_CAMERA_H */
|
|
@ -0,0 +1,880 @@
|
|||
#ifndef __MSMB_ISP__
|
||||
#define __MSMB_ISP__
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#define MAX_PLANES_PER_STREAM 3
|
||||
#define MAX_NUM_STREAM 7
|
||||
|
||||
#define ISP_VERSION_47 47
|
||||
#define ISP_VERSION_46 46
|
||||
#define ISP_VERSION_44 44
|
||||
#define ISP_VERSION_40 40
|
||||
#define ISP_VERSION_32 32
|
||||
#define ISP_NATIVE_BUF_BIT (0x10000 << 0)
|
||||
#define ISP0_BIT (0x10000 << 1)
|
||||
#define ISP1_BIT (0x10000 << 2)
|
||||
#define ISP_META_CHANNEL_BIT (0x10000 << 3)
|
||||
#define ISP_SCRATCH_BUF_BIT (0x10000 << 4)
|
||||
#define ISP_OFFLINE_STATS_BIT (0x10000 << 5)
|
||||
#define ISP_STATS_STREAM_BIT 0x80000000
|
||||
|
||||
struct msm_vfe_cfg_cmd_list;
|
||||
|
||||
enum ISP_START_PIXEL_PATTERN {
|
||||
ISP_BAYER_RGRGRG,
|
||||
ISP_BAYER_GRGRGR,
|
||||
ISP_BAYER_BGBGBG,
|
||||
ISP_BAYER_GBGBGB,
|
||||
ISP_YUV_YCbYCr,
|
||||
ISP_YUV_YCrYCb,
|
||||
ISP_YUV_CbYCrY,
|
||||
ISP_YUV_CrYCbY,
|
||||
ISP_PIX_PATTERN_MAX
|
||||
};
|
||||
|
||||
enum msm_vfe_plane_fmt {
|
||||
Y_PLANE,
|
||||
CB_PLANE,
|
||||
CR_PLANE,
|
||||
CRCB_PLANE,
|
||||
CBCR_PLANE,
|
||||
VFE_PLANE_FMT_MAX
|
||||
};
|
||||
|
||||
enum msm_vfe_input_src {
|
||||
VFE_PIX_0,
|
||||
VFE_RAW_0,
|
||||
VFE_RAW_1,
|
||||
VFE_RAW_2,
|
||||
VFE_SRC_MAX,
|
||||
};
|
||||
|
||||
enum msm_vfe_axi_stream_src {
|
||||
PIX_ENCODER,
|
||||
PIX_VIEWFINDER,
|
||||
PIX_VIDEO,
|
||||
CAMIF_RAW,
|
||||
IDEAL_RAW,
|
||||
RDI_INTF_0,
|
||||
RDI_INTF_1,
|
||||
RDI_INTF_2,
|
||||
VFE_AXI_SRC_MAX
|
||||
};
|
||||
|
||||
enum msm_vfe_frame_skip_pattern {
|
||||
NO_SKIP,
|
||||
EVERY_2FRAME,
|
||||
EVERY_3FRAME,
|
||||
EVERY_4FRAME,
|
||||
EVERY_5FRAME,
|
||||
EVERY_6FRAME,
|
||||
EVERY_7FRAME,
|
||||
EVERY_8FRAME,
|
||||
EVERY_16FRAME,
|
||||
EVERY_32FRAME,
|
||||
SKIP_ALL,
|
||||
SKIP_RANGE,
|
||||
MAX_SKIP,
|
||||
};
|
||||
|
||||
/*
|
||||
* Define an unused period. When this period is set it means that the stream is
|
||||
* stopped(i.e the pattern is 0). We don't track the current pattern, just the
|
||||
* period defines what the pattern is, if period is this then pattern is 0 else
|
||||
* pattern is 1
|
||||
*/
|
||||
#define MSM_VFE_STREAM_STOP_PERIOD 15
|
||||
|
||||
enum msm_isp_stats_type {
|
||||
MSM_ISP_STATS_AEC, /* legacy based AEC */
|
||||
MSM_ISP_STATS_AF, /* legacy based AF */
|
||||
MSM_ISP_STATS_AWB, /* legacy based AWB */
|
||||
MSM_ISP_STATS_RS, /* legacy based RS */
|
||||
MSM_ISP_STATS_CS, /* legacy based CS */
|
||||
MSM_ISP_STATS_IHIST, /* legacy based HIST */
|
||||
MSM_ISP_STATS_SKIN, /* legacy based SKIN */
|
||||
MSM_ISP_STATS_BG, /* Bayer Grids */
|
||||
MSM_ISP_STATS_BF, /* Bayer Focus */
|
||||
MSM_ISP_STATS_BE, /* Bayer Exposure*/
|
||||
MSM_ISP_STATS_BHIST, /* Bayer Hist */
|
||||
MSM_ISP_STATS_BF_SCALE, /* Bayer Focus scale */
|
||||
MSM_ISP_STATS_HDR_BE, /* HDR Bayer Exposure */
|
||||
MSM_ISP_STATS_HDR_BHIST, /* HDR Bayer Hist */
|
||||
MSM_ISP_STATS_AEC_BG, /* AEC BG */
|
||||
MSM_ISP_STATS_MAX /* MAX */
|
||||
};
|
||||
|
||||
/*
|
||||
* @stats_type_mask: Stats type mask (enum msm_isp_stats_type).
|
||||
* @stream_src_mask: Stream src mask (enum msm_vfe_axi_stream_src)
|
||||
* @skip_mode: skip pattern, if skip mode is range only then min/max is used
|
||||
* @min_frame_id: minimum frame id (valid only if skip_mode = RANGE)
|
||||
* @max_frame_id: maximum frame id (valid only if skip_mode = RANGE)
|
||||
*/
|
||||
struct msm_isp_sw_framskip {
|
||||
uint32_t stats_type_mask;
|
||||
uint32_t stream_src_mask;
|
||||
enum msm_vfe_frame_skip_pattern skip_mode;
|
||||
uint32_t min_frame_id;
|
||||
uint32_t max_frame_id;
|
||||
};
|
||||
|
||||
enum msm_vfe_testgen_color_pattern {
|
||||
COLOR_BAR_8_COLOR,
|
||||
UNICOLOR_WHITE,
|
||||
UNICOLOR_YELLOW,
|
||||
UNICOLOR_CYAN,
|
||||
UNICOLOR_GREEN,
|
||||
UNICOLOR_MAGENTA,
|
||||
UNICOLOR_RED,
|
||||
UNICOLOR_BLUE,
|
||||
UNICOLOR_BLACK,
|
||||
MAX_COLOR,
|
||||
};
|
||||
|
||||
enum msm_vfe_camif_input {
|
||||
CAMIF_DISABLED,
|
||||
CAMIF_PAD_REG_INPUT,
|
||||
CAMIF_MIDDI_INPUT,
|
||||
CAMIF_MIPI_INPUT,
|
||||
};
|
||||
|
||||
struct msm_vfe_fetch_engine_cfg {
|
||||
uint32_t input_format;
|
||||
uint32_t buf_width;
|
||||
uint32_t buf_height;
|
||||
uint32_t fetch_width;
|
||||
uint32_t fetch_height;
|
||||
uint32_t x_offset;
|
||||
uint32_t y_offset;
|
||||
uint32_t buf_stride;
|
||||
};
|
||||
|
||||
enum msm_vfe_camif_output_format {
|
||||
CAMIF_QCOM_RAW,
|
||||
CAMIF_MIPI_RAW,
|
||||
CAMIF_PLAIN_8,
|
||||
CAMIF_PLAIN_16,
|
||||
CAMIF_MAX_FORMAT,
|
||||
};
|
||||
|
||||
/*
|
||||
* Camif output general configuration
|
||||
*/
|
||||
struct msm_vfe_camif_subsample_cfg {
|
||||
uint32_t irq_subsample_period;
|
||||
uint32_t irq_subsample_pattern;
|
||||
uint32_t sof_counter_step;
|
||||
uint32_t pixel_skip;
|
||||
uint32_t line_skip;
|
||||
uint32_t first_line;
|
||||
uint32_t last_line;
|
||||
uint32_t first_pixel;
|
||||
uint32_t last_pixel;
|
||||
enum msm_vfe_camif_output_format output_format;
|
||||
};
|
||||
|
||||
/*
|
||||
* Camif frame and window configuration
|
||||
*/
|
||||
struct msm_vfe_camif_cfg {
|
||||
uint32_t lines_per_frame;
|
||||
uint32_t pixels_per_line;
|
||||
uint32_t first_pixel;
|
||||
uint32_t last_pixel;
|
||||
uint32_t first_line;
|
||||
uint32_t last_line;
|
||||
uint32_t epoch_line0;
|
||||
uint32_t epoch_line1;
|
||||
uint32_t is_split;
|
||||
enum msm_vfe_camif_input camif_input;
|
||||
struct msm_vfe_camif_subsample_cfg subsample_cfg;
|
||||
};
|
||||
|
||||
struct msm_vfe_testgen_cfg {
|
||||
uint32_t lines_per_frame;
|
||||
uint32_t pixels_per_line;
|
||||
uint32_t v_blank;
|
||||
uint32_t h_blank;
|
||||
enum ISP_START_PIXEL_PATTERN pixel_bayer_pattern;
|
||||
uint32_t rotate_period;
|
||||
enum msm_vfe_testgen_color_pattern color_bar_pattern;
|
||||
uint32_t burst_num_frame;
|
||||
};
|
||||
|
||||
enum msm_vfe_inputmux {
|
||||
CAMIF,
|
||||
TESTGEN,
|
||||
EXTERNAL_READ,
|
||||
};
|
||||
|
||||
enum msm_vfe_stats_composite_group {
|
||||
STATS_COMPOSITE_GRP_NONE,
|
||||
STATS_COMPOSITE_GRP_1,
|
||||
STATS_COMPOSITE_GRP_2,
|
||||
STATS_COMPOSITE_GRP_MAX,
|
||||
};
|
||||
|
||||
enum msm_vfe_hvx_streaming_cmd {
|
||||
HVX_DISABLE,
|
||||
HVX_ONE_WAY,
|
||||
HVX_ROUND_TRIP
|
||||
};
|
||||
|
||||
struct msm_vfe_pix_cfg {
|
||||
struct msm_vfe_camif_cfg camif_cfg;
|
||||
struct msm_vfe_testgen_cfg testgen_cfg;
|
||||
struct msm_vfe_fetch_engine_cfg fetch_engine_cfg;
|
||||
enum msm_vfe_inputmux input_mux;
|
||||
enum ISP_START_PIXEL_PATTERN pixel_pattern;
|
||||
uint32_t input_format;
|
||||
enum msm_vfe_hvx_streaming_cmd hvx_cmd;
|
||||
uint32_t is_split;
|
||||
};
|
||||
|
||||
struct msm_vfe_rdi_cfg {
|
||||
uint8_t cid;
|
||||
uint8_t frame_based;
|
||||
};
|
||||
|
||||
struct msm_vfe_input_cfg {
|
||||
union {
|
||||
struct msm_vfe_pix_cfg pix_cfg;
|
||||
struct msm_vfe_rdi_cfg rdi_cfg;
|
||||
} d;
|
||||
enum msm_vfe_input_src input_src;
|
||||
uint32_t input_pix_clk;
|
||||
};
|
||||
|
||||
struct msm_vfe_fetch_eng_start {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t buf_idx;
|
||||
uint8_t offline_mode;
|
||||
uint32_t fd;
|
||||
uint32_t buf_addr;
|
||||
uint32_t frame_id;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_plane_cfg {
|
||||
uint32_t output_width; /*Include padding*/
|
||||
uint32_t output_height;
|
||||
uint32_t output_stride;
|
||||
uint32_t output_scan_lines;
|
||||
uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
|
||||
uint32_t plane_addr_offset;
|
||||
uint8_t csid_src; /*RDI 0-2*/
|
||||
uint8_t rdi_cid;/*CID 1-16*/
|
||||
};
|
||||
|
||||
enum msm_stream_memory_input_t {
|
||||
MEMORY_INPUT_DISABLED,
|
||||
MEMORY_INPUT_ENABLED
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_stream_request_cmd {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t vt_enable;
|
||||
uint32_t output_format;/*Planar/RAW/Misc*/
|
||||
enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
|
||||
struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
|
||||
|
||||
uint32_t burst_count;
|
||||
uint32_t hfr_mode;
|
||||
uint8_t frame_base;
|
||||
|
||||
uint32_t init_frame_drop; /*MAX 31 Frames*/
|
||||
enum msm_vfe_frame_skip_pattern frame_skip_pattern;
|
||||
uint8_t buf_divert; /* if TRUE no vb2 buf done. */
|
||||
/*Return values*/
|
||||
uint32_t axi_stream_handle;
|
||||
uint32_t controllable_output;
|
||||
uint32_t burst_len;
|
||||
/* Flag indicating memory input stream */
|
||||
enum msm_stream_memory_input_t memory_input;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_stream_release_cmd {
|
||||
uint32_t stream_handle;
|
||||
};
|
||||
|
||||
enum msm_vfe_axi_stream_cmd {
|
||||
STOP_STREAM,
|
||||
START_STREAM,
|
||||
STOP_IMMEDIATELY,
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_stream_cfg_cmd {
|
||||
uint8_t num_streams;
|
||||
uint32_t stream_handle[VFE_AXI_SRC_MAX];
|
||||
enum msm_vfe_axi_stream_cmd cmd;
|
||||
uint8_t sync_frame_id_src;
|
||||
};
|
||||
|
||||
enum msm_vfe_axi_stream_update_type {
|
||||
ENABLE_STREAM_BUF_DIVERT,
|
||||
DISABLE_STREAM_BUF_DIVERT,
|
||||
UPDATE_STREAM_FRAMEDROP_PATTERN,
|
||||
UPDATE_STREAM_STATS_FRAMEDROP_PATTERN,
|
||||
UPDATE_STREAM_AXI_CONFIG,
|
||||
UPDATE_STREAM_REQUEST_FRAMES,
|
||||
UPDATE_STREAM_ADD_BUFQ,
|
||||
UPDATE_STREAM_REMOVE_BUFQ,
|
||||
UPDATE_STREAM_SW_FRAME_DROP,
|
||||
};
|
||||
|
||||
enum msm_vfe_iommu_type {
|
||||
IOMMU_ATTACH,
|
||||
IOMMU_DETACH,
|
||||
};
|
||||
|
||||
enum msm_vfe_buff_queue_id {
|
||||
VFE_BUF_QUEUE_DEFAULT,
|
||||
VFE_BUF_QUEUE_SHARED,
|
||||
VFE_BUF_QUEUE_MAX,
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_stream_cfg_update_info {
|
||||
uint32_t stream_handle;
|
||||
uint32_t output_format;
|
||||
uint32_t user_stream_id;
|
||||
uint32_t frame_id;
|
||||
enum msm_vfe_frame_skip_pattern skip_pattern;
|
||||
struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
|
||||
struct msm_isp_sw_framskip sw_skip_info;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_halt_cmd {
|
||||
uint32_t stop_camif;
|
||||
uint32_t overflow_detected;
|
||||
uint32_t blocking_halt;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_reset_cmd {
|
||||
uint32_t blocking;
|
||||
uint32_t frame_id;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_restart_cmd {
|
||||
uint32_t enable_camif;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_stream_update_cmd {
|
||||
uint32_t num_streams;
|
||||
enum msm_vfe_axi_stream_update_type update_type;
|
||||
struct msm_vfe_axi_stream_cfg_update_info
|
||||
update_info[MSM_ISP_STATS_MAX];
|
||||
};
|
||||
|
||||
struct msm_vfe_smmu_attach_cmd {
|
||||
uint32_t security_mode;
|
||||
uint32_t iommu_attach_mode;
|
||||
};
|
||||
|
||||
struct msm_vfe_stats_stream_request_cmd {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
enum msm_isp_stats_type stats_type;
|
||||
uint32_t composite_flag;
|
||||
uint32_t framedrop_pattern;
|
||||
uint32_t init_frame_drop; /*MAX 31 Frames*/
|
||||
uint32_t irq_subsample_pattern;
|
||||
uint32_t buffer_offset;
|
||||
uint32_t stream_handle;
|
||||
};
|
||||
|
||||
struct msm_vfe_stats_stream_release_cmd {
|
||||
uint32_t stream_handle;
|
||||
};
|
||||
struct msm_vfe_stats_stream_cfg_cmd {
|
||||
uint8_t num_streams;
|
||||
uint32_t stream_handle[MSM_ISP_STATS_MAX];
|
||||
uint8_t enable;
|
||||
uint32_t stats_burst_len;
|
||||
};
|
||||
|
||||
enum msm_vfe_reg_cfg_type {
|
||||
VFE_WRITE,
|
||||
VFE_WRITE_MB,
|
||||
VFE_READ,
|
||||
VFE_CFG_MASK,
|
||||
VFE_WRITE_DMI_16BIT,
|
||||
VFE_WRITE_DMI_32BIT,
|
||||
VFE_WRITE_DMI_64BIT,
|
||||
VFE_READ_DMI_16BIT,
|
||||
VFE_READ_DMI_32BIT,
|
||||
VFE_READ_DMI_64BIT,
|
||||
GET_MAX_CLK_RATE,
|
||||
GET_CLK_RATES,
|
||||
GET_ISP_ID,
|
||||
VFE_HW_UPDATE_LOCK,
|
||||
VFE_HW_UPDATE_UNLOCK,
|
||||
SET_WM_UB_SIZE,
|
||||
SET_UB_POLICY,
|
||||
};
|
||||
|
||||
struct msm_vfe_cfg_cmd2 {
|
||||
uint16_t num_cfg;
|
||||
uint16_t cmd_len;
|
||||
void __user *cfg_data;
|
||||
void __user *cfg_cmd;
|
||||
};
|
||||
|
||||
struct msm_vfe_cfg_cmd_list {
|
||||
struct msm_vfe_cfg_cmd2 cfg_cmd;
|
||||
struct msm_vfe_cfg_cmd_list *next;
|
||||
uint32_t next_size;
|
||||
};
|
||||
|
||||
struct msm_vfe_reg_rw_info {
|
||||
uint32_t reg_offset;
|
||||
uint32_t cmd_data_offset;
|
||||
uint32_t len;
|
||||
};
|
||||
|
||||
struct msm_vfe_reg_mask_info {
|
||||
uint32_t reg_offset;
|
||||
uint32_t mask;
|
||||
uint32_t val;
|
||||
};
|
||||
|
||||
struct msm_vfe_reg_dmi_info {
|
||||
uint32_t hi_tbl_offset; /*Optional*/
|
||||
uint32_t lo_tbl_offset; /*Required*/
|
||||
uint32_t len;
|
||||
};
|
||||
|
||||
struct msm_vfe_reg_cfg_cmd {
|
||||
union {
|
||||
struct msm_vfe_reg_rw_info rw_info;
|
||||
struct msm_vfe_reg_mask_info mask_info;
|
||||
struct msm_vfe_reg_dmi_info dmi_info;
|
||||
} u;
|
||||
|
||||
enum msm_vfe_reg_cfg_type cmd_type;
|
||||
};
|
||||
|
||||
enum vfe_sd_type {
|
||||
VFE_SD_0 = 0,
|
||||
VFE_SD_1,
|
||||
VFE_SD_COMMON,
|
||||
VFE_SD_MAX,
|
||||
};
|
||||
|
||||
/* When you change the value below, check for the sof event_data size.
|
||||
* V4l2 limits payload to 64 bytes */
|
||||
#define MS_NUM_SLAVE_MAX 1
|
||||
|
||||
/* Usecases when 2 HW need to be related or synced */
|
||||
enum msm_vfe_dual_hw_type {
|
||||
DUAL_NONE = 0,
|
||||
DUAL_HW_VFE_SPLIT = 1,
|
||||
DUAL_HW_MASTER_SLAVE = 2,
|
||||
};
|
||||
|
||||
/* Type for 2 INTF when used in Master-Slave mode */
|
||||
enum msm_vfe_dual_hw_ms_type {
|
||||
MS_TYPE_NONE,
|
||||
MS_TYPE_MASTER,
|
||||
MS_TYPE_SLAVE,
|
||||
};
|
||||
|
||||
struct msm_isp_set_dual_hw_ms_cmd {
|
||||
uint8_t num_src;
|
||||
/* Each session can be only one type but multiple intf if YUV cam */
|
||||
enum msm_vfe_dual_hw_ms_type dual_hw_ms_type;
|
||||
/* Primary intf is mostly associated with preview.
|
||||
* This primary intf SOF frame_id and timestamp is tracked
|
||||
* and used to calculate delta */
|
||||
enum msm_vfe_input_src primary_intf;
|
||||
/* input_src array indicates other input INTF that may be Master/Slave.
|
||||
* For these additional intf, frame_id and timestamp are not saved.
|
||||
* However, if these are slaves then they will still get their
|
||||
* frame_id from Master */
|
||||
enum msm_vfe_input_src input_src[VFE_SRC_MAX];
|
||||
uint32_t sof_delta_threshold; /* In milliseconds. Sent for Master */
|
||||
};
|
||||
|
||||
enum msm_isp_buf_type {
|
||||
ISP_PRIVATE_BUF,
|
||||
ISP_SHARE_BUF,
|
||||
MAX_ISP_BUF_TYPE,
|
||||
};
|
||||
|
||||
struct msm_isp_unmap_buf_req {
|
||||
uint32_t fd;
|
||||
};
|
||||
|
||||
struct msm_isp_buf_request {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint8_t num_buf;
|
||||
uint32_t handle;
|
||||
enum msm_isp_buf_type buf_type;
|
||||
};
|
||||
|
||||
struct msm_isp_qbuf_plane {
|
||||
uint32_t addr;
|
||||
uint32_t offset;
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
struct msm_isp_qbuf_buffer {
|
||||
struct msm_isp_qbuf_plane planes[MAX_PLANES_PER_STREAM];
|
||||
uint32_t num_planes;
|
||||
};
|
||||
|
||||
struct msm_isp_qbuf_info {
|
||||
uint32_t handle;
|
||||
int32_t buf_idx;
|
||||
/*Only used for prepare buffer*/
|
||||
struct msm_isp_qbuf_buffer buffer;
|
||||
/*Only used for diverted buffer*/
|
||||
uint32_t dirty_buf;
|
||||
};
|
||||
|
||||
struct msm_isp_clk_rates {
|
||||
uint32_t svs_rate;
|
||||
uint32_t nominal_rate;
|
||||
uint32_t high_rate;
|
||||
};
|
||||
|
||||
struct msm_vfe_axi_src_state {
|
||||
enum msm_vfe_input_src input_src;
|
||||
uint32_t src_active;
|
||||
uint32_t src_frame_id;
|
||||
};
|
||||
|
||||
enum msm_isp_event_mask_index {
|
||||
ISP_EVENT_MASK_INDEX_STATS_NOTIFY = 0,
|
||||
ISP_EVENT_MASK_INDEX_ERROR = 1,
|
||||
ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT = 2,
|
||||
ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE = 3,
|
||||
ISP_EVENT_MASK_INDEX_REG_UPDATE = 4,
|
||||
ISP_EVENT_MASK_INDEX_SOF = 5,
|
||||
ISP_EVENT_MASK_INDEX_BUF_DIVERT = 6,
|
||||
ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY = 7,
|
||||
ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE = 8,
|
||||
ISP_EVENT_MASK_INDEX_BUF_DONE = 9,
|
||||
ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING = 10,
|
||||
ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH = 11,
|
||||
ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR = 12,
|
||||
};
|
||||
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_NONE 0
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_STATS_NOTIFY \
|
||||
(1 << ISP_EVENT_MASK_INDEX_STATS_NOTIFY)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_ERROR \
|
||||
(1 << ISP_EVENT_MASK_INDEX_ERROR)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_IOMMU_P_FAULT \
|
||||
(1 << ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_STREAM_UPDATE_DONE \
|
||||
(1 << ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_REG_UPDATE \
|
||||
(1 << ISP_EVENT_MASK_INDEX_REG_UPDATE)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_SOF \
|
||||
(1 << ISP_EVENT_MASK_INDEX_SOF)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_BUF_DIVERT \
|
||||
(1 << ISP_EVENT_MASK_INDEX_BUF_DIVERT)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_COMP_STATS_NOTIFY \
|
||||
(1 << ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_FE_READ_DONE \
|
||||
(1 << ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_BUF_DONE \
|
||||
(1 << ISP_EVENT_MASK_INDEX_BUF_DONE)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_REG_UPDATE_MISSING \
|
||||
(1 << ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_PING_PONG_MISMATCH \
|
||||
(1 << ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH)
|
||||
|
||||
#define ISP_EVENT_SUBS_MASK_BUF_FATAL_ERROR \
|
||||
(1 << ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR)
|
||||
|
||||
enum msm_isp_event_idx {
|
||||
ISP_REG_UPDATE = 0,
|
||||
ISP_EPOCH_0 = 1,
|
||||
ISP_EPOCH_1 = 2,
|
||||
ISP_START_ACK = 3,
|
||||
ISP_STOP_ACK = 4,
|
||||
ISP_IRQ_VIOLATION = 5,
|
||||
ISP_STATS_OVERFLOW = 6,
|
||||
ISP_BUF_DONE = 7,
|
||||
ISP_FE_RD_DONE = 8,
|
||||
ISP_IOMMU_P_FAULT = 9,
|
||||
ISP_ERROR = 10,
|
||||
ISP_HW_FATAL_ERROR = 11,
|
||||
ISP_PING_PONG_MISMATCH = 12,
|
||||
ISP_REG_UPDATE_MISSING = 13,
|
||||
ISP_BUF_FATAL_ERROR = 14,
|
||||
ISP_EVENT_MAX = 15
|
||||
};
|
||||
|
||||
#define ISP_EVENT_OFFSET 8
|
||||
#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
|
||||
#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
|
||||
#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
|
||||
#define ISP_CAMIF_EVENT_BASE (ISP_EVENT_BASE + (3 << ISP_EVENT_OFFSET))
|
||||
#define ISP_STREAM_EVENT_BASE (ISP_EVENT_BASE + (4 << ISP_EVENT_OFFSET))
|
||||
#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
|
||||
#define ISP_EVENT_EPOCH_0 (ISP_EVENT_BASE + ISP_EPOCH_0)
|
||||
#define ISP_EVENT_EPOCH_1 (ISP_EVENT_BASE + ISP_EPOCH_1)
|
||||
#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
|
||||
#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
|
||||
#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
|
||||
#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
|
||||
#define ISP_EVENT_ERROR (ISP_EVENT_BASE + ISP_ERROR)
|
||||
#define ISP_EVENT_SOF (ISP_CAMIF_EVENT_BASE)
|
||||
#define ISP_EVENT_EOF (ISP_CAMIF_EVENT_BASE + 1)
|
||||
#define ISP_EVENT_BUF_DONE (ISP_EVENT_BASE + ISP_BUF_DONE)
|
||||
#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
|
||||
#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
|
||||
#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
|
||||
#define ISP_EVENT_FE_READ_DONE (ISP_EVENT_BASE + ISP_FE_RD_DONE)
|
||||
#define ISP_EVENT_IOMMU_P_FAULT (ISP_EVENT_BASE + ISP_IOMMU_P_FAULT)
|
||||
#define ISP_EVENT_HW_FATAL_ERROR (ISP_EVENT_BASE + ISP_HW_FATAL_ERROR)
|
||||
#define ISP_EVENT_PING_PONG_MISMATCH (ISP_EVENT_BASE + ISP_PING_PONG_MISMATCH)
|
||||
#define ISP_EVENT_REG_UPDATE_MISSING (ISP_EVENT_BASE + ISP_REG_UPDATE_MISSING)
|
||||
#define ISP_EVENT_BUF_FATAL_ERROR (ISP_EVENT_BASE + ISP_BUF_FATAL_ERROR)
|
||||
#define ISP_EVENT_STREAM_UPDATE_DONE (ISP_STREAM_EVENT_BASE)
|
||||
|
||||
/* The msm_v4l2_event_data structure should match the
|
||||
* v4l2_event.u.data field.
|
||||
* should not exceed 64 bytes */
|
||||
|
||||
struct msm_isp_buf_event {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t handle;
|
||||
uint32_t output_format;
|
||||
int8_t buf_idx;
|
||||
};
|
||||
struct msm_isp_fetch_eng_event {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t handle;
|
||||
uint32_t fd;
|
||||
int8_t buf_idx;
|
||||
int8_t offline_mode;
|
||||
};
|
||||
struct msm_isp_stats_event {
|
||||
uint32_t stats_mask; /* 4 bytes */
|
||||
uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
|
||||
};
|
||||
|
||||
struct msm_isp_stream_ack {
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
enum msm_vfe_error_type {
|
||||
ISP_ERROR_NONE,
|
||||
ISP_ERROR_CAMIF,
|
||||
ISP_ERROR_BUS_OVERFLOW,
|
||||
ISP_ERROR_RETURN_EMPTY_BUFFER,
|
||||
ISP_ERROR_FRAME_ID_MISMATCH,
|
||||
ISP_ERROR_MAX,
|
||||
};
|
||||
|
||||
struct msm_isp_error_info {
|
||||
enum msm_vfe_error_type err_type;
|
||||
uint32_t session_id;
|
||||
uint32_t stream_id;
|
||||
uint32_t stream_id_mask;
|
||||
};
|
||||
|
||||
/* This structure reports delta between master and slave */
|
||||
struct msm_isp_ms_delta_info {
|
||||
uint8_t num_delta_info;
|
||||
uint32_t delta[MS_NUM_SLAVE_MAX];
|
||||
};
|
||||
|
||||
/* This is sent in EPOCH irq */
|
||||
struct msm_isp_output_info {
|
||||
uint8_t regs_not_updated;
|
||||
/* mask with bufq_handle for regs not updated or return empty */
|
||||
uint16_t output_err_mask;
|
||||
/* mask with stream_idx for get_buf failed */
|
||||
uint8_t stream_framedrop_mask;
|
||||
/* mask with stats stream_idx for get_buf failed */
|
||||
uint16_t stats_framedrop_mask;
|
||||
/* delta between master and slave */
|
||||
};
|
||||
|
||||
/* This structure is piggybacked with SOF event */
|
||||
struct msm_isp_sof_info {
|
||||
uint8_t regs_not_updated;
|
||||
/* mask with AXI_SRC for regs not updated */
|
||||
uint16_t reg_update_fail_mask;
|
||||
/* mask with bufq_handle for get_buf failed */
|
||||
uint32_t stream_get_buf_fail_mask;
|
||||
/* mask with stats stream_idx for get_buf failed */
|
||||
uint16_t stats_get_buf_fail_mask;
|
||||
/* delta between master and slave */
|
||||
struct msm_isp_ms_delta_info ms_delta_info;
|
||||
};
|
||||
|
||||
struct msm_isp_event_data {
|
||||
/*Wall clock except for buffer divert events
|
||||
*which use monotonic clock
|
||||
*/
|
||||
struct timeval timestamp;
|
||||
/* Monotonic timestamp since bootup */
|
||||
struct timeval mono_timestamp;
|
||||
uint32_t frame_id;
|
||||
union {
|
||||
/* Sent for Stats_Done event */
|
||||
struct msm_isp_stats_event stats;
|
||||
/* Sent for Buf_Divert event */
|
||||
struct msm_isp_buf_event buf_done;
|
||||
/* Sent for offline fetch done event */
|
||||
struct msm_isp_fetch_eng_event fetch_done;
|
||||
/* Sent for Error_Event */
|
||||
struct msm_isp_error_info error_info;
|
||||
/*
|
||||
* This struct needs to be removed once
|
||||
* userspace switches to sof_info
|
||||
*/
|
||||
struct msm_isp_output_info output_info;
|
||||
/* Sent for SOF event */
|
||||
struct msm_isp_sof_info sof_info;
|
||||
} u; /* union can have max 52 bytes */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
struct msm_isp_event_data32 {
|
||||
struct compat_timeval timestamp;
|
||||
struct compat_timeval mono_timestamp;
|
||||
uint32_t frame_id;
|
||||
union {
|
||||
struct msm_isp_stats_event stats;
|
||||
struct msm_isp_buf_event buf_done;
|
||||
struct msm_isp_fetch_eng_event fetch_done;
|
||||
struct msm_isp_error_info error_info;
|
||||
struct msm_isp_output_info output_info;
|
||||
struct msm_isp_sof_info sof_info;
|
||||
} u;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
|
||||
#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
|
||||
#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
|
||||
#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
|
||||
#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
|
||||
#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
|
||||
#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
|
||||
#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
|
||||
#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
|
||||
#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
|
||||
#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
|
||||
#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
|
||||
#define V4L2_PIX_FMT_QBGGR14 v4l2_fourcc('Q', 'B', 'G', '4')
|
||||
#define V4L2_PIX_FMT_QGBRG14 v4l2_fourcc('Q', 'G', 'B', '4')
|
||||
#define V4L2_PIX_FMT_QGRBG14 v4l2_fourcc('Q', 'G', 'R', '4')
|
||||
#define V4L2_PIX_FMT_QRGGB14 v4l2_fourcc('Q', 'R', 'G', '4')
|
||||
#define V4L2_PIX_FMT_P16BGGR10 v4l2_fourcc('P', 'B', 'G', '0')
|
||||
#define V4L2_PIX_FMT_P16GBRG10 v4l2_fourcc('P', 'G', 'B', '0')
|
||||
#define V4L2_PIX_FMT_P16GRBG10 v4l2_fourcc('P', 'G', 'R', '0')
|
||||
#define V4L2_PIX_FMT_P16RGGB10 v4l2_fourcc('P', 'R', 'G', '0')
|
||||
#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
|
||||
#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
|
||||
#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
|
||||
#define V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.GRGR.*/
|
||||
#define V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.RGRG.*/
|
||||
#define V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') /* 14 GRGR.BGBG.*/
|
||||
#define V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.GBGB.*/
|
||||
|
||||
#define VIDIOC_MSM_VFE_REG_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
|
||||
|
||||
#define VIDIOC_MSM_ISP_REQUEST_BUF \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
|
||||
|
||||
#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
|
||||
|
||||
#define VIDIOC_MSM_ISP_RELEASE_BUF \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
|
||||
|
||||
#define VIDIOC_MSM_ISP_REQUEST_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_CFG_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_RELEASE_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_INPUT_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
|
||||
|
||||
#define VIDIOC_MSM_ISP_SET_SRC_STATE \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
|
||||
|
||||
#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+9, \
|
||||
struct msm_vfe_stats_stream_request_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+11, \
|
||||
struct msm_vfe_stats_stream_release_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_REG_UPDATE_CMD \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+12, enum msm_vfe_input_src)
|
||||
|
||||
#define VIDIOC_MSM_ISP_UPDATE_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
|
||||
|
||||
#define VIDIOC_MSM_VFE_REG_LIST_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+14, struct msm_vfe_cfg_cmd_list)
|
||||
|
||||
#define VIDIOC_MSM_ISP_SMMU_ATTACH \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+15, struct msm_vfe_smmu_attach_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_UPDATE_STATS_STREAM \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+16, struct msm_vfe_axi_stream_update_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_AXI_HALT \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+17, struct msm_vfe_axi_halt_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_AXI_RESET \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+18, struct msm_vfe_axi_reset_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_AXI_RESTART \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+19, struct msm_vfe_axi_restart_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_FETCH_ENG_START \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+20, struct msm_vfe_fetch_eng_start)
|
||||
|
||||
#define VIDIOC_MSM_ISP_DEQUEUE_BUF \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+21, struct msm_isp_qbuf_info)
|
||||
|
||||
#define VIDIOC_MSM_ISP_SET_DUAL_HW_MASTER_SLAVE \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+22, struct msm_isp_set_dual_hw_ms_cmd)
|
||||
|
||||
#define VIDIOC_MSM_ISP_MAP_BUF_START_FE \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+23, struct msm_vfe_fetch_eng_start)
|
||||
|
||||
#define VIDIOC_MSM_ISP_UNMAP_BUF \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE+24, struct msm_isp_unmap_buf_req)
|
||||
|
||||
#endif /* __MSMB_ISP__ */
|
|
@ -0,0 +1,125 @@
|
|||
#ifndef MSM_CAM_ISPIF_H
|
||||
#define MSM_CAM_ISPIF_H
|
||||
|
||||
#define CSID_VERSION_V20 0x02000011
|
||||
#define CSID_VERSION_V22 0x02001000
|
||||
#define CSID_VERSION_V30 0x30000000
|
||||
#define CSID_VERSION_V3 0x30000000
|
||||
|
||||
enum msm_ispif_vfe_intf {
|
||||
VFE0,
|
||||
VFE1,
|
||||
VFE_MAX
|
||||
};
|
||||
#define VFE0_MASK (1 << VFE0)
|
||||
#define VFE1_MASK (1 << VFE1)
|
||||
|
||||
enum msm_ispif_intftype {
|
||||
PIX0,
|
||||
RDI0,
|
||||
PIX1,
|
||||
RDI1,
|
||||
RDI2,
|
||||
INTF_MAX
|
||||
};
|
||||
#define MAX_PARAM_ENTRIES (INTF_MAX * 2)
|
||||
#define MAX_CID_CH 8
|
||||
|
||||
#define PIX0_MASK (1 << PIX0)
|
||||
#define PIX1_MASK (1 << PIX1)
|
||||
#define RDI0_MASK (1 << RDI0)
|
||||
#define RDI1_MASK (1 << RDI1)
|
||||
#define RDI2_MASK (1 << RDI2)
|
||||
|
||||
|
||||
enum msm_ispif_vc {
|
||||
VC0,
|
||||
VC1,
|
||||
VC2,
|
||||
VC3,
|
||||
VC_MAX
|
||||
};
|
||||
|
||||
enum msm_ispif_cid {
|
||||
CID0,
|
||||
CID1,
|
||||
CID2,
|
||||
CID3,
|
||||
CID4,
|
||||
CID5,
|
||||
CID6,
|
||||
CID7,
|
||||
CID8,
|
||||
CID9,
|
||||
CID10,
|
||||
CID11,
|
||||
CID12,
|
||||
CID13,
|
||||
CID14,
|
||||
CID15,
|
||||
CID_MAX
|
||||
};
|
||||
|
||||
enum msm_ispif_csid {
|
||||
CSID0,
|
||||
CSID1,
|
||||
CSID2,
|
||||
CSID3,
|
||||
CSID_MAX
|
||||
};
|
||||
|
||||
struct msm_ispif_params_entry {
|
||||
enum msm_ispif_vfe_intf vfe_intf;
|
||||
enum msm_ispif_intftype intftype;
|
||||
int num_cids;
|
||||
enum msm_ispif_cid cids[3];
|
||||
enum msm_ispif_csid csid;
|
||||
int crop_enable;
|
||||
uint16_t crop_start_pixel;
|
||||
uint16_t crop_end_pixel;
|
||||
};
|
||||
|
||||
struct msm_ispif_param_data {
|
||||
uint32_t num;
|
||||
struct msm_ispif_params_entry entries[MAX_PARAM_ENTRIES];
|
||||
};
|
||||
|
||||
struct msm_isp_info {
|
||||
uint32_t max_resolution;
|
||||
uint32_t id;
|
||||
uint32_t ver;
|
||||
};
|
||||
|
||||
struct msm_ispif_vfe_info {
|
||||
int num_vfe;
|
||||
struct msm_isp_info info[VFE_MAX];
|
||||
};
|
||||
|
||||
enum ispif_cfg_type_t {
|
||||
ISPIF_CLK_ENABLE,
|
||||
ISPIF_CLK_DISABLE,
|
||||
ISPIF_INIT,
|
||||
ISPIF_CFG,
|
||||
ISPIF_START_FRAME_BOUNDARY,
|
||||
ISPIF_RESTART_FRAME_BOUNDARY,
|
||||
ISPIF_STOP_FRAME_BOUNDARY,
|
||||
ISPIF_STOP_IMMEDIATELY,
|
||||
ISPIF_RELEASE,
|
||||
ISPIF_ENABLE_REG_DUMP,
|
||||
ISPIF_SET_VFE_INFO,
|
||||
};
|
||||
|
||||
struct ispif_cfg_data {
|
||||
enum ispif_cfg_type_t cfg_type;
|
||||
union {
|
||||
int reg_dump; /* ISPIF_ENABLE_REG_DUMP */
|
||||
uint32_t csid_version; /* ISPIF_INIT */
|
||||
struct msm_ispif_vfe_info vfe_info; /* ISPIF_SET_VFE_INFO */
|
||||
struct msm_ispif_param_data params; /* CFG, START, STOP */
|
||||
};
|
||||
};
|
||||
|
||||
#define VIDIOC_MSM_ISPIF_CFG \
|
||||
_IOWR('V', BASE_VIDIOC_PRIVATE, struct ispif_cfg_data)
|
||||
|
||||
#endif /* MSM_CAM_ISPIF_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import json
|
||||
import signal
|
||||
import subprocess
|
||||
import time
|
||||
from PIL import Image
|
||||
from common.basedir import BASEDIR
|
||||
from common.params import Params
|
||||
from selfdrive.camerad.snapshot.visionipc import VisionIPC
|
||||
|
||||
with open(BASEDIR + "/selfdrive/controls/lib/alerts_offroad.json") as json_file:
|
||||
OFFROAD_ALERTS = json.load(json_file)
|
||||
|
||||
|
||||
def jpeg_write(fn, dat):
|
||||
img = Image.fromarray(dat)
|
||||
img.save(fn, "JPEG")
|
||||
|
||||
|
||||
def snapshot():
|
||||
params = Params()
|
||||
front_camera_allowed = int(params.get("RecordFront"))
|
||||
|
||||
params.put("IsTakingSnapshot", "1")
|
||||
params.put("Offroad_IsTakingSnapshot", json.dumps(OFFROAD_ALERTS["Offroad_IsTakingSnapshot"]))
|
||||
time.sleep(2.0) # Give thermald time to read the param, or if just started give camerad time to start
|
||||
|
||||
# Check if camerad is already started
|
||||
ps = subprocess.Popen("ps | grep camerad", shell=True, stdout=subprocess.PIPE)
|
||||
ret = list(filter(lambda x: 'grep ' not in x, ps.communicate()[0].decode('utf-8').strip().split("\n")))
|
||||
if len(ret) > 0:
|
||||
params.put("IsTakingSnapshot", "0")
|
||||
params.delete("Offroad_IsTakingSnapshot")
|
||||
return None
|
||||
|
||||
proc = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad"))
|
||||
time.sleep(3.0)
|
||||
|
||||
ret = None
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 5.0:
|
||||
try:
|
||||
ipc = VisionIPC()
|
||||
pic = ipc.get()
|
||||
del ipc
|
||||
|
||||
if front_camera_allowed:
|
||||
ipc_front = VisionIPC(front=True)
|
||||
fpic = ipc_front.get()
|
||||
del ipc_front
|
||||
else:
|
||||
fpic = None
|
||||
|
||||
ret = pic, fpic
|
||||
break
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
|
||||
proc.send_signal(signal.SIGINT)
|
||||
proc.communicate()
|
||||
|
||||
params.put("IsTakingSnapshot", "0")
|
||||
params.delete("Offroad_IsTakingSnapshot")
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pic, fpic = snapshot()
|
||||
print(pic.shape)
|
||||
jpeg_write("/tmp/back.jpg", pic)
|
||||
jpeg_write("/tmp/front.jpg", fpic)
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
from cffi import FFI
|
||||
|
||||
import numpy as np
|
||||
|
||||
gf_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
ffi = FFI()
|
||||
ffi.cdef("""
|
||||
|
||||
typedef enum VisionStreamType {
|
||||
VISION_STREAM_RGB_BACK,
|
||||
VISION_STREAM_RGB_FRONT,
|
||||
VISION_STREAM_YUV,
|
||||
VISION_STREAM_YUV_FRONT,
|
||||
VISION_STREAM_MAX,
|
||||
} VisionStreamType;
|
||||
|
||||
typedef struct VisionUIInfo {
|
||||
int big_box_x, big_box_y;
|
||||
int big_box_width, big_box_height;
|
||||
int transformed_width, transformed_height;
|
||||
|
||||
int front_box_x, front_box_y;
|
||||
int front_box_width, front_box_height;
|
||||
} VisionUIInfo;
|
||||
|
||||
typedef struct VisionStreamBufs {
|
||||
VisionStreamType type;
|
||||
|
||||
int width, height, stride;
|
||||
size_t buf_len;
|
||||
|
||||
union {
|
||||
VisionUIInfo ui_info;
|
||||
} buf_info;
|
||||
} VisionStreamBufs;
|
||||
|
||||
typedef struct VIPCBuf {
|
||||
int fd;
|
||||
size_t len;
|
||||
void* addr;
|
||||
} VIPCBuf;
|
||||
|
||||
typedef struct VIPCBufExtra {
|
||||
// only for yuv
|
||||
uint32_t frame_id;
|
||||
uint64_t timestamp_eof;
|
||||
} VIPCBufExtra;
|
||||
|
||||
typedef struct VisionStream {
|
||||
int ipc_fd;
|
||||
int last_idx;
|
||||
int last_type;
|
||||
int num_bufs;
|
||||
VisionStreamBufs bufs_info;
|
||||
VIPCBuf *bufs;
|
||||
} VisionStream;
|
||||
|
||||
int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, VisionStreamBufs *out_bufs_info);
|
||||
VIPCBuf* visionstream_get(VisionStream *s, VIPCBufExtra *out_extra);
|
||||
void visionstream_destroy(VisionStream *s);
|
||||
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
class VisionIPCError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class VisionIPC():
|
||||
def __init__(self, front=False):
|
||||
self.clib = ffi.dlopen(os.path.join(gf_dir, "libvisionipc.so"))
|
||||
|
||||
self.s = ffi.new("VisionStream*")
|
||||
self.buf_info = ffi.new("VisionStreamBufs*")
|
||||
|
||||
err = self.clib.visionstream_init(self.s, self.clib.VISION_STREAM_RGB_FRONT if front else self.clib.VISION_STREAM_RGB_BACK, True, self.buf_info)
|
||||
|
||||
if err != 0:
|
||||
self.clib.visionstream_destroy(self.s)
|
||||
raise VisionIPCError
|
||||
|
||||
def __del__(self):
|
||||
self.clib.visionstream_destroy(self.s)
|
||||
|
||||
def get(self):
|
||||
buf = self.clib.visionstream_get(self.s, ffi.NULL)
|
||||
pbuf = ffi.buffer(buf.addr, buf.len)
|
||||
ret = np.frombuffer(pbuf, dtype=np.uint8).reshape((-1, self.buf_info.stride//3, 3))
|
||||
return ret[:self.buf_info.height, :self.buf_info.width, [2,1,0]]
|
|
@ -0,0 +1,48 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "camera_qcom.h"
|
||||
|
||||
bool do_exit = false;
|
||||
|
||||
void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func,
|
||||
const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void set_thread_name(const char* name) {
|
||||
}
|
||||
|
||||
// tbuffers
|
||||
|
||||
void tbuffer_init2(TBuffer *tb, int num_bufs, const char* name,
|
||||
void (*release_cb)(void* c, int idx),
|
||||
void* cb_cookie) {
|
||||
printf("tbuffer_init2\n");
|
||||
}
|
||||
|
||||
void tbuffer_dispatch(TBuffer *tb, int idx) {
|
||||
printf("tbuffer_dispatch\n");
|
||||
}
|
||||
|
||||
void tbuffer_stop(TBuffer *tb) {
|
||||
printf("tbuffer_stop\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
DualCameraState s;
|
||||
cameras_init(&s);
|
||||
VisionBuf camera_bufs_rear[0x10] = {0};
|
||||
VisionBuf camera_bufs_focus[0x10] = {0};
|
||||
VisionBuf camera_bufs_stats[0x10] = {0};
|
||||
VisionBuf camera_bufs_front[0x10] = {0};
|
||||
cameras_open(&s,
|
||||
camera_bufs_rear, camera_bufs_focus,
|
||||
camera_bufs_stats, camera_bufs_front);
|
||||
cameras_close(&s);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
gcc -DQCOM -I ~/one -I ~/one/selfdrive -I ../../include \
|
||||
-I ~/one/phonelibs/android_system_core/include -I ~/one/phonelibs/opencl/include \
|
||||
-I ~/one/selfdrive/visiond/cameras \
|
||||
test.c ../../cameras/camera_qcom.c \
|
||||
-l:libczmq.a -l:libzmq.a -lgnustl_shared -lm -llog -lcutils \
|
||||
-l:libcapn.a -l:libcapnp.a -l:libkj.a \
|
||||
~/one/cereal/gen/c/log.capnp.o
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python3
|
||||
import time
|
||||
import numpy as np
|
||||
import cereal.messaging as messaging
|
||||
from PIL import ImageFont, ImageDraw, Image
|
||||
|
||||
font = ImageFont.truetype("arial", size=72)
|
||||
def get_frame(idx):
|
||||
img = np.zeros((874, 1164, 3), np.uint8)
|
||||
img[100:400, 100:100+(idx%10)*100] = 255
|
||||
|
||||
# big number
|
||||
im2 = Image.new("RGB", (200,200))
|
||||
draw = ImageDraw.Draw(im2)
|
||||
draw.text((10, 100), "%02d" % idx, font=font)
|
||||
img[400:600, 400:600] = np.array(im2.getdata()).reshape((200,200,3))
|
||||
return img.tostring()
|
||||
|
||||
if __name__ == "__main__":
|
||||
from common.realtime import Ratekeeper
|
||||
rk = Ratekeeper(20)
|
||||
|
||||
pm = messaging.PubMaster(['frame'])
|
||||
frm = [get_frame(x) for x in range(30)]
|
||||
idx = 0
|
||||
while 1:
|
||||
print("send %d" % idx)
|
||||
dat = messaging.new_message()
|
||||
dat.init('frame')
|
||||
dat.valid = True
|
||||
dat.frame = {
|
||||
"frameId": idx,
|
||||
"image": frm[idx%len(frm)],
|
||||
}
|
||||
pm.send('frame', dat)
|
||||
|
||||
idx += 1
|
||||
rk.keep_time()
|
||||
#time.sleep(1.0)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
cd ..
|
||||
while :; do
|
||||
./camerad &
|
||||
pid="$!"
|
||||
sleep 2
|
||||
kill -2 $pid
|
||||
wait $pid
|
||||
done
|
|
@ -0,0 +1,57 @@
|
|||
CC = clang
|
||||
CXX = clang++
|
||||
|
||||
PHONELIBS = ../../../../phonelibs
|
||||
|
||||
WARN_FLAGS = -Werror=implicit-function-declaration \
|
||||
-Werror=incompatible-pointer-types \
|
||||
-Werror=int-conversion \
|
||||
-Werror=return-type \
|
||||
-Werror=format-extra-args \
|
||||
-Wno-deprecated-declarations
|
||||
|
||||
CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
|
||||
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
OPENCL_LIBS = -framework OpenCL
|
||||
else
|
||||
OPENCL_FLAGS = -I$(PHONELIBS)/opencl/include
|
||||
OPENCL_LIBS = -L/system/vendor/lib64 -lgsl -lCB -lOpenCL
|
||||
endif
|
||||
|
||||
OBJS += yuv_bench.o \
|
||||
../../../common/util.o \
|
||||
../../clutil.o
|
||||
|
||||
OUTPUT = yuv
|
||||
|
||||
.PHONY: all
|
||||
all: $(OUTPUT)
|
||||
|
||||
$(OUTPUT): $(OBJS)
|
||||
@echo "[ LINK ] $@"
|
||||
$(CXX) -fPIC -o '$@' $^ \
|
||||
-L/usr/lib \
|
||||
$(OPENCL_LIBS)
|
||||
|
||||
|
||||
%.o: %.cc
|
||||
@echo "[ CXX ] $@"
|
||||
$(CXX) $(CXXFLAGS) -MMD \
|
||||
-I../.. -I../../.. -I ../../../.. \
|
||||
$(OPENCL_FLAGS) \
|
||||
-c -o '$@' '$<'
|
||||
|
||||
|
||||
%.o: %.c
|
||||
@echo "[ CC ] $@"
|
||||
$(CC) $(CFLAGS) -MMD \
|
||||
-I../.. -I../../.. -I ../../../.. \
|
||||
$(OPENCL_FLAGS) \
|
||||
-c -o '$@' '$<'
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(OUTPUT) $(OBJS) $(DEPS)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import numpy as np
|
||||
import cv2
|
||||
|
||||
# img_bgr = np.zeros((874, 1164, 3), dtype=np.uint8)
|
||||
# for y in range(874):
|
||||
# for k in range(1164*3):
|
||||
# img_bgr[y, k//3, k%3] = k ^ y
|
||||
|
||||
# cv2.imwrite("img_rgb.png", img_bgr)
|
||||
|
||||
|
||||
cl = np.fromstring(open("out_cl.bin", "rb").read(), dtype=np.uint8)
|
||||
|
||||
cl_r = cl.reshape(874 * 3 // 2, -1)
|
||||
|
||||
cv2.imwrite("out_y.png", cl_r[:874])
|
||||
|
||||
cl_bgr = cv2.cvtColor(cl_r, cv2.COLOR_YUV2BGR_I420)
|
||||
cv2.imwrite("out_cl.png", cl_bgr)
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
#define PIX_PER_WI_X 1
|
||||
#define PIX_PER_WI_Y 1
|
||||
|
||||
#define scn 3
|
||||
#define bidx 2
|
||||
#define uidx 0
|
||||
|
||||
#define R_COMP x
|
||||
#define G_COMP y
|
||||
#define B_COMP z
|
||||
|
||||
__constant float c_RGB2YUVCoeffs_420[8] = { 0.256999969f, 0.50399971f, 0.09799957f, -0.1479988098f, -0.2909994125f,
|
||||
0.438999176f, -0.3679990768f, -0.0709991455f };
|
||||
|
||||
__kernel void RGB2YUV_YV12_IYUV(__global const uchar* srcptr, int src_step, int src_offset,
|
||||
__global uchar* dstptr, int dst_step, int dst_offset,
|
||||
int rows, int cols)
|
||||
{
|
||||
int x = get_global_id(0) * PIX_PER_WI_X;
|
||||
int y = get_global_id(1) * PIX_PER_WI_Y;
|
||||
|
||||
if (x < cols/2)
|
||||
{
|
||||
int src_index = mad24(y << 1, src_step, mad24(x << 1, scn, src_offset));
|
||||
int ydst_index = mad24(y << 1, dst_step, (x << 1) + dst_offset);
|
||||
int y_rows = rows / 3 * 2;
|
||||
int vsteps[2] = { cols >> 1, dst_step - (cols >> 1)};
|
||||
__constant float* coeffs = c_RGB2YUVCoeffs_420;
|
||||
|
||||
#pragma unroll
|
||||
for (int cy = 0; cy < PIX_PER_WI_Y; ++cy)
|
||||
{
|
||||
if (y < rows / 3)
|
||||
{
|
||||
__global const uchar* src1 = srcptr + src_index;
|
||||
__global const uchar* src2 = src1 + src_step;
|
||||
__global uchar* ydst1 = dstptr + ydst_index;
|
||||
__global uchar* ydst2 = ydst1 + dst_step;
|
||||
|
||||
__global uchar* udst = dstptr + mad24(y_rows + (y>>1), dst_step, dst_offset + (y%2)*(cols >> 1) + x);
|
||||
__global uchar* vdst = udst + mad24(y_rows >> 2, dst_step, y_rows % 4 ? vsteps[y%2] : 0);
|
||||
|
||||
#if PIX_PER_WI_X == 2
|
||||
int s11 = *((__global const int*) src1);
|
||||
int s12 = *((__global const int*) src1 + 1);
|
||||
int s13 = *((__global const int*) src1 + 2);
|
||||
#if scn == 4
|
||||
int s14 = *((__global const int*) src1 + 3);
|
||||
#endif
|
||||
int s21 = *((__global const int*) src2);
|
||||
int s22 = *((__global const int*) src2 + 1);
|
||||
int s23 = *((__global const int*) src2 + 2);
|
||||
#if scn == 4
|
||||
int s24 = *((__global const int*) src2 + 3);
|
||||
#endif
|
||||
float src_pix1[scn * 4], src_pix2[scn * 4];
|
||||
|
||||
*((float4*) src_pix1) = convert_float4(as_uchar4(s11));
|
||||
*((float4*) src_pix1 + 1) = convert_float4(as_uchar4(s12));
|
||||
*((float4*) src_pix1 + 2) = convert_float4(as_uchar4(s13));
|
||||
#if scn == 4
|
||||
*((float4*) src_pix1 + 3) = convert_float4(as_uchar4(s14));
|
||||
#endif
|
||||
*((float4*) src_pix2) = convert_float4(as_uchar4(s21));
|
||||
*((float4*) src_pix2 + 1) = convert_float4(as_uchar4(s22));
|
||||
*((float4*) src_pix2 + 2) = convert_float4(as_uchar4(s23));
|
||||
#if scn == 4
|
||||
*((float4*) src_pix2 + 3) = convert_float4(as_uchar4(s24));
|
||||
#endif
|
||||
uchar4 y1, y2;
|
||||
y1.x = convert_uchar_sat(fma(coeffs[0], src_pix1[ 2-bidx], fma(coeffs[1], src_pix1[ 1], fma(coeffs[2], src_pix1[ bidx], 16.5f))));
|
||||
y1.y = convert_uchar_sat(fma(coeffs[0], src_pix1[ scn+2-bidx], fma(coeffs[1], src_pix1[ scn+1], fma(coeffs[2], src_pix1[ scn+bidx], 16.5f))));
|
||||
y1.z = convert_uchar_sat(fma(coeffs[0], src_pix1[2*scn+2-bidx], fma(coeffs[1], src_pix1[2*scn+1], fma(coeffs[2], src_pix1[2*scn+bidx], 16.5f))));
|
||||
y1.w = convert_uchar_sat(fma(coeffs[0], src_pix1[3*scn+2-bidx], fma(coeffs[1], src_pix1[3*scn+1], fma(coeffs[2], src_pix1[3*scn+bidx], 16.5f))));
|
||||
y2.x = convert_uchar_sat(fma(coeffs[0], src_pix2[ 2-bidx], fma(coeffs[1], src_pix2[ 1], fma(coeffs[2], src_pix2[ bidx], 16.5f))));
|
||||
y2.y = convert_uchar_sat(fma(coeffs[0], src_pix2[ scn+2-bidx], fma(coeffs[1], src_pix2[ scn+1], fma(coeffs[2], src_pix2[ scn+bidx], 16.5f))));
|
||||
y2.z = convert_uchar_sat(fma(coeffs[0], src_pix2[2*scn+2-bidx], fma(coeffs[1], src_pix2[2*scn+1], fma(coeffs[2], src_pix2[2*scn+bidx], 16.5f))));
|
||||
y2.w = convert_uchar_sat(fma(coeffs[0], src_pix2[3*scn+2-bidx], fma(coeffs[1], src_pix2[3*scn+1], fma(coeffs[2], src_pix2[3*scn+bidx], 16.5f))));
|
||||
|
||||
*((__global int*) ydst1) = as_int(y1);
|
||||
*((__global int*) ydst2) = as_int(y2);
|
||||
|
||||
float uv[4] = { fma(coeffs[3], src_pix1[ 2-bidx], fma(coeffs[4], src_pix1[ 1], fma(coeffs[5], src_pix1[ bidx], 128.5f))),
|
||||
fma(coeffs[5], src_pix1[ 2-bidx], fma(coeffs[6], src_pix1[ 1], fma(coeffs[7], src_pix1[ bidx], 128.5f))),
|
||||
fma(coeffs[3], src_pix1[2*scn+2-bidx], fma(coeffs[4], src_pix1[2*scn+1], fma(coeffs[5], src_pix1[2*scn+bidx], 128.5f))),
|
||||
fma(coeffs[5], src_pix1[2*scn+2-bidx], fma(coeffs[6], src_pix1[2*scn+1], fma(coeffs[7], src_pix1[2*scn+bidx], 128.5f))) };
|
||||
|
||||
udst[0] = convert_uchar_sat(uv[uidx] );
|
||||
vdst[0] = convert_uchar_sat(uv[1 - uidx]);
|
||||
udst[1] = convert_uchar_sat(uv[2 + uidx]);
|
||||
vdst[1] = convert_uchar_sat(uv[3 - uidx]);
|
||||
#else
|
||||
float4 src_pix1 = convert_float4(vload4(0, src1));
|
||||
float4 src_pix2 = convert_float4(vload4(0, src1+scn));
|
||||
float4 src_pix3 = convert_float4(vload4(0, src2));
|
||||
float4 src_pix4 = convert_float4(vload4(0, src2+scn));
|
||||
|
||||
ydst1[0] = convert_uchar_sat(fma(coeffs[0], src_pix1.R_COMP, fma(coeffs[1], src_pix1.G_COMP, fma(coeffs[2], src_pix1.B_COMP, 16.5f))));
|
||||
ydst1[1] = convert_uchar_sat(fma(coeffs[0], src_pix2.R_COMP, fma(coeffs[1], src_pix2.G_COMP, fma(coeffs[2], src_pix2.B_COMP, 16.5f))));
|
||||
ydst2[0] = convert_uchar_sat(fma(coeffs[0], src_pix3.R_COMP, fma(coeffs[1], src_pix3.G_COMP, fma(coeffs[2], src_pix3.B_COMP, 16.5f))));
|
||||
ydst2[1] = convert_uchar_sat(fma(coeffs[0], src_pix4.R_COMP, fma(coeffs[1], src_pix4.G_COMP, fma(coeffs[2], src_pix4.B_COMP, 16.5f))));
|
||||
|
||||
float uv[2] = { fma(coeffs[3], src_pix1.R_COMP, fma(coeffs[4], src_pix1.G_COMP, fma(coeffs[5], src_pix1.B_COMP, 128.5f))),
|
||||
fma(coeffs[5], src_pix1.R_COMP, fma(coeffs[6], src_pix1.G_COMP, fma(coeffs[7], src_pix1.B_COMP, 128.5f))) };
|
||||
|
||||
udst[0] = convert_uchar_sat(uv[uidx] );
|
||||
vdst[0] = convert_uchar_sat(uv[1-uidx]);
|
||||
#endif
|
||||
++y;
|
||||
src_index += 2*src_step;
|
||||
ydst_index += 2*dst_step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
// #include <opencv2/opencv.hpp>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#include "common/util.h"
|
||||
#include "common/timing.h"
|
||||
#include "common/mat.h"
|
||||
#include "clutil.h"
|
||||
|
||||
int main() {
|
||||
|
||||
int rgb_width = 1164;
|
||||
int rgb_height = 874;
|
||||
|
||||
int rgb_stride = rgb_width*3;
|
||||
|
||||
size_t out_size = rgb_width*rgb_height*3/2;
|
||||
|
||||
uint8_t* rgb_buf = (uint8_t*)calloc(1, rgb_width*rgb_height*3);
|
||||
uint8_t* out = (uint8_t*)calloc(1, out_size);
|
||||
|
||||
for (int y=0; y<rgb_height; y++) {
|
||||
for (int k=0; k<rgb_stride; k++) {
|
||||
rgb_buf[y*rgb_stride + k] = k ^ y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// init cl
|
||||
/* Get Platform and Device Info */
|
||||
cl_platform_id platform_id = NULL;
|
||||
cl_uint num_platforms_unused;
|
||||
int err = clGetPlatformIDs(1, &platform_id, &num_platforms_unused);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "cl error: %d\n", err);
|
||||
}
|
||||
assert(err == 0);
|
||||
|
||||
cl_device_id device_id = NULL;
|
||||
cl_uint num_devices_unused;
|
||||
err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id,
|
||||
&num_devices_unused);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "cl error: %d\n", err);
|
||||
}
|
||||
assert(err == 0);
|
||||
|
||||
cl_print_info(platform_id, device_id);
|
||||
printf("\n");
|
||||
|
||||
cl_context context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err);
|
||||
assert(err == 0);
|
||||
|
||||
cl_program prg = cl_create_program_from_file(context, "yuv.cl");
|
||||
|
||||
err = clBuildProgram(prg, 1, &device_id, "", NULL, NULL);
|
||||
if (err != 0) {
|
||||
cl_print_build_errors(prg, device_id);
|
||||
}
|
||||
cl_check_error(err);
|
||||
|
||||
|
||||
cl_kernel krnl = clCreateKernel(prg, "RGB2YUV_YV12_IYUV", &err);
|
||||
assert(err == 0);
|
||||
|
||||
|
||||
cl_mem inbuf_cl = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
rgb_width*rgb_height*3, (void*)rgb_buf, &err);
|
||||
cl_check_error(err);
|
||||
cl_mem out_cl = clCreateBuffer(context, CL_MEM_READ_WRITE, out_size, NULL, &err);
|
||||
cl_check_error(err);
|
||||
|
||||
|
||||
// load into net
|
||||
err = clSetKernelArg(krnl, 0, sizeof(cl_mem), &inbuf_cl); //srcptr
|
||||
assert(err == 0);
|
||||
|
||||
int zero = 0;
|
||||
err = clSetKernelArg(krnl, 1, sizeof(cl_int), &rgb_stride); //src_step
|
||||
assert(err == 0);
|
||||
err = clSetKernelArg(krnl, 2, sizeof(cl_int), &zero); //src_offset
|
||||
assert(err == 0);
|
||||
|
||||
err = clSetKernelArg(krnl, 3, sizeof(cl_mem), &out_cl); //dstptr
|
||||
assert(err == 0);
|
||||
err = clSetKernelArg(krnl, 4, sizeof(cl_int), &rgb_width); //dst_step
|
||||
assert(err == 0);
|
||||
err = clSetKernelArg(krnl, 5, sizeof(cl_int), &zero); //dst_offset
|
||||
assert(err == 0);
|
||||
|
||||
const int rows = rgb_height * 3 / 2;
|
||||
err = clSetKernelArg(krnl, 6, sizeof(cl_int), &rows); //rows
|
||||
assert(err == 0);
|
||||
err = clSetKernelArg(krnl, 7, sizeof(cl_int), &rgb_width); //cols
|
||||
assert(err == 0);
|
||||
|
||||
cl_command_queue q = clCreateCommandQueue(context, device_id, 0, &err);
|
||||
assert(err == 0);
|
||||
const size_t work_size[2] = {rgb_width/2, rows/3};
|
||||
|
||||
err = clEnqueueNDRangeKernel(q, krnl, 2, NULL,
|
||||
(const size_t*)&work_size, NULL, 0, 0, NULL);
|
||||
cl_check_error(err);
|
||||
clFinish(q);
|
||||
|
||||
|
||||
|
||||
double t1 = millis_since_boot();
|
||||
for (int k=0; k<32; k++) {
|
||||
err = clEnqueueNDRangeKernel(q, krnl, 2, NULL,
|
||||
(const size_t*)&work_size, NULL, 0, 0, NULL);
|
||||
cl_check_error(err);
|
||||
}
|
||||
clFinish(q);
|
||||
double t2 = millis_since_boot();
|
||||
printf("t: %.2f\n", (t2-t1)/32.);
|
||||
|
||||
uint8_t* out_ptr = (uint8_t*)clEnqueueMapBuffer(q, out_cl, CL_FALSE,
|
||||
CL_MAP_READ, 0, out_size,
|
||||
0, NULL, NULL, &err);
|
||||
assert(err == 0);
|
||||
clFinish(q);
|
||||
|
||||
|
||||
FILE* of = fopen("out_cl.bin", "wb");
|
||||
fwrite(out_ptr, out_size, 1, of);
|
||||
fclose(of);
|
||||
|
||||
|
||||
// #endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "clutil.h"
|
||||
|
||||
#include "rgb_to_yuv.h"
|
||||
|
||||
void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) {
|
||||
int err = 0;
|
||||
memset(s, 0, sizeof(*s));
|
||||
assert(width % 2 == 0);
|
||||
assert(height % 2 == 0);
|
||||
s->width = width;
|
||||
s->height = height;
|
||||
char args[1024];
|
||||
snprintf(args, sizeof(args),
|
||||
"-cl-fast-relaxed-math -cl-denorms-are-zero "
|
||||
#ifdef CL_DEBUG
|
||||
"-DCL_DEBUG "
|
||||
#endif
|
||||
"-DWIDTH=%d -DHEIGHT=%d -DUV_WIDTH=%d -DUV_HEIGHT=%d -DRGB_STRIDE=%d -DRGB_SIZE=%d",
|
||||
width, height, width/ 2, height / 2, rgb_stride, width * height);
|
||||
cl_program prg = CLU_LOAD_FROM_FILE(ctx, device_id, "transforms/rgb_to_yuv.cl", args);
|
||||
|
||||
s->rgb_to_yuv_krnl = clCreateKernel(prg, "rgb_to_yuv", &err);
|
||||
assert(err == 0);
|
||||
// done with this
|
||||
err = clReleaseProgram(prg);
|
||||
assert(err == 0);
|
||||
}
|
||||
|
||||
void rgb_to_yuv_destroy(RGBToYUVState* s) {
|
||||
int err = 0;
|
||||
err = clReleaseKernel(s->rgb_to_yuv_krnl);
|
||||
assert(err == 0);
|
||||
}
|
||||
|
||||
void rgb_to_yuv_queue(RGBToYUVState* s, cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl) {
|
||||
int err = 0;
|
||||
err = clSetKernelArg(s->rgb_to_yuv_krnl, 0, sizeof(cl_mem), &rgb_cl);
|
||||
assert(err == 0);
|
||||
err = clSetKernelArg(s->rgb_to_yuv_krnl, 1, sizeof(cl_mem), &yuv_cl);
|
||||
assert(err == 0);
|
||||
const size_t work_size[2] = {
|
||||
(size_t)(s->width + (s->width % 4 == 0 ? 0 : (4 - s->width % 4))) / 4,
|
||||
(size_t)(s->height + (s->height % 4 == 0 ? 0 : (4 - s->height % 4))) / 4
|
||||
};
|
||||
cl_event event;
|
||||
err = clEnqueueNDRangeKernel(q, s->rgb_to_yuv_krnl, 2, NULL, &work_size[0], NULL, 0, 0, &event);
|
||||
assert(err == 0);
|
||||
clWaitForEvents(1, &event);
|
||||
clReleaseEvent(event);
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
#define RGB_TO_Y(r, g, b) ((((mul24(b, 13) + mul24(g, 65) + mul24(r, 33)) + 64) >> 7) + 16)
|
||||
#define RGB_TO_U(r, g, b) ((mul24(b, 56) - mul24(g, 37) - mul24(r, 19) + 0x8080) >> 8)
|
||||
#define RGB_TO_V(r, g, b) ((mul24(r, 56) - mul24(g, 47) - mul24(b, 9) + 0x8080) >> 8)
|
||||
#define AVERAGE(x, y, z, w) ((convert_ushort(x) + convert_ushort(y) + convert_ushort(z) + convert_ushort(w) + 1) >> 1)
|
||||
|
||||
inline void convert_2_ys(__global uchar * out_yuv, int yi, const uchar8 rgbs1) {
|
||||
uchar2 yy = (uchar2)(
|
||||
RGB_TO_Y(rgbs1.s2, rgbs1.s1, rgbs1.s0),
|
||||
RGB_TO_Y(rgbs1.s5, rgbs1.s4, rgbs1.s3)
|
||||
);
|
||||
#ifdef CL_DEBUG
|
||||
if(yi >= RGB_SIZE)
|
||||
printf("Y vector2 overflow, %d > %d\n", yi, RGB_SIZE);
|
||||
#endif
|
||||
vstore2(yy, 0, out_yuv + yi);
|
||||
}
|
||||
|
||||
inline void convert_4_ys(__global uchar * out_yuv, int yi, const uchar8 rgbs1, const uchar8 rgbs3) {
|
||||
const uchar4 yy = (uchar4)(
|
||||
RGB_TO_Y(rgbs1.s2, rgbs1.s1, rgbs1.s0),
|
||||
RGB_TO_Y(rgbs1.s5, rgbs1.s4, rgbs1.s3),
|
||||
RGB_TO_Y(rgbs3.s0, rgbs1.s7, rgbs1.s6),
|
||||
RGB_TO_Y(rgbs3.s3, rgbs3.s2, rgbs3.s1)
|
||||
);
|
||||
#ifdef CL_DEBUG
|
||||
if(yi > RGB_SIZE - 4)
|
||||
printf("Y vector4 overflow, %d > %d\n", yi, RGB_SIZE - 4);
|
||||
#endif
|
||||
vstore4(yy, 0, out_yuv + yi);
|
||||
}
|
||||
|
||||
inline void convert_uv(__global uchar * out_yuv, int ui, int vi,
|
||||
const uchar8 rgbs1, const uchar8 rgbs2) {
|
||||
// U & V: average of 2x2 pixels square
|
||||
const short ab = AVERAGE(rgbs1.s0, rgbs1.s3, rgbs2.s0, rgbs2.s3);
|
||||
const short ag = AVERAGE(rgbs1.s1, rgbs1.s4, rgbs2.s1, rgbs2.s4);
|
||||
const short ar = AVERAGE(rgbs1.s2, rgbs1.s5, rgbs2.s2, rgbs2.s5);
|
||||
#ifdef CL_DEBUG
|
||||
if(ui >= RGB_SIZE + RGB_SIZE / 4)
|
||||
printf("U overflow, %d >= %d\n", ui, RGB_SIZE + RGB_SIZE / 4);
|
||||
if(vi >= RGB_SIZE + RGB_SIZE / 2)
|
||||
printf("V overflow, %d >= %d\n", vi, RGB_SIZE + RGB_SIZE / 2);
|
||||
#endif
|
||||
out_yuv[ui] = RGB_TO_U(ar, ag, ab);
|
||||
out_yuv[vi] = RGB_TO_V(ar, ag, ab);
|
||||
}
|
||||
|
||||
inline void convert_2_uvs(__global uchar * out_yuv, int ui, int vi,
|
||||
const uchar8 rgbs1, const uchar8 rgbs2, const uchar8 rgbs3, const uchar8 rgbs4) {
|
||||
// U & V: average of 2x2 pixels square
|
||||
const short ab1 = AVERAGE(rgbs1.s0, rgbs1.s3, rgbs2.s0, rgbs2.s3);
|
||||
const short ag1 = AVERAGE(rgbs1.s1, rgbs1.s4, rgbs2.s1, rgbs2.s4);
|
||||
const short ar1 = AVERAGE(rgbs1.s2, rgbs1.s5, rgbs2.s2, rgbs2.s5);
|
||||
const short ab2 = AVERAGE(rgbs1.s6, rgbs3.s1, rgbs2.s6, rgbs4.s1);
|
||||
const short ag2 = AVERAGE(rgbs1.s7, rgbs3.s2, rgbs2.s7, rgbs4.s2);
|
||||
const short ar2 = AVERAGE(rgbs3.s0, rgbs3.s3, rgbs4.s0, rgbs4.s3);
|
||||
uchar2 u2 = (uchar2)(
|
||||
RGB_TO_U(ar1, ag1, ab1),
|
||||
RGB_TO_U(ar2, ag2, ab2)
|
||||
);
|
||||
uchar2 v2 = (uchar2)(
|
||||
RGB_TO_V(ar1, ag1, ab1),
|
||||
RGB_TO_V(ar2, ag2, ab2)
|
||||
);
|
||||
#ifdef CL_DEBUG1
|
||||
if(ui > RGB_SIZE + RGB_SIZE / 4 - 2)
|
||||
printf("U 2 overflow, %d >= %d\n", ui, RGB_SIZE + RGB_SIZE / 4 - 2);
|
||||
if(vi > RGB_SIZE + RGB_SIZE / 2 - 2)
|
||||
printf("V 2 overflow, %d >= %d\n", vi, RGB_SIZE + RGB_SIZE / 2 - 2);
|
||||
#endif
|
||||
vstore2(u2, 0, out_yuv + ui);
|
||||
vstore2(v2, 0, out_yuv + vi);
|
||||
}
|
||||
|
||||
__kernel void rgb_to_yuv(__global uchar const * const rgb,
|
||||
__global uchar * out_yuv)
|
||||
{
|
||||
const int dx = get_global_id(0);
|
||||
const int dy = get_global_id(1);
|
||||
const int col = mul24(dx, 4); // Current column in rgb image
|
||||
const int row = mul24(dy, 4); // Current row in rgb image
|
||||
const int bgri_start = mad24(row, RGB_STRIDE, mul24(col, 3)); // Start offset of rgb data being converted
|
||||
const int yi_start = mad24(row, WIDTH, col); // Start offset in the target yuv buffer
|
||||
int ui = mad24(row / 2, UV_WIDTH, RGB_SIZE + col / 2);
|
||||
int vi = mad24(row / 2 , UV_WIDTH, RGB_SIZE + UV_WIDTH * UV_HEIGHT + col / 2);
|
||||
int num_col = min(WIDTH - col, 4);
|
||||
int num_row = min(HEIGHT - row, 4);
|
||||
if(num_row == 4) {
|
||||
const uchar8 rgbs0_0 = vload8(0, rgb + bgri_start);
|
||||
const uchar8 rgbs0_1 = vload8(0, rgb + bgri_start + 8);
|
||||
const uchar8 rgbs1_0 = vload8(0, rgb + bgri_start + RGB_STRIDE);
|
||||
const uchar8 rgbs1_1 = vload8(0, rgb + bgri_start + RGB_STRIDE + 8);
|
||||
const uchar8 rgbs2_0 = vload8(0, rgb + bgri_start + RGB_STRIDE * 2);
|
||||
const uchar8 rgbs2_1 = vload8(0, rgb + bgri_start + RGB_STRIDE * 2 + 8);
|
||||
const uchar8 rgbs3_0 = vload8(0, rgb + bgri_start + RGB_STRIDE * 3);
|
||||
const uchar8 rgbs3_1 = vload8(0, rgb + bgri_start + RGB_STRIDE * 3 + 8);
|
||||
if(num_col == 4) {
|
||||
convert_4_ys(out_yuv, yi_start, rgbs0_0, rgbs0_1);
|
||||
convert_4_ys(out_yuv, yi_start + WIDTH, rgbs1_0, rgbs1_1);
|
||||
convert_4_ys(out_yuv, yi_start + WIDTH * 2, rgbs2_0, rgbs2_1);
|
||||
convert_4_ys(out_yuv, yi_start + WIDTH * 3, rgbs3_0, rgbs3_1);
|
||||
convert_2_uvs(out_yuv, ui, vi, rgbs0_0, rgbs1_0, rgbs0_1, rgbs1_1);
|
||||
convert_2_uvs(out_yuv, ui + UV_WIDTH, vi + UV_WIDTH, rgbs2_0, rgbs3_0, rgbs2_1, rgbs3_1);
|
||||
} else if(num_col == 2) {
|
||||
convert_2_ys(out_yuv, yi_start, rgbs0_0);
|
||||
convert_2_ys(out_yuv, yi_start + WIDTH, rgbs1_0);
|
||||
convert_2_ys(out_yuv, yi_start + WIDTH * 2, rgbs2_0);
|
||||
convert_2_ys(out_yuv, yi_start + WIDTH * 3, rgbs3_0);
|
||||
convert_uv(out_yuv, ui, vi, rgbs0_0, rgbs1_0);
|
||||
convert_uv(out_yuv, ui + UV_WIDTH, vi + UV_WIDTH, rgbs2_0, rgbs3_0);
|
||||
}
|
||||
} else {
|
||||
const uchar8 rgbs0_0 = vload8(0, rgb + bgri_start);
|
||||
const uchar8 rgbs0_1 = vload8(0, rgb + bgri_start + 8);
|
||||
const uchar8 rgbs1_0 = vload8(0, rgb + bgri_start + RGB_STRIDE);
|
||||
const uchar8 rgbs1_1 = vload8(0, rgb + bgri_start + RGB_STRIDE + 8);
|
||||
if(num_col == 4) {
|
||||
convert_4_ys(out_yuv, yi_start, rgbs0_0, rgbs0_1);
|
||||
convert_4_ys(out_yuv, yi_start + WIDTH, rgbs1_0, rgbs1_1);
|
||||
convert_2_uvs(out_yuv, ui, vi, rgbs0_0, rgbs1_0, rgbs0_1, rgbs1_1);
|
||||
} else if(num_col == 2) {
|
||||
convert_2_ys(out_yuv, yi_start, rgbs0_0);
|
||||
convert_2_ys(out_yuv, yi_start + WIDTH, rgbs1_0);
|
||||
convert_uv(out_yuv, ui, vi, rgbs0_0, rgbs1_0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef RGB_TO_YUV_H
|
||||
#define RGB_TO_YUV_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int width, height;
|
||||
cl_kernel rgb_to_yuv_krnl;
|
||||
} RGBToYUVState;
|
||||
|
||||
void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride);
|
||||
|
||||
void rgb_to_yuv_destroy(RGBToYUVState* s);
|
||||
|
||||
void rgb_to_yuv_queue(RGBToYUVState* s, cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RGB_TO_YUV_H
|
|
@ -0,0 +1,201 @@
|
|||
#include <memory.h>
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <thread>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#define MAXE 0
|
||||
#include <unistd.h>
|
||||
|
||||
#else
|
||||
// The libyuv implementation on ARM is slightly different than on x86
|
||||
// Our implementation matches the ARM version, so accept errors of 1
|
||||
#define MAXE 1
|
||||
|
||||
#endif
|
||||
|
||||
#include <libyuv.h>
|
||||
|
||||
#include <CL/cl.h>
|
||||
|
||||
#include "clutil.h"
|
||||
#include "rgb_to_yuv.h"
|
||||
|
||||
|
||||
static inline double millis_since_boot() {
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_BOOTTIME, &t);
|
||||
return t.tv_sec * 1000.0 + t.tv_nsec * 1e-6;
|
||||
}
|
||||
|
||||
void cl_init(cl_device_id &device_id, cl_context &context) {
|
||||
int err;
|
||||
cl_platform_id platform_id = NULL;
|
||||
cl_uint num_devices;
|
||||
cl_uint num_platforms;
|
||||
|
||||
err = clGetPlatformIDs(1, &platform_id, &num_platforms);
|
||||
err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1,
|
||||
&device_id, &num_devices);
|
||||
cl_print_info(platform_id, device_id);
|
||||
context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err);
|
||||
}
|
||||
|
||||
|
||||
bool compare_results(uint8_t *a, uint8_t *b, int len, int stride, int width, int height, uint8_t *rgb) {
|
||||
int min_diff = 0., max_diff = 0., max_e = 0.;
|
||||
int e1 = 0, e0 = 0;
|
||||
int e0y = 0, e0u = 0, e0v = 0, e1y = 0, e1u = 0, e1v = 0;
|
||||
int max_e_i = 0;
|
||||
for (int i = 0;i < len;i++) {
|
||||
int e = ((int)a[i]) - ((int)b[i]);
|
||||
if(e < min_diff) {
|
||||
min_diff = e;
|
||||
}
|
||||
if(e > max_diff) {
|
||||
max_diff = e;
|
||||
}
|
||||
int e_abs = std::abs(e);
|
||||
if(e_abs > max_e) {
|
||||
max_e = e_abs;
|
||||
max_e_i = i;
|
||||
}
|
||||
if(e_abs < 1) {
|
||||
e0++;
|
||||
if(i < stride * height)
|
||||
e0y++;
|
||||
else if(i < stride * height + stride * height / 4)
|
||||
e0u++;
|
||||
else
|
||||
e0v++;
|
||||
} else {
|
||||
e1++;
|
||||
if(i < stride * height)
|
||||
e1y++;
|
||||
else if(i < stride * height + stride * height / 4)
|
||||
e1u++;
|
||||
else
|
||||
e1v++;
|
||||
}
|
||||
}
|
||||
//printf("max diff : %d, min diff : %d, e < 1: %d, e >= 1: %d\n", max_diff, min_diff, e0, e1);
|
||||
//printf("Y: e < 1: %d, e >= 1: %d, U: e < 1: %d, e >= 1: %d, V: e < 1: %d, e >= 1: %d\n", e0y, e1y, e0u, e1u, e0v, e1v);
|
||||
if(max_e <= MAXE) {
|
||||
return true;
|
||||
}
|
||||
int row = max_e_i / stride;
|
||||
if(row < height) {
|
||||
printf("max error is Y: %d = (libyuv: %u - cl: %u), row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], row, max_e_i % stride);
|
||||
} else if(row >= height && row < (height + height / 4)) {
|
||||
printf("max error is U: %d = %u - %u, row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], (row - height) / 2, max_e_i % stride / 2);
|
||||
} else {
|
||||
printf("max error is V: %d = %u - %u, row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], (row - height - height / 4) / 2, max_e_i % stride / 2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
srand(1337);
|
||||
|
||||
clu_init();
|
||||
cl_device_id device_id;
|
||||
cl_context context;
|
||||
cl_init(device_id, context) ;
|
||||
|
||||
int err;
|
||||
const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0};
|
||||
cl_command_queue q = clCreateCommandQueueWithProperties(context, device_id, props, &err);
|
||||
if(err != 0) {
|
||||
std::cout << "clCreateCommandQueueWithProperties error: " << err << std::endl;
|
||||
}
|
||||
|
||||
int width = 1164;
|
||||
int height = 874;
|
||||
|
||||
int opt = 0;
|
||||
while ((opt = getopt(argc, argv, "f")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'f':
|
||||
std::cout << "Using front camera dimensions" << std::endl;
|
||||
int width = 1152;
|
||||
int height = 846;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Width: " << width << " Height: " << height << std::endl;
|
||||
uint8_t *rgb_frame = new uint8_t[width * height * 3];
|
||||
|
||||
|
||||
RGBToYUVState rgb_to_yuv_state;
|
||||
rgb_to_yuv_init(&rgb_to_yuv_state, context, device_id, width, height, width * 3);
|
||||
|
||||
int frame_yuv_buf_size = width * height * 3 / 2;
|
||||
cl_mem yuv_cl = clCreateBuffer(context, CL_MEM_READ_WRITE, frame_yuv_buf_size, (void*)NULL, &err);
|
||||
uint8_t *frame_yuv_buf = new uint8_t[frame_yuv_buf_size];
|
||||
uint8_t *frame_yuv_ptr_y = frame_yuv_buf;
|
||||
uint8_t *frame_yuv_ptr_u = frame_yuv_buf + (width * height);
|
||||
uint8_t *frame_yuv_ptr_v = frame_yuv_ptr_u + ((width/2) * (height/2));
|
||||
|
||||
cl_mem rgb_cl = clCreateBuffer(context, CL_MEM_READ_WRITE, width * height * 3, (void*)NULL, &err);
|
||||
int mismatched = 0;
|
||||
int counter = 0;
|
||||
srand (time(NULL));
|
||||
|
||||
for (int i = 0; i < 100; i++){
|
||||
for (int i = 0; i < width * height * 3; i++){
|
||||
rgb_frame[i] = (uint8_t)rand();
|
||||
}
|
||||
|
||||
double t1 = millis_since_boot();
|
||||
libyuv::RGB24ToI420((uint8_t*)rgb_frame, width * 3,
|
||||
frame_yuv_ptr_y, width,
|
||||
frame_yuv_ptr_u, width/2,
|
||||
frame_yuv_ptr_v, width/2,
|
||||
width, height);
|
||||
double t2 = millis_since_boot();
|
||||
//printf("Libyuv: rgb to yuv: %.2fms\n", t2-t1);
|
||||
|
||||
clEnqueueWriteBuffer(q, rgb_cl, CL_TRUE, 0, width * height * 3, (void *)rgb_frame, 0, NULL, NULL);
|
||||
t1 = millis_since_boot();
|
||||
rgb_to_yuv_queue(&rgb_to_yuv_state, q, rgb_cl, yuv_cl);
|
||||
t2 = millis_since_boot();
|
||||
|
||||
//printf("OpenCL: rgb to yuv: %.2fms\n", t2-t1);
|
||||
uint8_t *yyy = (uint8_t *)clEnqueueMapBuffer(q, yuv_cl, CL_TRUE,
|
||||
CL_MAP_READ, 0, frame_yuv_buf_size,
|
||||
0, NULL, NULL, &err);
|
||||
if(!compare_results(frame_yuv_ptr_y, yyy, frame_yuv_buf_size, width, width, height, (uint8_t*)rgb_frame))
|
||||
mismatched++;
|
||||
clEnqueueUnmapMemObject(q, yuv_cl, yyy, 0, NULL, NULL);
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
if(counter++ % 100 == 0)
|
||||
printf("Matched: %d, Mismatched: %d\n", counter - mismatched, mismatched);
|
||||
|
||||
}
|
||||
printf("Matched: %d, Mismatched: %d\n", counter - mismatched, mismatched);
|
||||
|
||||
delete[] frame_yuv_buf;
|
||||
rgb_to_yuv_destroy(&rgb_to_yuv_state);
|
||||
clReleaseContext(context);
|
||||
delete[] rgb_frame;
|
||||
|
||||
if (mismatched == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
Loading…
Reference in New Issue