hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _RKAIQ_RAW_PROTOCOL_H__
#define _RKAIQ_RAW_PROTOCOL_H__
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include "logger/log.h"
#include "rkaiq_cmdid.h"
#include "rkaiq_common.h"
 
typedef enum
{
    CAPTURE_NORMAL = 0,
    CAPTUER_AVERAGE,
} captureMode;
 
typedef enum
{
    VIDEO_APP_OFF = 0x80,
    VIDEO_APP_ON
} videoAppStatus;
 
typedef enum
{
    APP_RUN_STATUS_INIT = -1,
    APP_RUN_STATUS_TUNRING = 0,
    APP_RUN_STATUS_CAPTURE = 1,
    APP_RUN_STATUS_STREAMING = 2,
} appRunStatus;
 
typedef enum
{
    RAW_CAP = 0x00,
    AVALIABLE
} runStaus;
 
#define RAW_FMT_NON_COMPACT (0x0000 << 7)
#define RAW_FMT_COMPACT (0x0001 << 7)
#define RAW_FMT_COMPACT_CHECK (0x0001 << 7)
 
#define RAW_FMT_LINEAR (0x0000 << 4)
#define RAW_FMT_HDR2 (0x0001 << 4)
#define RAW_FMT_HDR3 (0x0002 << 4)
#define RAW_FMT_MODE_CHECK (0x0003 << 4)
 
#define RAW_FMT_ALIGN0 (0x0000 << 0)
#define RAW_FMT_ALIGN64 (0x0001 << 0)
#define RAW_FMT_ALIGN128 (0x0002 << 0)
#define RAW_FMT_ALIGN256 (0x0003 << 0)
#define RAW_FMT_ALIGN512 (0x0004 << 0)
#define RAW_FMT_ALIGN_CHECK (0x000F << 0)
 
#define IS_RAW_FMT_NON_COMPACT(x) (((x) & (RAW_FMT_COMPACT_CHECK)) == (RAW_FMT_NON_COMPACT))
#define IS_RAW_FMT_COMPACT(x) (((x) & (RAW_FMT_COMPACT_CHECK)) == (RAW_FMT_COMPACT))
 
#define IS_RAW_FMT_LINEAR(x) (((x) & (RAW_FMT_MODE_CHECK)) == (RAW_FMT_LINEAR))
#define IS_RAW_FMT_HDR2(x) (((x) & (RAW_FMT_MODE_CHECK)) == (RAW_FMT_HDR2))
#define IS_RAW_FMT_HDR3(x) (((x) & (RAW_FMT_MODE_CHECK)) == (RAW_FMT_HDR3))
 
#define IS_RAW_FMT_ALIGN0(x) (((x) & (RAW_FMT_ALIGN_CHECK)) == (RAW_FMT_ALIGN0))
#define IS_RAW_FMT_ALIGN64(x) (((x) & (RAW_FMT_ALIGN_CHECK)) == (RAW_FMT_ALIGN64))
#define IS_RAW_FMT_ALIGN128(x) (((x) & (RAW_FMT_ALIGN_CHECK)) == (RAW_FMT_ALIGN128))
#define IS_RAW_FMT_ALIGN256(x) (((x) & (RAW_FMT_ALIGN_CHECK)) == (RAW_FMT_ALIGN256))
#define IS_RAW_FMT_ALIGN512(x) (((x) & (RAW_FMT_ALIGN_CHECK)) == (RAW_FMT_ALIGN512))
 
typedef enum
{
    PROC_ID_CAPTURE_RAW_FMT_STATUS = 0x00,
    // NON-Compact
    PROC_ID_CAPTURE_RAW_NON_COMPACT_LINEAR = (RAW_FMT_NON_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN0),
    PROC_ID_CAPTURE_RAW_NON_COMPACT_HDR2 = (RAW_FMT_NON_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN0),
    PROC_ID_CAPTURE_RAW_NON_COMPACT_HDR3 = (RAW_FMT_NON_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN0),
    // Compact and non-align
    PROC_ID_CAPTURE_RAW_COMPACT_LINEAR_ALIGN0 = (RAW_FMT_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN0),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR2_ALIGN0 = (RAW_FMT_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN0),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR3_ALIGN0 = (RAW_FMT_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN0),
    // Compact and align with 64
    PROC_ID_CAPTURE_RAW_COMPACT_LINEAR_ALIGN64 = (RAW_FMT_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN64),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR2_ALIGN64 = (RAW_FMT_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN64),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR3_ALIGN64 = (RAW_FMT_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN64),
    // Compact and align with 128
    PROC_ID_CAPTURE_RAW_COMPACT_LINEAR_ALIGN128 = (RAW_FMT_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN128),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR2_ALIGN128 = (RAW_FMT_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN128),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR3_ALIGN128 = (RAW_FMT_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN128),
    // Compact and align with 256
    PROC_ID_CAPTURE_RAW_COMPACT_LINEAR_ALIGN256 = (RAW_FMT_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN256),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR2_ALIGN256 = (RAW_FMT_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN256),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR3_ALIGN256 = (RAW_FMT_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN256),
    // Compact and align with 512
    PROC_ID_CAPTURE_RAW_COMPACT_LINEAR_ALIGN512 = (RAW_FMT_COMPACT | RAW_FMT_LINEAR | RAW_FMT_ALIGN512),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR2_ALIGN512 = (RAW_FMT_COMPACT | RAW_FMT_HDR2 | RAW_FMT_ALIGN512),
    PROC_ID_CAPTURE_RAW_COMPACT_HDR3_ALIGN512 = (RAW_FMT_COMPACT | RAW_FMT_HDR3 | RAW_FMT_ALIGN512),
} RkispCmdRawFmtID_e;
 
#pragma pack(1)
typedef struct Sensor_Params_s {
    uint8_t status;
    uint32_t fps;
    uint32_t hts;
    uint32_t vts;
    uint32_t bits;
    uint8_t endianness;
    uint16_t sensorImageFormat;
} Sensor_Params_t;
#pragma pack()
 
#pragma pack(1)
typedef struct Capture_Params_s {
    uint32_t gain;
    uint32_t time;
    uint8_t lhcg;
    uint8_t bits;
    uint8_t framenumber;
    uint8_t multiframe;
    uint32_t vblank;
    uint32_t focus_position;
} Capture_Params_t;
#pragma pack()
 
#pragma pack(1)
typedef struct Capture_Reso_s {
    uint16_t width;
    uint16_t height;
} Capture_Reso_t;
#pragma pack()
 
#define VIDEO_RAW0 "/dev/video0"
#define SAVE_RAW0_PATH "/data/output.raw"
 
#define TAG_PC_TO_DEVICE RKID_ISP_OFF
#define TAG_DEVICE_TO_PC RKID_ISP_OFF
 
int StopProcess(const char* process, const char* str);
int WaitProcessExit(const char* process, int sec);
 
class RKAiqRawProtocol
{
  public:
    RKAiqRawProtocol() = default;
    virtual ~RKAiqRawProtocol() = default;
    static void HandlerRawCapMessage(int sockfd, char* buffer, int size);
};
 
#endif