usbvc_var.h revision 9e37f2b5d225bd6428d62c06655138fc78fd1ac0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_USB_USBVC_VAR_H
#define _SYS_USB_USBVC_VAR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/videodev2.h>
typedef struct usbvc_state usbvc_state_t;
/*
* Power Management support
*/
typedef struct usbvc_power {
void *usbvc_state; /* points back to usbvc_state */
int usbvc_pm_busy;
/* Wakeup and power transistion capabilites of an interface */
/* flag to indicate if driver is about to raise power level */
/* Raw data buf from the USB cam */
typedef struct usbvc_buf
{
/* cookie used for memory mapping */
struct v4l2_buffer v4l2_buf;
} usbvc_buf_t;
/* Group data buf related lists and other elements */
typedef struct usbvc_buf_grp
{
/*
* UVC Spec: one format descriptor may be followed by sererval frame
* descriptors, one still image descriptor and one color matching descriptor.
* It is called a format group. There might be several format groups follow
*/
typedef struct usbvc_format_group {
/* bytes per pix, used to calculate bytesperline */
/* A stream interface may have several format groups */
typedef struct usbvc_stream_if {
/* The actual format groups we parsed for the stream interface */
/* The max payload that the isoc data EPs can support */
/*
* To flag if VIDIOC_STREAMON is executed, only used by STREAM mode
* device's isoc polling operation after resume.
*/
/* video interface collection */
typedef struct usbvc_vic {
/* bFirstInterface, the video control infterface num of this VIC */
/*
* bInterfaceCount -1, the total number of stream interfaces
* belong to this VIC
*/
} usbvc_vic_t;
/* Macros */
#define USBVC_OPEN 0x00000001
/* For serialization. */
#define USBVC_SER_NOSIG B_FALSE
#define USBVC_SER_SIG B_TRUE
/*
* Masks for debug printing
*/
#define PRINT_MASK_ATTA 0x00000001
#define PRINT_MASK_OPEN 0x00000002
#define PRINT_MASK_CLOSE 0x00000004
#define PRINT_MASK_READ 0x00000008
#define PRINT_MASK_IOCTL 0x00000010
#define PRINT_MASK_PM 0x00000020
#define PRINT_MASK_CB 0x00000040
#define PRINT_MASK_HOTPLUG 0x00000080
#define PRINT_MASK_DEVCTRL 0x00000100
#define PRINT_MASK_DEVMAP 0x00000200
#define PRINT_MASK_ALL 0xFFFFFFFF
#define USBVC_MAX_PKTS 40
#define USBVC_DEFAULT_READ_BUF_NUM 3
#define USBVC_MAX_READ_BUF_NUM 40
#define USBVC_MAX_MAP_BUF_NUM 40
/* According to UVC specs, the frame interval is in 100ns unit */
#define USBVC_FRAME_INTERVAL_DENOMINATOR 10000000
/* Only D3...D0 are writable, Table 4-6, UVC Spec */
#define USBVC_POWER_MODE_MASK 0xf0;
enum usbvc_buf_status {
USBVC_BUF_INIT = 0, /* Allocated, to be queued */
/*
* buf is filled with a full frame without any errors,
* it will be moved to full list.
*/
USBVC_BUF_DONE = 4,
/*
* buf is filled to full but no EOF bit is found at the end
* of video data
*/
USBVC_BUF_ERR = 8
};
/*
* This structure is used to map v4l2 controls to uvc controls. The structure
* array is addressed by (V4L2_CID_BASE - V4L2_CID_*)
*/
typedef struct usbvc_v4l2_ctrl_map {
char name[32];
/* The xth bit in bmControls bitmap of processing unit descriptor */
enum v4l2_ctrl_type type;
typedef struct usbvc_v4l2_ctrl {
/*
* State structure
*/
struct usbvc_state {
int usbvc_dev_state; /* USB device states. */
int usbvc_drv_state; /* driver states. */
/* Video ctrl interface header descriptor */
/* current I/O type: read or mmap. */
};
/*
* Used in ioctl entry to copy an argument from kernel space (arg_name)
* to USER space (arg)
*/
#define USBVC_COPYOUT(arg_name) \
break; \
}
/*
* Used in ioctl entry to copy an argument from USER space (arg) to
* KERNEL space (arg_name)
*/
#define USBVC_COPYIN(arg_name) \
break; \
}
/* Turn a little endian byte array to a uint32_t */
}
/* Turn a uint32_t to a little endian byte array */
}
/* Turn a little endian byte array to a uint16_t */
/* Turn a uint16_t to alittle endian byte array */
}
#define NELEM(a) (sizeof (a) / sizeof (*(a)))
/* Minimum length of class specific descriptors */
/* Length of the Frame descriptor which has continuous frame intervals */
#define USBVC_FRAME_LEN_CON 38
/*
* According to usb2.0 spec (table 9-13), for all ep, bits 10..0 specify the
* max pkt size; for high speed ep, bits 12..11 specify the number of
* additional transaction opportunities per microframe.
*/
/*
* warlock directives
* _NOTE is an advice for locklint. Locklint checks lock use for deadlocks.
*/
}))
/* Functions specific for V4L2 API */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_USBVC_VAR_H */