/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* usbvideo_drv.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file implements usb video class driver
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#include "drv_comm.h"
#include "reg_base.h"
#include "intrCtrl.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h"
#include "app_buff_alloc.h"
#include "drvsignals.h"
#include "gpt_sw.h"
#include "usb_comm.h"
#include "usb_drv.h"
#include "usb.h"
#include "usb_resource.h"
#include "usbvideo_drv.h"
#include "usbvideo_state.h"
#include "usb_custom.h"
#include "usbvideo_if.h"
#include "usbvideo_custom.h"
#include "usb_debug_tool.h"
/*This will be removed when change back to media task*/
#include "custom_config.h"
#ifdef WEBCAM_SUPPORT
USBVideo_Struct g_USBVideo;
/* static functions */
static void USBVideo_Set_Attr(void *data);
static void USBVideo_Set_ProbControl(void *data);
static void USBVideo_Set_Still_ProbControl(void *data);
static void USBVideo_Set_Still_ImageControl(void *data);/* take picture */
static void USBVideo_Ep0_VC_Command(Usb_Ep0_Status *pep0state, Usb_Command *pcmd);
static void USBVideo_Ep0_VS_Command(Usb_Ep0_Status *pep0state, Usb_Command *pcmd);
static void USBVideo_IntrIn_Reset(void);
static void USBVideo_BulkIn_Reset(void);
static void USBVideo_IntrIn_Hdlr(void );
static void USBVideo_Tx_Incall_DMA_Callback(void);
static void USBVideo_Tx_DMA_Callback(void);
static void USBVideo_ClearFeature_Callback(Usb_Command *pcmd); /*clear ep1's state */
/************************************************************
Attribute tables
*************************************************************/
/* subtype lengths */
static const USBVideo_Attr_Sub_Map g_USBVideo_Focus_Map[] =
{
{USBVIDEO_ATTR_FOCUS_SET, 1},
{USBVIDEO_ATTR_FOCUS_SPEED, 1}
};
static const USBVideo_Attr_Sub_Map g_USBVideo_Zoom_Map[] =
{
{USBVIDEO_ATTR_ZOOM_ZOOM, 1},
{USBVIDEO_ATTR_ZOOM_DIGITALZOOM, 1},
{USBVIDEO_ATTR_ZOOM_SPEED, 1}
};
static const USBVideo_Attr_Sub_Map g_USBVideo_PanTilt_Ab_Map[] =
{
{USBVIDEO_ATTR_AB_PANTILT_PAN, 4},
{USBVIDEO_ATTR_AB_PANTILT_TILT, 4}
};
static const USBVideo_Attr_Sub_Map g_USBVideo_PanTilt_Re_Map[] =
{
{USBVIDEO_ATTR_RE_PANTILT_PAN, 1},
{USBVIDEO_ATTR_RE_PANTILT_PAN_SPEED, 1},
{USBVIDEO_ATTR_RE_PANTILT_TILT, 1},
{USBVIDEO_ATTR_RE_PANTILT_TILT_SPEED, 1}
};
static const USBVideo_Attr_Sub_Map g_USBVideo_Roll_Map[] =
{
{USBVIDEO_ATTR_ROLL_SET, 1},
{USBVIDEO_ATTR_ROLL_SPEED, 1}
};
static const USBVideo_Attr_Sub_Map g_USBVideo_AWB_Map[] =
{
{USBVIDEO_ATTR_WHITE_BALANCE_BLUE, 2},
{USBVIDEO_ATTR_WHITE_BALANCE_RED, 2}
};
/* CT attribute. Descriptor shift mapping table, attribute data length, and whether it has subtypes*/
static const USBVideo_Attr_Map g_USBVideo_CT_Attr_Map[] =
{
{USBVIDEO_ATTRIBUTE_SCANNING_MODE, 0, 1, NULL},
{USBVIDEO_ATTRIBUTE_AE_MODE, 1, 1, NULL},
{USBVIDEO_ATTRIBUTE_AE_PRIORITY, 2, 1, NULL},
{USBVIDEO_ATTRIBUTE_EXP_TIME_ABSOLUTE, 3, 4, NULL},
{USBVIDEO_ATTRIBUTE_EXP_TIME_RELATIVE, 4, 1, NULL},
{USBVIDEO_ATTRIBUTE_FOCUS_ABSOLUTE, 5, 2, NULL},
{USBVIDEO_ATTRIBUTE_FOCUS_RELATIVE, 6, 2, g_USBVideo_Focus_Map},
{USBVIDEO_ATTRIBUTE_FOCUS_AUTO, 17, 1, NULL},
{USBVIDEO_ATTRIBUTE_IRIS_ABSOLUTE, 7, 2, NULL},
{USBVIDEO_ATTRIBUTE_IRIS_RELATIVE, 8, 1, NULL},
{USBVIDEO_ATTRIBUTE_ZOOM_ABSOLUTE, 9, 2, NULL},
{USBVIDEO_ATTRIBUTE_ZOOM_RELATIVE, 10, 3, g_USBVideo_Zoo