diff --git a/interface/mmal/mmal_encodings.h b/interface/mmal/mmal_encodings.h index 14afa2e56..b6c681aea 100644 --- a/interface/mmal/mmal_encodings.h +++ b/interface/mmal/mmal_encodings.h @@ -83,6 +83,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MMAL_ENCODING_BGR16 MMAL_FOURCC('B','G','R','2') #define MMAL_ENCODING_BGR24 MMAL_FOURCC('B','G','R','3') #define MMAL_ENCODING_BGR32 MMAL_FOURCC('B','G','R','4') +//Bayer formats +//FourCC values copied from V4L2 +//10 bit per pixel packed Bayer formats. +#define MMAL_ENCODING_BAYER_SBGGR10P MMAL_FOURCC('p','B','A','A') //BGGR +//#define MMAL_ENCODING_BAYER_SGRBG10P MMAL_FOURCC('p','g','A','A') //GRBG +//#define MMAL_ENCODING_BAYER_SGBRG10P MMAL_FOURCC('p','G','A','A') //GBRG +//#define MMAL_ENCODING_BAYER_SRGGB10P MMAL_FOURCC('p','R','A','A') //RGGB + +//8 bit per pixel Bayer formats. +#define MMAL_ENCODING_BAYER_SBGGR8 MMAL_FOURCC('B','A','8','1') //BGGR +//#define MMAL_ENCODING_BAYER_SGBRG8 MMAL_FOURCC('G','B','R','G') //GBRG +//#define MMAL_ENCODING_BAYER_SGRBG8 MMAL_FOURCC('G','R','B','G') //GRBG +//#define MMAL_ENCODING_BAYER_SRGGB8 MMAL_FOURCC('R','G','G','B') //RGGB + +//12 bit per pixel Bayer formats - not defined in V4L2, only 12bit expanded to 16. +#define MMAL_ENCODING_BAYER_SBGGR12P MMAL_FOURCC('B','Y','1','2') //BGGR + +//16 bit per pixel Bayer formats. +#define MMAL_ENCODING_BAYER_SBGGR16 MMAL_FOURCC('B','Y','R','2') //BGGR + +//10 bit per pixel DPCM compressed to 8bits Bayer formats. +#define MMAL_ENCODING_BAYER_SBGGR10DPCM8 MMAL_FOURCC('b','B','A','8') //BGGR +//#define MMAL_ENCODING_BAYER_SGBRG10DPCM8 MMAL_FOURCC('b','G','A','8') //GBRG +//#define MMAL_ENCODING_BAYER_SGRBG10DPCM8 MMAL_FOURCC('b','D','A','8') //GRBG +//#define MMAL_ENCODING_BAYER_SRGGB10DPCM8 MMAL_FOURCC('b','R','A','8') //RGGB /** SAND Video (YUVUV128) format, native format understood by VideoCore. * This format is *not* opaque - if requested you will receive full frames diff --git a/interface/mmal/mmal_parameters_camera.h b/interface/mmal/mmal_parameters_camera.h index 64596b617..5dbe6f8f5 100644 --- a/interface/mmal/mmal_parameters_camera.h +++ b/interface/mmal/mmal_parameters_camera.h @@ -131,6 +131,10 @@ enum { MMAL_PARAMETER_STILLS_DENOISE, /**< Takes a @ref MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_ANNOTATE, /**< Takes a @ref MMAL_PARAMETER_CAMERA_ANNOTATE_T */ MMAL_PARAMETER_STEREOSCOPIC_MODE, /**< Takes a @ref MMAL_PARAMETER_STEREOSCOPIC_MODE_T */ + MMAL_PARAMETER_CAMERA_INTERFACE, /**< Takes a @ref MMAL_PARAMETER_CAMERA_INTERFACE_T */ + MMAL_PARAMETER_CAMERA_CLOCKING_MODE, /**< Takes a @ref MMAL_PARAMETER_CAMERA_CLOCKING_MODE_T */ + MMAL_PARAMETER_CAMERA_RX_CONFIG, /**< Takes a @ref MMAL_PARAMETER_CAMERA_RX_CONFIG_T */ + MMAL_PARAMETER_CAMERA_RX_TIMING, /**< Takes a @ref MMAL_PARAMETER_CAMERA_RX_TIMING_T */ }; /** Thumbnail configuration parameter type */ @@ -778,4 +782,108 @@ typedef struct MMAL_PARAMETER_STEREOSCOPIC_MODE_T MMAL_BOOL_T swap_eyes; } MMAL_PARAMETER_STEREOSCOPIC_MODE_T; +typedef enum MMAL_CAMERA_INTERFACE_T { + MMAL_CAMERA_INTERFACE_CSI2 = 0, + MMAL_CAMERA_INTERFACE_CCP2 = 1, + MMAL_CAMERA_INTERFACE_CPI = 2, + MMAL_CAMERA_INTERFACE_MAX = 0x7FFFFFFF, +} MMAL_CAMERA_INTERFACE_T; + +typedef struct MMAL_PARAMETER_CAMERA_INTERFACE_T +{ + MMAL_PARAMETER_HEADER_T hdr; + + MMAL_CAMERA_INTERFACE_T mode; +} MMAL_PARAMETER_CAMERA_INTERFACE_T; + +typedef enum MMAL_CAMERA_CLOCKING_MODE_T { + MMAL_CAMERA_CLOCKING_MODE_STROBE = 0, + MMAL_CAMERA_CLOCKING_MODE_CLOCK = 1, + MMAL_CAMERA_CLOCKING_MODE_MAX = 0x7FFFFFFF, +} MMAL_CAMERA_CLOCKING_MODE_T; + +typedef struct MMAL_PARAMETER_CAMERA_CLOCKING_MODE_T +{ + MMAL_PARAMETER_HEADER_T hdr; + + MMAL_CAMERA_CLOCKING_MODE_T mode; +} MMAL_PARAMETER_CAMERA_CLOCKING_MODE_T; + +typedef enum MMAL_CAMERA_RX_CONFIG_DECODE { + MMAL_CAMERA_RX_CONFIG_DECODE_NONE = 0, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM8TO10 = 1, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM7TO10 = 2, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM6TO10 = 3, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM8TO12 = 4, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM7TO12 = 5, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM6TO12 = 6, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM10TO14 = 7, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM8TO14 = 8, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM12TO16 = 9, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM10TO16 = 10, + MMAL_CAMERA_RX_CONFIG_DECODE_DPCM8TO16 = 11, + MMAL_CAMERA_RX_CONFIG_DECODE_MAX = 0x7FFFFFFF +} MMAL_CAMERA_RX_CONFIG_DECODE; + +typedef enum MMAL_CAMERA_RX_CONFIG_ENCODE { + MMAL_CAMERA_RX_CONFIG_ENCODE_NONE = 0, + MMAL_CAMERA_RX_CONFIG_ENCODE_DPCM10TO8 = 1, + MMAL_CAMERA_RX_CONFIG_ENCODE_DPCM12TO8 = 2, + MMAL_CAMERA_RX_CONFIG_ENCODE_DPCM14TO8 = 3, + MMAL_CAMERA_RX_CONFIG_ENCODE_MAX = 0x7FFFFFFF +} MMAL_CAMERA_RX_CONFIG_ENCODE; + +typedef enum MMAL_CAMERA_RX_CONFIG_UNPACK { + MMAL_CAMERA_RX_CONFIG_UNPACK_NONE = 0, + MMAL_CAMERA_RX_CONFIG_UNPACK_6 = 1, + MMAL_CAMERA_RX_CONFIG_UNPACK_7 = 2, + MMAL_CAMERA_RX_CONFIG_UNPACK_8 = 3, + MMAL_CAMERA_RX_CONFIG_UNPACK_10 = 4, + MMAL_CAMERA_RX_CONFIG_UNPACK_12 = 5, + MMAL_CAMERA_RX_CONFIG_UNPACK_14 = 6, + MMAL_CAMERA_RX_CONFIG_UNPACK_16 = 7, + MMAL_CAMERA_RX_CONFIG_UNPACK_MAX = 0x7FFFFFFF +} MMAL_CAMERA_RX_CONFIG_UNPACK; + +typedef enum MMAL_CAMERA_RX_CONFIG_PACK { + MMAL_CAMERA_RX_CONFIG_PACK_NONE = 0, + MMAL_CAMERA_RX_CONFIG_PACK_8 = 1, + MMAL_CAMERA_RX_CONFIG_PACK_10 = 2, + MMAL_CAMERA_RX_CONFIG_PACK_12 = 3, + MMAL_CAMERA_RX_CONFIG_PACK_14 = 4, + MMAL_CAMERA_RX_CONFIG_PACK_16 = 5, + MMAL_CAMERA_RX_CONFIG_PACK_RAW10 = 6, + MMAL_CAMERA_RX_CONFIG_PACK_RAW12 = 7, + MMAL_CAMERA_RX_CONFIG_PACK_MAX = 0x7FFFFFFF +} MMAL_CAMERA_RX_CONFIG_PACK; + +typedef struct MMAL_PARAMETER_CAMERA_RX_CONFIG_T +{ + MMAL_PARAMETER_HEADER_T hdr; + + MMAL_CAMERA_RX_CONFIG_DECODE decode; + MMAL_CAMERA_RX_CONFIG_ENCODE encode; + MMAL_CAMERA_RX_CONFIG_UNPACK unpack; + MMAL_CAMERA_RX_CONFIG_PACK pack; + uint32_t data_lanes; + uint32_t encode_block_length; + uint32_t embedded_data_lines; + uint32_t image_id; +} MMAL_PARAMETER_CAMERA_RX_CONFIG_T; + +typedef struct MMAL_PARAMETER_CAMERA_RX_TIMING_T +{ + MMAL_PARAMETER_HEADER_T hdr; + + uint32_t timing1; + uint32_t timing2; + uint32_t timing3; + uint32_t timing4; + uint32_t timing5; + uint32_t term1; + uint32_t term2; + uint32_t cpi_timing1; + uint32_t cpi_timing2; +} MMAL_PARAMETER_CAMERA_RX_TIMING_T; + #endif /* MMAL_PARAMETERS_CAMERA_H */ diff --git a/interface/mmal/util/mmal_il.c b/interface/mmal/util/mmal_il.c index 7d5c90907..e84a60ed5 100644 --- a/interface/mmal/util/mmal_il.c +++ b/interface/mmal/util/mmal_il.c @@ -709,6 +709,11 @@ static struct { {MMAL_ENCODING_ARGB, OMX_COLOR_Format32bitBGRA8888}, {MMAL_ENCODING_RGBA, OMX_COLOR_Format32bitABGR8888}, {MMAL_ENCODING_EGL_IMAGE, OMX_COLOR_FormatBRCMEGL}, + {MMAL_ENCODING_BAYER_SBGGR8, OMX_COLOR_FormatRawBayer8bit}, + {MMAL_ENCODING_BAYER_SBGGR10P, OMX_COLOR_FormatRawBayer10bit}, + {MMAL_ENCODING_BAYER_SBGGR12P, OMX_COLOR_FormatRawBayer12bit}, + {MMAL_ENCODING_BAYER_SBGGR16, OMX_COLOR_FormatRawBayer16bit}, + {MMAL_ENCODING_BAYER_SBGGR10DPCM8,OMX_COLOR_FormatRawBayer8bitcompressed}, {MMAL_ENCODING_OPAQUE, OMX_COLOR_FormatBRCMOpaque}, {MMAL_ENCODING_UNKNOWN, OMX_COLOR_FormatUnused} }; diff --git a/interface/mmal/util/mmal_util.c b/interface/mmal/util/mmal_util.c index 8959e5329..c046d1b6a 100644 --- a/interface/mmal/util/mmal_util.c +++ b/interface/mmal/util/mmal_util.c @@ -68,28 +68,37 @@ static struct { uint32_t encoding; uint32_t pitch_num; uint32_t pitch_den; + uint32_t alignment; } pixel_pitch[] = { - {MMAL_ENCODING_I420, 1, 1}, - {MMAL_ENCODING_YV12, 1, 1}, - {MMAL_ENCODING_I422, 1, 1}, - {MMAL_ENCODING_NV21, 1, 1}, - {MMAL_ENCODING_NV12, 1, 1}, - {MMAL_ENCODING_ARGB, 4, 1}, - {MMAL_ENCODING_RGBA, 4, 1}, - {MMAL_ENCODING_RGB32, 4, 1}, - {MMAL_ENCODING_ABGR, 4, 1}, - {MMAL_ENCODING_BGRA, 4, 1}, - {MMAL_ENCODING_BGR32, 4, 1}, - {MMAL_ENCODING_RGB16, 2, 1}, - {MMAL_ENCODING_RGB24, 3, 1}, - {MMAL_ENCODING_BGR16, 2, 1}, - {MMAL_ENCODING_BGR24, 3, 1}, - - {MMAL_ENCODING_YUYV, 2, 1}, - {MMAL_ENCODING_YVYU, 2, 1}, - {MMAL_ENCODING_UYVY, 2, 1}, - {MMAL_ENCODING_VYUY, 2, 1}, + {MMAL_ENCODING_I420, 1, 1, 1}, + {MMAL_ENCODING_YV12, 1, 1, 1}, + {MMAL_ENCODING_I422, 1, 1, 1}, + {MMAL_ENCODING_NV21, 1, 1, 1}, + {MMAL_ENCODING_NV12, 1, 1, 1}, + {MMAL_ENCODING_ARGB, 4, 1, 1}, + {MMAL_ENCODING_RGBA, 4, 1, 1}, + {MMAL_ENCODING_RGB32, 4, 1, 1}, + {MMAL_ENCODING_ABGR, 4, 1, 1}, + {MMAL_ENCODING_BGRA, 4, 1, 1}, + {MMAL_ENCODING_BGR32, 4, 1, 1}, + {MMAL_ENCODING_RGB16, 2, 1, 1}, + {MMAL_ENCODING_RGB24, 3, 1, 1}, + {MMAL_ENCODING_BGR16, 2, 1, 1}, + {MMAL_ENCODING_BGR24, 3, 1, 1}, + + {MMAL_ENCODING_YUYV, 2, 1, 1}, + {MMAL_ENCODING_YVYU, 2, 1, 1}, + {MMAL_ENCODING_UYVY, 2, 1, 1}, + {MMAL_ENCODING_VYUY, 2, 1, 1}, + + // Bayer formats, the resulting alignment must also be a multiple of 16. + // Camplus padded to a multiple of 32, so let's copy that. + {MMAL_ENCODING_BAYER_SBGGR8, 1, 1, 32}, + {MMAL_ENCODING_BAYER_SBGGR10DPCM8, 1, 1, 32}, + {MMAL_ENCODING_BAYER_SBGGR10P, 10,8, 32}, + {MMAL_ENCODING_BAYER_SBGGR16, 2, 1, 32}, + /* {MMAL_ENCODING_YUVUV128, 1, 1}, That's a special case which must not be included */ {MMAL_ENCODING_UNKNOWN, 0, 0} }; @@ -117,7 +126,7 @@ uint32_t mmal_encoding_width_to_stride(uint32_t encoding, uint32_t width) if(pixel_pitch[i].encoding == MMAL_ENCODING_UNKNOWN) return 0; - return pixel_pitch[i].pitch_num * width / pixel_pitch[i].pitch_den; + return VCOS_ALIGN_UP(pixel_pitch[i].pitch_num * width / pixel_pitch[i].pitch_den, pixel_pitch[i].alignment); } const char* mmal_port_type_to_string(MMAL_PORT_TYPE_T type) diff --git a/interface/vmcs_host/khronos/IL/OMX_Broadcom.h b/interface/vmcs_host/khronos/IL/OMX_Broadcom.h index 7723720e0..14194ade5 100644 --- a/interface/vmcs_host/khronos/IL/OMX_Broadcom.h +++ b/interface/vmcs_host/khronos/IL/OMX_Broadcom.h @@ -2405,5 +2405,112 @@ typedef struct OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE { OMX_BOOL bSwapEyes; /**< False = left eye first. True = right eye first. */ } OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE; +typedef enum OMX_CAMERAINTERFACETYPE { + OMX_CAMERAINTERFACE_CSI = 0, + OMX_CAMERAINTERFACE_CCP2 = 1, + OMX_CAMERAINTERFACE_CPI = 2, + OMX_CAMERAINTERFACE_MAX = 0x7FFFFFFF, +} OMX_CAMERAINTERFACETYPE; + +typedef struct OMX_PARAM_CAMERAINTERFACETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_CAMERAINTERFACETYPE eMode; /**< Interface mode */ +} OMX_PARAM_CAMERAINTERFACETYPE; + +typedef enum OMX_CAMERACLOCKINGMODETYPE { + OMX_CAMERACLOCKINGMODE_STROBE = 0, + OMX_CAMERACLOCKINGMODE_CLOCK = 1, + OMX_CAMERACLOCKINGMODE_MAX = 0x7FFFFFFF, +} OMX_CAMERACLOCKINGMODETYPE; + +typedef struct OMX_PARAM_CAMERACLOCKINGMODETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_CAMERACLOCKINGMODETYPE eMode; /**< Clocking mode */ +} OMX_PARAM_CAMERACLOCKINGMODETYPE; + +typedef enum OMX_CAMERARXDECODETYPE { + OMX_CAMERARXDECODE_NONE = 0, + OMX_CAMERARXDECODE_DPCM8TO10 = 1, + OMX_CAMERARXDECODE_DPCM7TO10 = 2, + OMX_CAMERARXDECODE_DPCM6TO10 = 3, + OMX_CAMERARXDECODE_DPCM8TO12 = 4, + OMX_CAMERARXDECODE_DPCM7TO12 = 5, + OMX_CAMERARXDECODE_DPCM6TO12 = 6, + OMX_CAMERARXDECODE_DPCM10TO14 = 7, + OMX_CAMERARXDECODE_DPCM8TO14 = 8, + OMX_CAMERARXDECODE_DPCM12TO16 = 9, + OMX_CAMERARXDECODE_DPCM10TO16 = 10, + OMX_CAMERARXDECODE_DPCM8TO16 = 11, + OMX_CAMERARXDECODE_MAX = 0x7FFFFFFF +} OMX_CAMERARXDECODETYPE; + +typedef enum OMX_CAMERARXENCODETYPE { + OMX_CAMERARXENCODE_NONE = 0, + OMX_CAMERARXENCODE_DPCM10TO8 = 1, + OMX_CAMERARXENCODE_DPCM12TO8 = 2, + OMX_CAMERARXENCODE_DPCM14TO8 = 3, + OMX_CAMERARXENCODE_MAX = 0x7FFFFFFF +} OMX_CAMERARXENCODETYPE; + +typedef enum OMX_CAMERARXUNPACKTYPE { + OMX_CAMERARXUNPACK_NONE = 0, + OMX_CAMERARXUNPACK_6 = 1, + OMX_CAMERARXUNPACK_7 = 2, + OMX_CAMERARXUNPACK_8 = 3, + OMX_CAMERARXUNPACK_10 = 4, + OMX_CAMERARXUNPACK_12 = 5, + OMX_CAMERARXUNPACK_14 = 6, + OMX_CAMERARXUNPACK_16 = 7, + OMX_CAMERARXUNPACK_MAX = 0x7FFFFFFF +} OMX_CAMERARXUNPACKYPE; + +typedef enum OMX_CAMERARXPACKTYPE { + OMX_CAMERARXPACK_NONE = 0, + OMX_CAMERARXPACK_8 = 1, + OMX_CAMERARXPACK_10 = 2, + OMX_CAMERARXPACK_12 = 3, + OMX_CAMERARXPACK_14 = 4, + OMX_CAMERARXPACK_16 = 5, + OMX_CAMERARXPACK_RAW10 = 6, + OMX_CAMERARXPACK_RAW12 = 7, + OMX_CAMERARXPACK_MAX = 0x7FFFFFFF +} OMX_CAMERARXPACKTYPE; + +typedef struct OMX_PARAM_CAMERARXCONFIG_TYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_CAMERARXDECODETYPE eDecode; + OMX_CAMERARXENCODETYPE eEncode; + OMX_CAMERARXUNPACKYPE eUnpack; + OMX_CAMERARXPACKTYPE ePack; + OMX_U32 nDataLanes; + OMX_U32 nEncodeBlockLength; + OMX_U32 nEmbeddedDataLines; + OMX_U32 nImageId; +} OMX_PARAM_CAMERARXCONFIG_TYPE; + +typedef struct OMX_PARAM_CAMERARXTIMING_TYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_U32 nTiming1; + OMX_U32 nTiming2; + OMX_U32 nTiming3; + OMX_U32 nTiming4; + OMX_U32 nTiming5; + OMX_U32 nTerm1; + OMX_U32 nTerm2; + OMX_U32 nCpiTiming1; + OMX_U32 nCpiTiming2; +} OMX_PARAM_CAMERARXTIMING_TYPE; #endif /* File EOF */ diff --git a/interface/vmcs_host/khronos/IL/OMX_IVCommon.h b/interface/vmcs_host/khronos/IL/OMX_IVCommon.h index 244a3af96..bf86b7ca2 100644 --- a/interface/vmcs_host/khronos/IL/OMX_IVCommon.h +++ b/interface/vmcs_host/khronos/IL/OMX_IVCommon.h @@ -142,6 +142,7 @@ typedef enum OMX_COLOR_FORMATTYPE { OMX_COLOR_FormatBRCMOpaque, OMX_COLOR_FormatYVU420PackedPlanar, OMX_COLOR_FormatYVU420PackedSemiPlanar, + OMX_COLOR_FormatRawBayer16bit, OMX_COLOR_FormatMax = 0x7FFFFFFF } OMX_COLOR_FORMATTYPE; diff --git a/interface/vmcs_host/khronos/IL/OMX_Index.h b/interface/vmcs_host/khronos/IL/OMX_Index.h index 8db6ccc84..aca54927a 100644 --- a/interface/vmcs_host/khronos/IL/OMX_Index.h +++ b/interface/vmcs_host/khronos/IL/OMX_Index.h @@ -516,7 +516,10 @@ typedef enum OMX_INDEXTYPE { OMX_IndexParamBrcmStereoscopicMode, /**< reference :OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE */ OMX_IndexParamBrcmLockStepEnable, /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */ OMX_IndexParamBrcmTimeScale, /**< reference: OMX_PARAM_U32TYPE */ - + OMX_IndexParamCameraInterface, /**< reference: OMX_PARAM_CAMERAINTERFACETYPE */ + OMX_IndexParamCameraClockingMode, /**< reference: OMX_PARAM_CAMERACLOCKINGMODETYPE */ + OMX_IndexParamCameraRxConfig, /**< reference: OMX_PARAM_CAMERARXCONFIG_TYPE */ + OMX_IndexParamCameraRxTiming, /**< reference: OMX_PARAM_CAMERARXTIMING_TYPE */ OMX_IndexMax = 0x7FFFFFFF } OMX_INDEXTYPE;