📄 xllp_camera.c
字号:
/******************************************************************************
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors. Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
********************************************************************************/
#include "xllp_defs.h"
#include "xllp_serialization.h"
#include "xllp_bcr.h"
#include "xllp_clkmgr.h"
#include "xllp_ost.h"
#include "xllp_gpio.h"
#include "xllp_dmac.h"
#include "xllp_camera.h"
#include "xllp_camera_os_depend.h"
#include "xllp_ci.h"
/***********************************************************************
*
* Declarations
*
***********************************************************************/
#define SINGLE_DESCRIPTOR_TRANSFER_MAX 8000
static const XLLP_DMAC_DEVICE_T CAMERA_DMA_DEVICE[3] = { 68, 69, 70 };
// map of xllp camera image format (xllp_camera.h) ==> capture interface format (xllp_ci.h)
static const XLLP_CI_IMAGE_FORMAT FORMAT_MAPPINGS[] = {
XLLP_CI_RAW8, //RAW
XLLP_CI_RAW9,
XLLP_CI_RAW10,
XLLP_CI_RGB444, //RGB
XLLP_CI_RGB555,
XLLP_CI_RGB565,
XLLP_CI_RGB666_PACKED, //RGB Packed
XLLP_CI_RGB666,
XLLP_CI_RGB888_PACKED,
XLLP_CI_RGB888,
XLLP_CI_RGBT555_0, //RGB+Transparent bit 0
XLLP_CI_RGBT888_0,
XLLP_CI_RGBT555_1, //RGB+Transparent bit 1
XLLP_CI_RGBT888_1,
XLLP_CI_INVALID_FORMAT,
XLLP_CI_YCBCR422, //YCBCR
XLLP_CI_YCBCR422_PLANAR, //YCBCR Planaried
XLLP_CI_INVALID_FORMAT,
XLLP_CI_INVALID_FORMAT
};
static void PrvStartDMATransfer( P_XLLP_Camera_Context_T camera_context, unsigned block_id );
static void PrvStopDMATransfer( P_XLLP_Camera_Context_T camera_context );
static XLLP_STATUS_T PrvStartCapture( P_XLLP_Camera_Context_T camera_context, unsigned int block_id, unsigned int frames );
/***********************************************************************
*
* Private functions
*
***********************************************************************/
void PrvStartDMATransfer( P_XLLP_Camera_Context_T camera_context, unsigned block_id )
{
XLLP_DMAC_DESCRIPTOR_T *des_virtual, *des_physical;
/*
NKDbgPrintfW(TEXT("capture_width %d\r\n"),camera_context->capture_width);
NKDbgPrintfW(TEXT("capture_height %d\r\n"),camera_context->capture_height);
NKDbgPrintfW(TEXT("Video_capture_width %d\r\n"),camera_context->Video_capture_width);
NKDbgPrintfW(TEXT("Video_capture_height %d\r\n"),camera_context->Video_capture_height);
NKDbgPrintfW(TEXT("dma_channels %d %d %d\r\n"),camera_context->dma_channels[0], camera_context->dma_channels[1], camera_context->dma_channels[2]);
NKDbgPrintfW(TEXT("fifo0_transfer_size %d\r\n"),camera_context->fifo0_transfer_size);
NKDbgPrintfW(TEXT("fifo1_transfer_size %d\r\n"),camera_context->fifo1_transfer_size);
NKDbgPrintfW(TEXT("fifo2_transfer_size %d\r\n"),camera_context->fifo2_transfer_size);
*/
des_virtual = (P_XLLP_DMAC_DESCRIPTOR_T)NULL;
des_physical = (P_XLLP_DMAC_DESCRIPTOR_T)camera_context->fifo0_descriptors_physical;
/*
NKDbgPrintfW(TEXT("camera_context->fifo0_descriptors_physical 0x%x\r\n"),(DWORD)camera_context->fifo0_descriptors_physical);
NKDbgPrintfW(TEXT("des_physical 0x%x\r\n"),(DWORD)des_physical);
*/
OS_DmaCfgChannelDescTransfer( des_virtual,
des_physical,
camera_context->dma_channels[0],
CAMERA_DMA_DEVICE[0],
XLLP_DMAC_ALIGNMENT_OFF
);
if ( camera_context->fifo1_transfer_size ) {
des_virtual = (P_XLLP_DMAC_DESCRIPTOR_T)NULL;
des_physical = (P_XLLP_DMAC_DESCRIPTOR_T)camera_context->fifo1_descriptors_physical;
OS_DmaCfgChannelDescTransfer( des_virtual,
des_physical,
camera_context->dma_channels[1],
CAMERA_DMA_DEVICE[1],
XLLP_DMAC_ALIGNMENT_OFF
);
}
if ( camera_context->fifo2_transfer_size ) {
des_virtual = (P_XLLP_DMAC_DESCRIPTOR_T)NULL;
des_physical = (P_XLLP_DMAC_DESCRIPTOR_T)camera_context->fifo2_descriptors_physical;
OS_DmaCfgChannelDescTransfer( des_virtual,
des_physical,
camera_context->dma_channels[2],
CAMERA_DMA_DEVICE[2],
XLLP_DMAC_ALIGNMENT_OFF
);
}
if ( camera_context->fifo0_transfer_size && camera_context->fifo1_transfer_size && camera_context->fifo2_transfer_size )
{
OS_DmaStartTransfer( camera_context->dma_channels[0] );
OS_DmaStartTransfer( camera_context->dma_channels[1] );
OS_DmaStartTransfer( camera_context->dma_channels[2] );
} else
{
OS_DmaStartTransfer( camera_context->dma_channels[0] );
}
}
void PrvStopDMATransfer( P_XLLP_Camera_Context_T camera_context )
{
// stop channel 0
OS_DmaStopTransfer( camera_context->dma_channels[0] );
// stop channel 1 and 2
if ( camera_context->capture_output_format == XLLP_CAMERA_IMAGE_FORMAT_YCBCR422_PLANAR)
{
OS_DmaStopTransfer( camera_context->dma_channels[1] );
OS_DmaStopTransfer( camera_context->dma_channels[2] );
}
}
XLLP_STATUS_T PrvStartCapture( P_XLLP_Camera_Context_T camera_context, unsigned int block_id, unsigned int frames )
{
XLLP_STATUS_T status;
// clear ci fifo
XllpCIResetFIFO(camera_context->ci_reg_base);
XllpCIClearInterruptStatus(camera_context->ci_reg_base, 0xFFFFFFFF);
// start dma
PrvStartDMATransfer(camera_context, block_id);
// start capture
status = camera_context->camera_functions->start_capture(camera_context, frames);
return status;
}
/***********************************************************************
*
* Init/Deinit APIs
*
***********************************************************************/
XLLP_STATUS_T XllpCameraInit( P_XLLP_Camera_Context_T camera_context )
{
XLLP_STATUS_T status = XLLP_STATUS_SUCCESS;
P_XLLP_GPIO_T pGPIO = (P_XLLP_GPIO_T)camera_context->gpio_reg_base;
int i;
// parameter check
if (camera_context->sensor_type > XLLP_CAMERA_TYPE_MAX)
return XLLP_STATUS_WRONG_PARAMETER;
if (camera_context->capture_input_format > XLLP_CAMERA_IMAGE_FORMAT_MAX ||
camera_context->capture_output_format > XLLP_CAMERA_IMAGE_FORMAT_MAX)
return XLLP_STATUS_WRONG_PARAMETER;
// check the function dispatch table according to the sensor type
if ( !camera_context->camera_functions )
return XLLP_STATUS_WRONG_PARAMETER;
if ( !camera_context->camera_functions->init ||
!camera_context->camera_functions->deinit ||
!camera_context->camera_functions->set_capture_format ||
!camera_context->camera_functions->start_capture ||
!camera_context->camera_functions->stop_capture )
return XLLP_STATUS_WRONG_PARAMETER;
camera_context->fifo0_transfer_size = camera_context->fifo1_transfer_size = camera_context->fifo2_transfer_size = 0;
// gpio pins init
{
// the first entry is size
static const XLLP_UINT32_T lowpins[]= {12, 27, 114, 116, 115, 90, 91, 17, 12, 23, 26, 24, 25};
static const XLLP_UINT32_T inpins[] = {11, 27, 114, 116, 115, 90, 91, 17, 12, 26, 25, 24};
static const XLLP_UINT32_T outpins[] = {1, 23};
static const XLLP_UINT32_T altpins[] = {12, 27, 114, 116, 115, 90, 91, 17, 12, 23, 26, 25, 24};
static const XLLP_UINT32_T altfunc[] = {12, 3, 1, 1, 2, 3, 3, 2, 2, 1, 2, 1, 1};
// configure processor pins
// Mux Pin GPIO Alt Direction
// CIF_DD[0]: SSP_EXTCLK 27 alt3 in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -