Conflicts: drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c Minor conflict between the BCM_CNIC define removal in net-next and a bug fix added to net. Based upon a conflict resolution patch posted by Stephen Rothwell.
Showing the changes to include/uapi (26 of 1031 files). Show all
Unified · Split
| @@ -1 +1,9 @@ | ||
| 1 | 1 | # UAPI Header export list |
| 2 | +header-y += audio.h | |
| 3 | +header-y += ca.h | |
| 4 | +header-y += dmx.h | |
| 5 | +header-y += frontend.h | |
| 6 | +header-y += net.h | |
| 7 | +header-y += osd.h | |
| 8 | +header-y += version.h | |
| 9 | +header-y += video.h | |
| @@ -0,0 +1,135 @@ | ||
| 1 | +/* | |
| 2 | + * audio.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de> | |
| 5 | + * & Marcus Metzler <marcus@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU General Lesser Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _DVBAUDIO_H_ | |
| 25 | +#define _DVBAUDIO_H_ | |
| 26 | + | |
| 27 | +#include <linux/types.h> | |
| 28 | + | |
| 29 | +typedef enum { | |
| 30 | + AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */ | |
| 31 | + AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */ | |
| 32 | +} audio_stream_source_t; | |
| 33 | + | |
| 34 | + | |
| 35 | +typedef enum { | |
| 36 | + AUDIO_STOPPED, /* Device is stopped */ | |
| 37 | + AUDIO_PLAYING, /* Device is currently playing */ | |
| 38 | + AUDIO_PAUSED /* Device is paused */ | |
| 39 | +} audio_play_state_t; | |
| 40 | + | |
| 41 | + | |
| 42 | +typedef enum { | |
| 43 | + AUDIO_STEREO, | |
| 44 | + AUDIO_MONO_LEFT, | |
| 45 | + AUDIO_MONO_RIGHT, | |
| 46 | + AUDIO_MONO, | |
| 47 | + AUDIO_STEREO_SWAPPED | |
| 48 | +} audio_channel_select_t; | |
| 49 | + | |
| 50 | + | |
| 51 | +typedef struct audio_mixer { | |
| 52 | + unsigned int volume_left; | |
| 53 | + unsigned int volume_right; | |
| 54 | + // what else do we need? bass, pass-through, ... | |
| 55 | +} audio_mixer_t; | |
| 56 | + | |
| 57 | + | |
| 58 | +typedef struct audio_status { | |
| 59 | + int AV_sync_state; /* sync audio and video? */ | |
| 60 | + int mute_state; /* audio is muted */ | |
| 61 | + audio_play_state_t play_state; /* current playback state */ | |
| 62 | + audio_stream_source_t stream_source; /* current stream source */ | |
| 63 | + audio_channel_select_t channel_select; /* currently selected channel */ | |
| 64 | + int bypass_mode; /* pass on audio data to */ | |
| 65 | + audio_mixer_t mixer_state; /* current mixer state */ | |
| 66 | +} audio_status_t; /* separate decoder hardware */ | |
| 67 | + | |
| 68 | + | |
| 69 | +typedef | |
| 70 | +struct audio_karaoke { /* if Vocal1 or Vocal2 are non-zero, they get mixed */ | |
| 71 | + int vocal1; /* into left and right t at 70% each */ | |
| 72 | + int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/ | |
| 73 | + int melody; /* mixed into the left channel and */ | |
| 74 | + /* Vocal2 into the right channel at 100% each. */ | |
| 75 | + /* if Melody is non-zero, the melody channel gets mixed*/ | |
| 76 | +} audio_karaoke_t; /* into left and right */ | |
| 77 | + | |
| 78 | + | |
| 79 | +typedef __u16 audio_attributes_t; | |
| 80 | +/* bits: descr. */ | |
| 81 | +/* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */ | |
| 82 | +/* 12 multichannel extension */ | |
| 83 | +/* 11-10 audio type (0=not spec, 1=language included) */ | |
| 84 | +/* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */ | |
| 85 | +/* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */ | |
| 86 | +/* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */ | |
| 87 | +/* 2- 0 number of audio channels (n+1 channels) */ | |
| 88 | + | |
| 89 | + | |
| 90 | +/* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */ | |
| 91 | +#define AUDIO_CAP_DTS 1 | |
| 92 | +#define AUDIO_CAP_LPCM 2 | |
| 93 | +#define AUDIO_CAP_MP1 4 | |
| 94 | +#define AUDIO_CAP_MP2 8 | |
| 95 | +#define AUDIO_CAP_MP3 16 | |
| 96 | +#define AUDIO_CAP_AAC 32 | |
| 97 | +#define AUDIO_CAP_OGG 64 | |
| 98 | +#define AUDIO_CAP_SDDS 128 | |
| 99 | +#define AUDIO_CAP_AC3 256 | |
| 100 | + | |
| 101 | +#define AUDIO_STOP _IO('o', 1) | |
| 102 | +#define AUDIO_PLAY _IO('o', 2) | |
| 103 | +#define AUDIO_PAUSE _IO('o', 3) | |
| 104 | +#define AUDIO_CONTINUE _IO('o', 4) | |
| 105 | +#define AUDIO_SELECT_SOURCE _IO('o', 5) | |
| 106 | +#define AUDIO_SET_MUTE _IO('o', 6) | |
| 107 | +#define AUDIO_SET_AV_SYNC _IO('o', 7) | |
| 108 | +#define AUDIO_SET_BYPASS_MODE _IO('o', 8) | |
| 109 | +#define AUDIO_CHANNEL_SELECT _IO('o', 9) | |
| 110 | +#define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t) | |
| 111 | + | |
| 112 | +#define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int) | |
| 113 | +#define AUDIO_CLEAR_BUFFER _IO('o', 12) | |
| 114 | +#define AUDIO_SET_ID _IO('o', 13) | |
| 115 | +#define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t) | |
| 116 | +#define AUDIO_SET_STREAMTYPE _IO('o', 15) | |
| 117 | +#define AUDIO_SET_EXT_ID _IO('o', 16) | |
| 118 | +#define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t) | |
| 119 | +#define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t) | |
| 120 | + | |
| 121 | +/** | |
| 122 | + * AUDIO_GET_PTS | |
| 123 | + * | |
| 124 | + * Read the 33 bit presentation time stamp as defined | |
| 125 | + * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. | |
| 126 | + * | |
| 127 | + * The PTS should belong to the currently played | |
| 128 | + * frame if possible, but may also be a value close to it | |
| 129 | + * like the PTS of the last decoded frame or the last PTS | |
| 130 | + * extracted by the PES parser. | |
| 131 | + */ | |
| 132 | +#define AUDIO_GET_PTS _IOR('o', 19, __u64) | |
| 133 | +#define AUDIO_BILINGUAL_CHANNEL_SELECT _IO('o', 20) | |
| 134 | + | |
| 135 | +#endif /* _DVBAUDIO_H_ */ | |
| @@ -0,0 +1,90 @@ | ||
| 1 | +/* | |
| 2 | + * ca.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de> | |
| 5 | + * & Marcus Metzler <marcus@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU General Lesser Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _DVBCA_H_ | |
| 25 | +#define _DVBCA_H_ | |
| 26 | + | |
| 27 | +/* slot interface types and info */ | |
| 28 | + | |
| 29 | +typedef struct ca_slot_info { | |
| 30 | + int num; /* slot number */ | |
| 31 | + | |
| 32 | + int type; /* CA interface this slot supports */ | |
| 33 | +#define CA_CI 1 /* CI high level interface */ | |
| 34 | +#define CA_CI_LINK 2 /* CI link layer level interface */ | |
| 35 | +#define CA_CI_PHYS 4 /* CI physical layer level interface */ | |
| 36 | +#define CA_DESCR 8 /* built-in descrambler */ | |
| 37 | +#define CA_SC 128 /* simple smart card interface */ | |
| 38 | + | |
| 39 | + unsigned int flags; | |
| 40 | +#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */ | |
| 41 | +#define CA_CI_MODULE_READY 2 | |
| 42 | +} ca_slot_info_t; | |
| 43 | + | |
| 44 | + | |
| 45 | +/* descrambler types and info */ | |
| 46 | + | |
| 47 | +typedef struct ca_descr_info { | |
| 48 | + unsigned int num; /* number of available descramblers (keys) */ | |
| 49 | + unsigned int type; /* type of supported scrambling system */ | |
| 50 | +#define CA_ECD 1 | |
| 51 | +#define CA_NDS 2 | |
| 52 | +#define CA_DSS 4 | |
| 53 | +} ca_descr_info_t; | |
| 54 | + | |
| 55 | +typedef struct ca_caps { | |
| 56 | + unsigned int slot_num; /* total number of CA card and module slots */ | |
| 57 | + unsigned int slot_type; /* OR of all supported types */ | |
| 58 | + unsigned int descr_num; /* total number of descrambler slots (keys) */ | |
| 59 | + unsigned int descr_type; /* OR of all supported types */ | |
| 60 | +} ca_caps_t; | |
| 61 | + | |
| 62 | +/* a message to/from a CI-CAM */ | |
| 63 | +typedef struct ca_msg { | |
| 64 | + unsigned int index; | |
| 65 | + unsigned int type; | |
| 66 | + unsigned int length; | |
| 67 | + unsigned char msg[256]; | |
| 68 | +} ca_msg_t; | |
| 69 | + | |
| 70 | +typedef struct ca_descr { | |
| 71 | + unsigned int index; | |
| 72 | + unsigned int parity; /* 0 == even, 1 == odd */ | |
| 73 | + unsigned char cw[8]; | |
| 74 | +} ca_descr_t; | |
| 75 | + | |
| 76 | +typedef struct ca_pid { | |
| 77 | + unsigned int pid; | |
| 78 | + int index; /* -1 == disable*/ | |
| 79 | +} ca_pid_t; | |
| 80 | + | |
| 81 | +#define CA_RESET _IO('o', 128) | |
| 82 | +#define CA_GET_CAP _IOR('o', 129, ca_caps_t) | |
| 83 | +#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t) | |
| 84 | +#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t) | |
| 85 | +#define CA_GET_MSG _IOR('o', 132, ca_msg_t) | |
| 86 | +#define CA_SEND_MSG _IOW('o', 133, ca_msg_t) | |
| 87 | +#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) | |
| 88 | +#define CA_SET_PID _IOW('o', 135, ca_pid_t) | |
| 89 | + | |
| 90 | +#endif | |
| @@ -0,0 +1,155 @@ | ||
| 1 | +/* | |
| 2 | + * dmx.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de> | |
| 5 | + * & Ralph Metzler <ralph@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU Lesser General Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _UAPI_DVBDMX_H_ | |
| 25 | +#define _UAPI_DVBDMX_H_ | |
| 26 | + | |
| 27 | +#include <linux/types.h> | |
| 28 | +#ifndef __KERNEL__ | |
| 29 | +#include <time.h> | |
| 30 | +#endif | |
| 31 | + | |
| 32 | + | |
| 33 | +#define DMX_FILTER_SIZE 16 | |
| 34 | + | |
| 35 | +typedef enum | |
| 36 | +{ | |
| 37 | + DMX_OUT_DECODER, /* Streaming directly to decoder. */ | |
| 38 | + DMX_OUT_TAP, /* Output going to a memory buffer */ | |
| 39 | + /* (to be retrieved via the read command).*/ | |
| 40 | + DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */ | |
| 41 | + /* (to be retrieved by reading from the */ | |
| 42 | + /* logical DVR device). */ | |
| 43 | + DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */ | |
| 44 | +} dmx_output_t; | |
| 45 | + | |
| 46 | + | |
| 47 | +typedef enum | |
| 48 | +{ | |
| 49 | + DMX_IN_FRONTEND, /* Input from a front-end device. */ | |
| 50 | + DMX_IN_DVR /* Input from the logical DVR device. */ | |
| 51 | +} dmx_input_t; | |
| 52 | + | |
| 53 | + | |
| 54 | +typedef enum | |
| 55 | +{ | |
| 56 | + DMX_PES_AUDIO0, | |
| 57 | + DMX_PES_VIDEO0, | |
| 58 | + DMX_PES_TELETEXT0, | |
| 59 | + DMX_PES_SUBTITLE0, | |
| 60 | + DMX_PES_PCR0, | |
| 61 | + | |
| 62 | + DMX_PES_AUDIO1, | |
| 63 | + DMX_PES_VIDEO1, | |
| 64 | + DMX_PES_TELETEXT1, | |
| 65 | + DMX_PES_SUBTITLE1, | |
| 66 | + DMX_PES_PCR1, | |
| 67 | + | |
| 68 | + DMX_PES_AUDIO2, | |
| 69 | + DMX_PES_VIDEO2, | |
| 70 | + DMX_PES_TELETEXT2, | |
| 71 | + DMX_PES_SUBTITLE2, | |
| 72 | + DMX_PES_PCR2, | |
| 73 | + | |
| 74 | + DMX_PES_AUDIO3, | |
| 75 | + DMX_PES_VIDEO3, | |
| 76 | + DMX_PES_TELETEXT3, | |
| 77 | + DMX_PES_SUBTITLE3, | |
| 78 | + DMX_PES_PCR3, | |
| 79 | + | |
| 80 | + DMX_PES_OTHER | |
| 81 | +} dmx_pes_type_t; | |
| 82 | + | |
| 83 | +#define DMX_PES_AUDIO DMX_PES_AUDIO0 | |
| 84 | +#define DMX_PES_VIDEO DMX_PES_VIDEO0 | |
| 85 | +#define DMX_PES_TELETEXT DMX_PES_TELETEXT0 | |
| 86 | +#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0 | |
| 87 | +#define DMX_PES_PCR DMX_PES_PCR0 | |
| 88 | + | |
| 89 | + | |
| 90 | +typedef struct dmx_filter | |
| 91 | +{ | |
| 92 | + __u8 filter[DMX_FILTER_SIZE]; | |
| 93 | + __u8 mask[DMX_FILTER_SIZE]; | |
| 94 | + __u8 mode[DMX_FILTER_SIZE]; | |
| 95 | +} dmx_filter_t; | |
| 96 | + | |
| 97 | + | |
| 98 | +struct dmx_sct_filter_params | |
| 99 | +{ | |
| 100 | + __u16 pid; | |
| 101 | + dmx_filter_t filter; | |
| 102 | + __u32 timeout; | |
| 103 | + __u32 flags; | |
| 104 | +#define DMX_CHECK_CRC 1 | |
| 105 | +#define DMX_ONESHOT 2 | |
| 106 | +#define DMX_IMMEDIATE_START 4 | |
| 107 | +#define DMX_KERNEL_CLIENT 0x8000 | |
| 108 | +}; | |
| 109 | + | |
| 110 | + | |
| 111 | +struct dmx_pes_filter_params | |
| 112 | +{ | |
| 113 | + __u16 pid; | |
| 114 | + dmx_input_t input; | |
| 115 | + dmx_output_t output; | |
| 116 | + dmx_pes_type_t pes_type; | |
| 117 | + __u32 flags; | |
| 118 | +}; | |
| 119 | + | |
| 120 | +typedef struct dmx_caps { | |
| 121 | + __u32 caps; | |
| 122 | + int num_decoders; | |
| 123 | +} dmx_caps_t; | |
| 124 | + | |
| 125 | +typedef enum { | |
| 126 | + DMX_SOURCE_FRONT0 = 0, | |
| 127 | + DMX_SOURCE_FRONT1, | |
| 128 | + DMX_SOURCE_FRONT2, | |
| 129 | + DMX_SOURCE_FRONT3, | |
| 130 | + DMX_SOURCE_DVR0 = 16, | |
| 131 | + DMX_SOURCE_DVR1, | |
| 132 | + DMX_SOURCE_DVR2, | |
| 133 | + DMX_SOURCE_DVR3 | |
| 134 | +} dmx_source_t; | |
| 135 | + | |
| 136 | +struct dmx_stc { | |
| 137 | + unsigned int num; /* input : which STC? 0..N */ | |
| 138 | + unsigned int base; /* output: divisor for stc to get 90 kHz clock */ | |
| 139 | + __u64 stc; /* output: stc in 'base'*90 kHz units */ | |
| 140 | +}; | |
| 141 | + | |
| 142 | + | |
| 143 | +#define DMX_START _IO('o', 41) | |
| 144 | +#define DMX_STOP _IO('o', 42) | |
| 145 | +#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params) | |
| 146 | +#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) | |
| 147 | +#define DMX_SET_BUFFER_SIZE _IO('o', 45) | |
| 148 | +#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) | |
| 149 | +#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) | |
| 150 | +#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) | |
| 151 | +#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) | |
| 152 | +#define DMX_ADD_PID _IOW('o', 51, __u16) | |
| 153 | +#define DMX_REMOVE_PID _IOW('o', 52, __u16) | |
| 154 | + | |
| 155 | +#endif /* _UAPI_DVBDMX_H_ */ | |
| @@ -0,0 +1,516 @@ | ||
| 1 | +/* | |
| 2 | + * frontend.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de> | |
| 5 | + * Ralph Metzler <ralph@convergence.de> | |
| 6 | + * Holger Waechtler <holger@convergence.de> | |
| 7 | + * Andre Draszik <ad@convergence.de> | |
| 8 | + * for convergence integrated media GmbH | |
| 9 | + * | |
| 10 | + * This program is free software; you can redistribute it and/or | |
| 11 | + * modify it under the terms of the GNU Lesser General Public License | |
| 12 | + * as published by the Free Software Foundation; either version 2.1 | |
| 13 | + * of the License, or (at your option) any later version. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, | |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | + * GNU General Public License for more details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU Lesser General Public License | |
| 21 | + * along with this program; if not, write to the Free Software | |
| 22 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + | |
| 26 | +#ifndef _DVBFRONTEND_H_ | |
| 27 | +#define _DVBFRONTEND_H_ | |
| 28 | + | |
| 29 | +#include <linux/types.h> | |
| 30 | + | |
| 31 | +typedef enum fe_type { | |
| 32 | + FE_QPSK, | |
| 33 | + FE_QAM, | |
| 34 | + FE_OFDM, | |
| 35 | + FE_ATSC | |
| 36 | +} fe_type_t; | |
| 37 | + | |
| 38 | + | |
| 39 | +typedef enum fe_caps { | |
| 40 | + FE_IS_STUPID = 0, | |
| 41 | + FE_CAN_INVERSION_AUTO = 0x1, | |
| 42 | + FE_CAN_FEC_1_2 = 0x2, | |
| 43 | + FE_CAN_FEC_2_3 = 0x4, | |
| 44 | + FE_CAN_FEC_3_4 = 0x8, | |
| 45 | + FE_CAN_FEC_4_5 = 0x10, | |
| 46 | + FE_CAN_FEC_5_6 = 0x20, | |
| 47 | + FE_CAN_FEC_6_7 = 0x40, | |
| 48 | + FE_CAN_FEC_7_8 = 0x80, | |
| 49 | + FE_CAN_FEC_8_9 = 0x100, | |
| 50 | + FE_CAN_FEC_AUTO = 0x200, | |
| 51 | + FE_CAN_QPSK = 0x400, | |
| 52 | + FE_CAN_QAM_16 = 0x800, | |
| 53 | + FE_CAN_QAM_32 = 0x1000, | |
| 54 | + FE_CAN_QAM_64 = 0x2000, | |
| 55 | + FE_CAN_QAM_128 = 0x4000, | |
| 56 | + FE_CAN_QAM_256 = 0x8000, | |
| 57 | + FE_CAN_QAM_AUTO = 0x10000, | |
| 58 | + FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000, | |
| 59 | + FE_CAN_BANDWIDTH_AUTO = 0x40000, | |
| 60 | + FE_CAN_GUARD_INTERVAL_AUTO = 0x80000, | |
| 61 | + FE_CAN_HIERARCHY_AUTO = 0x100000, | |
| 62 | + FE_CAN_8VSB = 0x200000, | |
| 63 | + FE_CAN_16VSB = 0x400000, | |
| 64 | + FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */ | |
| 65 | + FE_CAN_MULTISTREAM = 0x4000000, /* frontend supports multistream filtering */ | |
| 66 | + FE_CAN_TURBO_FEC = 0x8000000, /* frontend supports "turbo fec modulation" */ | |
| 67 | + FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */ | |
| 68 | + FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */ | |
| 69 | + FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */ | |
| 70 | + FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */ | |
| 71 | +} fe_caps_t; | |
| 72 | + | |
| 73 | + | |
| 74 | +struct dvb_frontend_info { | |
| 75 | + char name[128]; | |
| 76 | + fe_type_t type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */ | |
| 77 | + __u32 frequency_min; | |
| 78 | + __u32 frequency_max; | |
| 79 | + __u32 frequency_stepsize; | |
| 80 | + __u32 frequency_tolerance; | |
| 81 | + __u32 symbol_rate_min; | |
| 82 | + __u32 symbol_rate_max; | |
| 83 | + __u32 symbol_rate_tolerance; /* ppm */ | |
| 84 | + __u32 notifier_delay; /* DEPRECATED */ | |
| 85 | + fe_caps_t caps; | |
| 86 | +}; | |
| 87 | + | |
| 88 | + | |
| 89 | +/** | |
| 90 | + * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for | |
| 91 | + * the meaning of this struct... | |
| 92 | + */ | |
| 93 | +struct dvb_diseqc_master_cmd { | |
| 94 | + __u8 msg [6]; /* { framing, address, command, data [3] } */ | |
| 95 | + __u8 msg_len; /* valid values are 3...6 */ | |
| 96 | +}; | |
| 97 | + | |
| 98 | + | |
| 99 | +struct dvb_diseqc_slave_reply { | |
| 100 | + __u8 msg [4]; /* { framing, data [3] } */ | |
| 101 | + __u8 msg_len; /* valid values are 0...4, 0 means no msg */ | |
| 102 | + int timeout; /* return from ioctl after timeout ms with */ | |
| 103 | +}; /* errorcode when no message was received */ | |
| 104 | + | |
| 105 | + | |
| 106 | +typedef enum fe_sec_voltage { | |
| 107 | + SEC_VOLTAGE_13, | |
| 108 | + SEC_VOLTAGE_18, | |
| 109 | + SEC_VOLTAGE_OFF | |
| 110 | +} fe_sec_voltage_t; | |
| 111 | + | |
| 112 | + | |
| 113 | +typedef enum fe_sec_tone_mode { | |
| 114 | + SEC_TONE_ON, | |
| 115 | + SEC_TONE_OFF | |
| 116 | +} fe_sec_tone_mode_t; | |
| 117 | + | |
| 118 | + | |
| 119 | +typedef enum fe_sec_mini_cmd { | |
| 120 | + SEC_MINI_A, | |
| 121 | + SEC_MINI_B | |
| 122 | +} fe_sec_mini_cmd_t; | |
| 123 | + | |
| 124 | + | |
| 125 | +/** | |
| 126 | + * enum fe_status - enumerates the possible frontend status | |
| 127 | + * @FE_HAS_SIGNAL: found something above the noise level | |
| 128 | + * @FE_HAS_CARRIER: found a DVB signal | |
| 129 | + * @FE_HAS_VITERBI: FEC is stable | |
| 130 | + * @FE_HAS_SYNC: found sync bytes | |
| 131 | + * @FE_HAS_LOCK: everything's working | |
| 132 | + * @FE_TIMEDOUT: no lock within the last ~2 seconds | |
| 133 | + * @FE_REINIT: frontend was reinitialized, application is recommended | |
| 134 | + * to reset DiSEqC, tone and parameters | |
| 135 | + */ | |
| 136 | + | |
| 137 | +typedef enum fe_status { | |
| 138 | + FE_HAS_SIGNAL = 0x01, | |
| 139 | + FE_HAS_CARRIER = 0x02, | |
| 140 | + FE_HAS_VITERBI = 0x04, | |
| 141 | + FE_HAS_SYNC = 0x08, | |
| 142 | + FE_HAS_LOCK = 0x10, | |
| 143 | + FE_TIMEDOUT = 0x20, | |
| 144 | + FE_REINIT = 0x40, | |
| 145 | +} fe_status_t; | |
| 146 | + | |
| 147 | +typedef enum fe_spectral_inversion { | |
| 148 | + INVERSION_OFF, | |
| 149 | + INVERSION_ON, | |
| 150 | + INVERSION_AUTO | |
| 151 | +} fe_spectral_inversion_t; | |
| 152 | + | |
| 153 | + | |
| 154 | +typedef enum fe_code_rate { | |
| 155 | + FEC_NONE = 0, | |
| 156 | + FEC_1_2, | |
| 157 | + FEC_2_3, | |
| 158 | + FEC_3_4, | |
| 159 | + FEC_4_5, | |
| 160 | + FEC_5_6, | |
| 161 | + FEC_6_7, | |
| 162 | + FEC_7_8, | |
| 163 | + FEC_8_9, | |
| 164 | + FEC_AUTO, | |
| 165 | + FEC_3_5, | |
| 166 | + FEC_9_10, | |
| 167 | + FEC_2_5, | |
| 168 | +} fe_code_rate_t; | |
| 169 | + | |
| 170 | + | |
| 171 | +typedef enum fe_modulation { | |
| 172 | + QPSK, | |
| 173 | + QAM_16, | |
| 174 | + QAM_32, | |
| 175 | + QAM_64, | |
| 176 | + QAM_128, | |
| 177 | + QAM_256, | |
| 178 | + QAM_AUTO, | |
| 179 | + VSB_8, | |
| 180 | + VSB_16, | |
| 181 | + PSK_8, | |
| 182 | + APSK_16, | |
| 183 | + APSK_32, | |
| 184 | + DQPSK, | |
| 185 | + QAM_4_NR, | |
| 186 | +} fe_modulation_t; | |
| 187 | + | |
| 188 | +typedef enum fe_transmit_mode { | |
| 189 | + TRANSMISSION_MODE_2K, | |
| 190 | + TRANSMISSION_MODE_8K, | |
| 191 | + TRANSMISSION_MODE_AUTO, | |
| 192 | + TRANSMISSION_MODE_4K, | |
| 193 | + TRANSMISSION_MODE_1K, | |
| 194 | + TRANSMISSION_MODE_16K, | |
| 195 | + TRANSMISSION_MODE_32K, | |
| 196 | + TRANSMISSION_MODE_C1, | |
| 197 | + TRANSMISSION_MODE_C3780, | |
| 198 | +} fe_transmit_mode_t; | |
| 199 | + | |
| 200 | +#if defined(__DVB_CORE__) || !defined (__KERNEL__) | |
| 201 | +typedef enum fe_bandwidth { | |
| 202 | + BANDWIDTH_8_MHZ, | |
| 203 | + BANDWIDTH_7_MHZ, | |
| 204 | + BANDWIDTH_6_MHZ, | |
| 205 | + BANDWIDTH_AUTO, | |
| 206 | + BANDWIDTH_5_MHZ, | |
| 207 | + BANDWIDTH_10_MHZ, | |
| 208 | + BANDWIDTH_1_712_MHZ, | |
| 209 | +} fe_bandwidth_t; | |
| 210 | +#endif | |
| 211 | + | |
| 212 | +typedef enum fe_guard_interval { | |
| 213 | + GUARD_INTERVAL_1_32, | |
| 214 | + GUARD_INTERVAL_1_16, | |
| 215 | + GUARD_INTERVAL_1_8, | |
| 216 | + GUARD_INTERVAL_1_4, | |
| 217 | + GUARD_INTERVAL_AUTO, | |
| 218 | + GUARD_INTERVAL_1_128, | |
| 219 | + GUARD_INTERVAL_19_128, | |
| 220 | + GUARD_INTERVAL_19_256, | |
| 221 | + GUARD_INTERVAL_PN420, | |
| 222 | + GUARD_INTERVAL_PN595, | |
| 223 | + GUARD_INTERVAL_PN945, | |
| 224 | +} fe_guard_interval_t; | |
| 225 | + | |
| 226 | + | |
| 227 | +typedef enum fe_hierarchy { | |
| 228 | + HIERARCHY_NONE, | |
| 229 | + HIERARCHY_1, | |
| 230 | + HIERARCHY_2, | |
| 231 | + HIERARCHY_4, | |
| 232 | + HIERARCHY_AUTO | |
| 233 | +} fe_hierarchy_t; | |
| 234 | + | |
| 235 | +enum fe_interleaving { | |
| 236 | + INTERLEAVING_NONE, | |
| 237 | + INTERLEAVING_AUTO, | |
| 238 | + INTERLEAVING_240, | |
| 239 | + INTERLEAVING_720, | |
| 240 | +}; | |
| 241 | + | |
| 242 | +#if defined(__DVB_CORE__) || !defined (__KERNEL__) | |
| 243 | +struct dvb_qpsk_parameters { | |
| 244 | + __u32 symbol_rate; /* symbol rate in Symbols per second */ | |
| 245 | + fe_code_rate_t fec_inner; /* forward error correction (see above) */ | |
| 246 | +}; | |
| 247 | + | |
| 248 | +struct dvb_qam_parameters { | |
| 249 | + __u32 symbol_rate; /* symbol rate in Symbols per second */ | |
| 250 | + fe_code_rate_t fec_inner; /* forward error correction (see above) */ | |
| 251 | + fe_modulation_t modulation; /* modulation type (see above) */ | |
| 252 | +}; | |
| 253 | + | |
| 254 | +struct dvb_vsb_parameters { | |
| 255 | + fe_modulation_t modulation; /* modulation type (see above) */ | |
| 256 | +}; | |
| 257 | + | |
| 258 | +struct dvb_ofdm_parameters { | |
| 259 | + fe_bandwidth_t bandwidth; | |
| 260 | + fe_code_rate_t code_rate_HP; /* high priority stream code rate */ | |
| 261 | + fe_code_rate_t code_rate_LP; /* low priority stream code rate */ | |
| 262 | + fe_modulation_t constellation; /* modulation type (see above) */ | |
| 263 | + fe_transmit_mode_t transmission_mode; | |
| 264 | + fe_guard_interval_t guard_interval; | |
| 265 | + fe_hierarchy_t hierarchy_information; | |
| 266 | +}; | |
| 267 | + | |
| 268 | + | |
| 269 | +struct dvb_frontend_parameters { | |
| 270 | + __u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */ | |
| 271 | + /* intermediate frequency in kHz for QPSK */ | |
| 272 | + fe_spectral_inversion_t inversion; | |
| 273 | + union { | |
| 274 | + struct dvb_qpsk_parameters qpsk; | |
| 275 | + struct dvb_qam_parameters qam; | |
| 276 | + struct dvb_ofdm_parameters ofdm; | |
| 277 | + struct dvb_vsb_parameters vsb; | |
| 278 | + } u; | |
| 279 | +}; | |
| 280 | + | |
| 281 | +struct dvb_frontend_event { | |
| 282 | + fe_status_t status; | |
| 283 | + struct dvb_frontend_parameters parameters; | |
| 284 | +}; | |
| 285 | +#endif | |
| 286 | + | |
| 287 | +/* S2API Commands */ | |
| 288 | +#define DTV_UNDEFINED 0 | |
| 289 | +#define DTV_TUNE 1 | |
| 290 | +#define DTV_CLEAR 2 | |
| 291 | +#define DTV_FREQUENCY 3 | |
| 292 | +#define DTV_MODULATION 4 | |
| 293 | +#define DTV_BANDWIDTH_HZ 5 | |
| 294 | +#define DTV_INVERSION 6 | |
| 295 | +#define DTV_DISEQC_MASTER 7 | |
| 296 | +#define DTV_SYMBOL_RATE 8 | |
| 297 | +#define DTV_INNER_FEC 9 | |
| 298 | +#define DTV_VOLTAGE 10 | |
| 299 | +#define DTV_TONE 11 | |
| 300 | +#define DTV_PILOT 12 | |
| 301 | +#define DTV_ROLLOFF 13 | |
| 302 | +#define DTV_DISEQC_SLAVE_REPLY 14 | |
| 303 | + | |
| 304 | +/* Basic enumeration set for querying unlimited capabilities */ | |
| 305 | +#define DTV_FE_CAPABILITY_COUNT 15 | |
| 306 | +#define DTV_FE_CAPABILITY 16 | |
| 307 | +#define DTV_DELIVERY_SYSTEM 17 | |
| 308 | + | |
| 309 | +/* ISDB-T and ISDB-Tsb */ | |
| 310 | +#define DTV_ISDBT_PARTIAL_RECEPTION 18 | |
| 311 | +#define DTV_ISDBT_SOUND_BROADCASTING 19 | |
| 312 | + | |
| 313 | +#define DTV_ISDBT_SB_SUBCHANNEL_ID 20 | |
| 314 | +#define DTV_ISDBT_SB_SEGMENT_IDX 21 | |
| 315 | +#define DTV_ISDBT_SB_SEGMENT_COUNT 22 | |
| 316 | + | |
| 317 | +#define DTV_ISDBT_LAYERA_FEC 23 | |
| 318 | +#define DTV_ISDBT_LAYERA_MODULATION 24 | |
| 319 | +#define DTV_ISDBT_LAYERA_SEGMENT_COUNT 25 | |
| 320 | +#define DTV_ISDBT_LAYERA_TIME_INTERLEAVING 26 | |
| 321 | + | |
| 322 | +#define DTV_ISDBT_LAYERB_FEC 27 | |
| 323 | +#define DTV_ISDBT_LAYERB_MODULATION 28 | |
| 324 | +#define DTV_ISDBT_LAYERB_SEGMENT_COUNT 29 | |
| 325 | +#define DTV_ISDBT_LAYERB_TIME_INTERLEAVING 30 | |
| 326 | + | |
| 327 | +#define DTV_ISDBT_LAYERC_FEC 31 | |
| 328 | +#define DTV_ISDBT_LAYERC_MODULATION 32 | |
| 329 | +#define DTV_ISDBT_LAYERC_SEGMENT_COUNT 33 | |
| 330 | +#define DTV_ISDBT_LAYERC_TIME_INTERLEAVING 34 | |
| 331 | + | |
| 332 | +#define DTV_API_VERSION 35 | |
| 333 | + | |
| 334 | +#define DTV_CODE_RATE_HP 36 | |
| 335 | +#define DTV_CODE_RATE_LP 37 | |
| 336 | +#define DTV_GUARD_INTERVAL 38 | |
| 337 | +#define DTV_TRANSMISSION_MODE 39 | |
| 338 | +#define DTV_HIERARCHY 40 | |
| 339 | + | |
| 340 | +#define DTV_ISDBT_LAYER_ENABLED 41 | |
| 341 | + | |
| 342 | +#define DTV_STREAM_ID 42 | |
| 343 | +#define DTV_ISDBS_TS_ID_LEGACY DTV_STREAM_ID | |
| 344 | +#define DTV_DVBT2_PLP_ID_LEGACY 43 | |
| 345 | + | |
| 346 | +#define DTV_ENUM_DELSYS 44 | |
| 347 | + | |
| 348 | +/* ATSC-MH */ | |
| 349 | +#define DTV_ATSCMH_FIC_VER 45 | |
| 350 | +#define DTV_ATSCMH_PARADE_ID 46 | |
| 351 | +#define DTV_ATSCMH_NOG 47 | |
| 352 | +#define DTV_ATSCMH_TNOG 48 | |
| 353 | +#define DTV_ATSCMH_SGN 49 | |
| 354 | +#define DTV_ATSCMH_PRC 50 | |
| 355 | +#define DTV_ATSCMH_RS_FRAME_MODE 51 | |
| 356 | +#define DTV_ATSCMH_RS_FRAME_ENSEMBLE 52 | |
| 357 | +#define DTV_ATSCMH_RS_CODE_MODE_PRI 53 | |
| 358 | +#define DTV_ATSCMH_RS_CODE_MODE_SEC 54 | |
| 359 | +#define DTV_ATSCMH_SCCC_BLOCK_MODE 55 | |
| 360 | +#define DTV_ATSCMH_SCCC_CODE_MODE_A 56 | |
| 361 | +#define DTV_ATSCMH_SCCC_CODE_MODE_B 57 | |
| 362 | +#define DTV_ATSCMH_SCCC_CODE_MODE_C 58 | |
| 363 | +#define DTV_ATSCMH_SCCC_CODE_MODE_D 59 | |
| 364 | + | |
| 365 | +#define DTV_INTERLEAVING 60 | |
| 366 | +#define DTV_LNA 61 | |
| 367 | + | |
| 368 | +#define DTV_MAX_COMMAND DTV_LNA | |
| 369 | + | |
| 370 | +typedef enum fe_pilot { | |
| 371 | + PILOT_ON, | |
| 372 | + PILOT_OFF, | |
| 373 | + PILOT_AUTO, | |
| 374 | +} fe_pilot_t; | |
| 375 | + | |
| 376 | +typedef enum fe_rolloff { | |
| 377 | + ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */ | |
| 378 | + ROLLOFF_20, | |
| 379 | + ROLLOFF_25, | |
| 380 | + ROLLOFF_AUTO, | |
| 381 | +} fe_rolloff_t; | |
| 382 | + | |
| 383 | +typedef enum fe_delivery_system { | |
| 384 | + SYS_UNDEFINED, | |
| 385 | + SYS_DVBC_ANNEX_A, | |
| 386 | + SYS_DVBC_ANNEX_B, | |
| 387 | + SYS_DVBT, | |
| 388 | + SYS_DSS, | |
| 389 | + SYS_DVBS, | |
| 390 | + SYS_DVBS2, | |
| 391 | + SYS_DVBH, | |
| 392 | + SYS_ISDBT, | |
| 393 | + SYS_ISDBS, | |
| 394 | + SYS_ISDBC, | |
| 395 | + SYS_ATSC, | |
| 396 | + SYS_ATSCMH, | |
| 397 | + SYS_DTMB, | |
| 398 | + SYS_CMMB, | |
| 399 | + SYS_DAB, | |
| 400 | + SYS_DVBT2, | |
| 401 | + SYS_TURBO, | |
| 402 | + SYS_DVBC_ANNEX_C, | |
| 403 | +} fe_delivery_system_t; | |
| 404 | + | |
| 405 | +/* backward compatibility */ | |
| 406 | +#define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A | |
| 407 | +#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB instead */ | |
| 408 | + | |
| 409 | +/* ATSC-MH */ | |
| 410 | + | |
| 411 | +enum atscmh_sccc_block_mode { | |
| 412 | + ATSCMH_SCCC_BLK_SEP = 0, | |
| 413 | + ATSCMH_SCCC_BLK_COMB = 1, | |
| 414 | + ATSCMH_SCCC_BLK_RES = 2, | |
| 415 | +}; | |
| 416 | + | |
| 417 | +enum atscmh_sccc_code_mode { | |
| 418 | + ATSCMH_SCCC_CODE_HLF = 0, | |
| 419 | + ATSCMH_SCCC_CODE_QTR = 1, | |
| 420 | + ATSCMH_SCCC_CODE_RES = 2, | |
| 421 | +}; | |
| 422 | + | |
| 423 | +enum atscmh_rs_frame_ensemble { | |
| 424 | + ATSCMH_RSFRAME_ENS_PRI = 0, | |
| 425 | + ATSCMH_RSFRAME_ENS_SEC = 1, | |
| 426 | +}; | |
| 427 | + | |
| 428 | +enum atscmh_rs_frame_mode { | |
| 429 | + ATSCMH_RSFRAME_PRI_ONLY = 0, | |
| 430 | + ATSCMH_RSFRAME_PRI_SEC = 1, | |
| 431 | + ATSCMH_RSFRAME_RES = 2, | |
| 432 | +}; | |
| 433 | + | |
| 434 | +enum atscmh_rs_code_mode { | |
| 435 | + ATSCMH_RSCODE_211_187 = 0, | |
| 436 | + ATSCMH_RSCODE_223_187 = 1, | |
| 437 | + ATSCMH_RSCODE_235_187 = 2, | |
| 438 | + ATSCMH_RSCODE_RES = 3, | |
| 439 | +}; | |
| 440 | + | |
| 441 | +#define NO_STREAM_ID_FILTER (~0U) | |
| 442 | +#define LNA_AUTO (~0U) | |
| 443 | + | |
| 444 | +struct dtv_cmds_h { | |
| 445 | + char *name; /* A display name for debugging purposes */ | |
| 446 | + | |
| 447 | + __u32 cmd; /* A unique ID */ | |
| 448 | + | |
| 449 | + /* Flags */ | |
| 450 | + __u32 set:1; /* Either a set or get property */ | |
| 451 | + __u32 buffer:1; /* Does this property use the buffer? */ | |
| 452 | + __u32 reserved:30; /* Align */ | |
| 453 | +}; | |
| 454 | + | |
| 455 | +struct dtv_property { | |
| 456 | + __u32 cmd; | |
| 457 | + __u32 reserved[3]; | |
| 458 | + union { | |
| 459 | + __u32 data; | |
| 460 | + struct { | |
| 461 | + __u8 data[32]; | |
| 462 | + __u32 len; | |
| 463 | + __u32 reserved1[3]; | |
| 464 | + void *reserved2; | |
| 465 | + } buffer; | |
| 466 | + } u; | |
| 467 | + int result; | |
| 468 | +} __attribute__ ((packed)); | |
| 469 | + | |
| 470 | +/* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */ | |
| 471 | +#define DTV_IOCTL_MAX_MSGS 64 | |
| 472 | + | |
| 473 | +struct dtv_properties { | |
| 474 | + __u32 num; | |
| 475 | + struct dtv_property *props; | |
| 476 | +}; | |
| 477 | + | |
| 478 | +#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties) | |
| 479 | +#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties) | |
| 480 | + | |
| 481 | + | |
| 482 | +/** | |
| 483 | + * When set, this flag will disable any zigzagging or other "normal" tuning | |
| 484 | + * behaviour. Additionally, there will be no automatic monitoring of the lock | |
| 485 | + * status, and hence no frontend events will be generated. If a frontend device | |
| 486 | + * is closed, this flag will be automatically turned off when the device is | |
| 487 | + * reopened read-write. | |
| 488 | + */ | |
| 489 | +#define FE_TUNE_MODE_ONESHOT 0x01 | |
| 490 | + | |
| 491 | + | |
| 492 | +#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info) | |
| 493 | + | |
| 494 | +#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62) | |
| 495 | +#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd) | |
| 496 | +#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply) | |
| 497 | +#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */ | |
| 498 | + | |
| 499 | +#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */ | |
| 500 | +#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */ | |
| 501 | +#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */ | |
| 502 | + | |
| 503 | +#define FE_READ_STATUS _IOR('o', 69, fe_status_t) | |
| 504 | +#define FE_READ_BER _IOR('o', 70, __u32) | |
| 505 | +#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16) | |
| 506 | +#define FE_READ_SNR _IOR('o', 72, __u16) | |
| 507 | +#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32) | |
| 508 | + | |
| 509 | +#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) | |
| 510 | +#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) | |
| 511 | +#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */ | |
| 512 | +#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event) | |
| 513 | + | |
| 514 | +#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */ | |
| 515 | + | |
| 516 | +#endif /*_DVBFRONTEND_H_*/ | |
| @@ -0,0 +1,52 @@ | ||
| 1 | +/* | |
| 2 | + * net.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de> | |
| 5 | + * & Ralph Metzler <ralph@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU Lesser General Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _DVBNET_H_ | |
| 25 | +#define _DVBNET_H_ | |
| 26 | + | |
| 27 | +#include <linux/types.h> | |
| 28 | + | |
| 29 | +struct dvb_net_if { | |
| 30 | + __u16 pid; | |
| 31 | + __u16 if_num; | |
| 32 | + __u8 feedtype; | |
| 33 | +#define DVB_NET_FEEDTYPE_MPE 0 /* multi protocol encapsulation */ | |
| 34 | +#define DVB_NET_FEEDTYPE_ULE 1 /* ultra lightweight encapsulation */ | |
| 35 | +}; | |
| 36 | + | |
| 37 | + | |
| 38 | +#define NET_ADD_IF _IOWR('o', 52, struct dvb_net_if) | |
| 39 | +#define NET_REMOVE_IF _IO('o', 53) | |
| 40 | +#define NET_GET_IF _IOWR('o', 54, struct dvb_net_if) | |
| 41 | + | |
| 42 | + | |
| 43 | +/* binary compatibility cruft: */ | |
| 44 | +struct __dvb_net_if_old { | |
| 45 | + __u16 pid; | |
| 46 | + __u16 if_num; | |
| 47 | +}; | |
| 48 | +#define __NET_ADD_IF_OLD _IOWR('o', 52, struct __dvb_net_if_old) | |
| 49 | +#define __NET_GET_IF_OLD _IOWR('o', 54, struct __dvb_net_if_old) | |
| 50 | + | |
| 51 | + | |
| 52 | +#endif /*_DVBNET_H_*/ | |
| @@ -0,0 +1,144 @@ | ||
| 1 | +/* | |
| 2 | + * osd.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2001 Ralph Metzler <ralph@convergence.de> | |
| 5 | + * & Marcus Metzler <marcus@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU General Lesser Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _DVBOSD_H_ | |
| 25 | +#define _DVBOSD_H_ | |
| 26 | + | |
| 27 | +#include <linux/compiler.h> | |
| 28 | + | |
| 29 | +typedef enum { | |
| 30 | + // All functions return -2 on "not open" | |
| 31 | + OSD_Close=1, // () | |
| 32 | + // Disables OSD and releases the buffers | |
| 33 | + // returns 0 on success | |
| 34 | + OSD_Open, // (x0,y0,x1,y1,BitPerPixel[2/4/8](color&0x0F),mix[0..15](color&0xF0)) | |
| 35 | + // Opens OSD with this size and bit depth | |
| 36 | + // returns 0 on success, -1 on DRAM allocation error, -2 on "already open" | |
| 37 | + OSD_Show, // () | |
| 38 | + // enables OSD mode | |
| 39 | + // returns 0 on success | |
| 40 | + OSD_Hide, // () | |
| 41 | + // disables OSD mode | |
| 42 | + // returns 0 on success | |
| 43 | + OSD_Clear, // () | |
| 44 | + // Sets all pixel to color 0 | |
| 45 | + // returns 0 on success | |
| 46 | + OSD_Fill, // (color) | |
| 47 | + // Sets all pixel to color <col> | |
| 48 | + // returns 0 on success | |
| 49 | + OSD_SetColor, // (color,R{x0},G{y0},B{x1},opacity{y1}) | |
| 50 | + // set palette entry <num> to <r,g,b>, <mix> and <trans> apply | |
| 51 | + // R,G,B: 0..255 | |
| 52 | + // R=Red, G=Green, B=Blue | |
| 53 | + // opacity=0: pixel opacity 0% (only video pixel shows) | |
| 54 | + // opacity=1..254: pixel opacity as specified in header | |
| 55 | + // opacity=255: pixel opacity 100% (only OSD pixel shows) | |
| 56 | + // returns 0 on success, -1 on error | |
| 57 | + OSD_SetPalette, // (firstcolor{color},lastcolor{x0},data) | |
| 58 | + // Set a number of entries in the palette | |
| 59 | + // sets the entries "firstcolor" through "lastcolor" from the array "data" | |
| 60 | + // data has 4 byte for each color: | |
| 61 | + // R,G,B, and a opacity value: 0->transparent, 1..254->mix, 255->pixel | |
| 62 | + OSD_SetTrans, // (transparency{color}) | |
| 63 | + // Sets transparency of mixed pixel (0..15) | |
| 64 | + // returns 0 on success | |
| 65 | + OSD_SetPixel, // (x0,y0,color) | |
| 66 | + // sets pixel <x>,<y> to color number <col> | |
| 67 | + // returns 0 on success, -1 on error | |
| 68 | + OSD_GetPixel, // (x0,y0) | |
| 69 | + // returns color number of pixel <x>,<y>, or -1 | |
| 70 | + OSD_SetRow, // (x0,y0,x1,data) | |
| 71 | + // fills pixels x0,y through x1,y with the content of data[] | |
| 72 | + // returns 0 on success, -1 on clipping all pixel (no pixel drawn) | |
| 73 | + OSD_SetBlock, // (x0,y0,x1,y1,increment{color},data) | |
| 74 | + // fills pixels x0,y0 through x1,y1 with the content of data[] | |
| 75 | + // inc contains the width of one line in the data block, | |
| 76 | + // inc<=0 uses blockwidth as linewidth | |
| 77 | + // returns 0 on success, -1 on clipping all pixel | |
| 78 | + OSD_FillRow, // (x0,y0,x1,color) | |
| 79 | + // fills pixels x0,y through x1,y with the color <col> | |
| 80 | + // returns 0 on success, -1 on clipping all pixel | |
| 81 | + OSD_FillBlock, // (x0,y0,x1,y1,color) | |
| 82 | + // fills pixels x0,y0 through x1,y1 with the color <col> | |
| 83 | + // returns 0 on success, -1 on clipping all pixel | |
| 84 | + OSD_Line, // (x0,y0,x1,y1,color) | |
| 85 | + // draw a line from x0,y0 to x1,y1 with the color <col> | |
| 86 | + // returns 0 on success | |
| 87 | + OSD_Query, // (x0,y0,x1,y1,xasp{color}}), yasp=11 | |
| 88 | + // fills parameters with the picture dimensions and the pixel aspect ratio | |
| 89 | + // returns 0 on success | |
| 90 | + OSD_Test, // () | |
| 91 | + // draws a test picture. for debugging purposes only | |
| 92 | + // returns 0 on success | |
| 93 | +// TODO: remove "test" in final version | |
| 94 | + OSD_Text, // (x0,y0,size,color,text) | |
| 95 | + OSD_SetWindow, // (x0) set window with number 0<x0<8 as current | |
| 96 | + OSD_MoveWindow, // move current window to (x0, y0) | |
| 97 | + OSD_OpenRaw, // Open other types of OSD windows | |
| 98 | +} OSD_Command; | |
| 99 | + | |
| 100 | +typedef struct osd_cmd_s { | |
| 101 | + OSD_Command cmd; | |
| 102 | + int x0; | |
| 103 | + int y0; | |
| 104 | + int x1; | |
| 105 | + int y1; | |
| 106 | + int color; | |
| 107 | + void __user *data; | |
| 108 | +} osd_cmd_t; | |
| 109 | + | |
| 110 | +/* OSD_OpenRaw: set 'color' to desired window type */ | |
| 111 | +typedef enum { | |
| 112 | + OSD_BITMAP1, /* 1 bit bitmap */ | |
| 113 | + OSD_BITMAP2, /* 2 bit bitmap */ | |
| 114 | + OSD_BITMAP4, /* 4 bit bitmap */ | |
| 115 | + OSD_BITMAP8, /* 8 bit bitmap */ | |
| 116 | + OSD_BITMAP1HR, /* 1 Bit bitmap half resolution */ | |
| 117 | + OSD_BITMAP2HR, /* 2 bit bitmap half resolution */ | |
| 118 | + OSD_BITMAP4HR, /* 4 bit bitmap half resolution */ | |
| 119 | + OSD_BITMAP8HR, /* 8 bit bitmap half resolution */ | |
| 120 | + OSD_YCRCB422, /* 4:2:2 YCRCB Graphic Display */ | |
| 121 | + OSD_YCRCB444, /* 4:4:4 YCRCB Graphic Display */ | |
| 122 | + OSD_YCRCB444HR, /* 4:4:4 YCRCB graphic half resolution */ | |
| 123 | + OSD_VIDEOTSIZE, /* True Size Normal MPEG Video Display */ | |
| 124 | + OSD_VIDEOHSIZE, /* MPEG Video Display Half Resolution */ | |
| 125 | + OSD_VIDEOQSIZE, /* MPEG Video Display Quarter Resolution */ | |
| 126 | + OSD_VIDEODSIZE, /* MPEG Video Display Double Resolution */ | |
| 127 | + OSD_VIDEOTHSIZE, /* True Size MPEG Video Display Half Resolution */ | |
| 128 | + OSD_VIDEOTQSIZE, /* True Size MPEG Video Display Quarter Resolution*/ | |
| 129 | + OSD_VIDEOTDSIZE, /* True Size MPEG Video Display Double Resolution */ | |
| 130 | + OSD_VIDEONSIZE, /* Full Size MPEG Video Display */ | |
| 131 | + OSD_CURSOR /* Cursor */ | |
| 132 | +} osd_raw_window_t; | |
| 133 | + | |
| 134 | +typedef struct osd_cap_s { | |
| 135 | + int cmd; | |
| 136 | +#define OSD_CAP_MEMSIZE 1 /* memory size */ | |
| 137 | + long val; | |
| 138 | +} osd_cap_t; | |
| 139 | + | |
| 140 | + | |
| 141 | +#define OSD_SEND_CMD _IOW('o', 160, osd_cmd_t) | |
| 142 | +#define OSD_GET_CAPABILITY _IOR('o', 161, osd_cap_t) | |
| 143 | + | |
| 144 | +#endif | |
| @@ -0,0 +1,29 @@ | ||
| 1 | +/* | |
| 2 | + * version.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Holger Waechtler <holger@convergence.de> | |
| 5 | + * for convergence integrated media GmbH | |
| 6 | + * | |
| 7 | + * This program is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License | |
| 9 | + * as published by the Free Software Foundation; either version 2.1 | |
| 10 | + * of the License, or (at your option) any later version. | |
| 11 | + * | |
| 12 | + * This program is distributed in the hope that it will be useful, | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | + * GNU General Public License for more details. | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU Lesser General Public License | |
| 18 | + * along with this program; if not, write to the Free Software | |
| 19 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 20 | + * | |
| 21 | + */ | |
| 22 | + | |
| 23 | +#ifndef _DVBVERSION_H_ | |
| 24 | +#define _DVBVERSION_H_ | |
| 25 | + | |
| 26 | +#define DVB_API_VERSION 5 | |
| 27 | +#define DVB_API_VERSION_MINOR 9 | |
| 28 | + | |
| 29 | +#endif /*_DVBVERSION_H_*/ | |
| @@ -0,0 +1,274 @@ | ||
| 1 | +/* | |
| 2 | + * video.h | |
| 3 | + * | |
| 4 | + * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de> | |
| 5 | + * & Ralph Metzler <ralph@convergence.de> | |
| 6 | + * for convergence integrated media GmbH | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU Lesser General Public License | |
| 10 | + * as published by the Free Software Foundation; either version 2.1 | |
| 11 | + * of the License, or (at your option) any later version. | |
| 12 | + * | |
| 13 | + * This program is distributed in the hope that it will be useful, | |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + * GNU General Public License for more details. | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU Lesser General Public License | |
| 19 | + * along with this program; if not, write to the Free Software | |
| 20 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef _UAPI_DVBVIDEO_H_ | |
| 25 | +#define _UAPI_DVBVIDEO_H_ | |
| 26 | + | |
| 27 | +#include <linux/types.h> | |
| 28 | +#ifndef __KERNEL__ | |
| 29 | +#include <stdint.h> | |
| 30 | +#include <time.h> | |
| 31 | +#endif | |
| 32 | + | |
| 33 | +typedef enum { | |
| 34 | + VIDEO_FORMAT_4_3, /* Select 4:3 format */ | |
| 35 | + VIDEO_FORMAT_16_9, /* Select 16:9 format. */ | |
| 36 | + VIDEO_FORMAT_221_1 /* 2.21:1 */ | |
| 37 | +} video_format_t; | |
| 38 | + | |
| 39 | + | |
| 40 | +typedef enum { | |
| 41 | + VIDEO_SYSTEM_PAL, | |
| 42 | + VIDEO_SYSTEM_NTSC, | |
| 43 | + VIDEO_SYSTEM_PALN, | |
| 44 | + VIDEO_SYSTEM_PALNc, | |
| 45 | + VIDEO_SYSTEM_PALM, | |
| 46 | + VIDEO_SYSTEM_NTSC60, | |
| 47 | + VIDEO_SYSTEM_PAL60, | |
| 48 | + VIDEO_SYSTEM_PALM60 | |
| 49 | +} video_system_t; | |
| 50 | + | |
| 51 | + | |
| 52 | +typedef enum { | |
| 53 | + VIDEO_PAN_SCAN, /* use pan and scan format */ | |
| 54 | + VIDEO_LETTER_BOX, /* use letterbox format */ | |
| 55 | + VIDEO_CENTER_CUT_OUT /* use center cut out format */ | |
| 56 | +} video_displayformat_t; | |
| 57 | + | |
| 58 | +typedef struct { | |
| 59 | + int w; | |
| 60 | + int h; | |
| 61 | + video_format_t aspect_ratio; | |
| 62 | +} video_size_t; | |
| 63 | + | |
| 64 | +typedef enum { | |
| 65 | + VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */ | |
| 66 | + VIDEO_SOURCE_MEMORY /* If this source is selected, the stream | |
| 67 | + comes from the user through the write | |
| 68 | + system call */ | |
| 69 | +} video_stream_source_t; | |
| 70 | + | |
| 71 | + | |
| 72 | +typedef enum { | |
| 73 | + VIDEO_STOPPED, /* Video is stopped */ | |
| 74 | + VIDEO_PLAYING, /* Video is currently playing */ | |
| 75 | + VIDEO_FREEZED /* Video is freezed */ | |
| 76 | +} video_play_state_t; | |
| 77 | + | |
| 78 | + | |
| 79 | +/* Decoder commands */ | |
| 80 | +#define VIDEO_CMD_PLAY (0) | |
| 81 | +#define VIDEO_CMD_STOP (1) | |
| 82 | +#define VIDEO_CMD_FREEZE (2) | |
| 83 | +#define VIDEO_CMD_CONTINUE (3) | |
| 84 | + | |
| 85 | +/* Flags for VIDEO_CMD_FREEZE */ | |
| 86 | +#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) | |
| 87 | + | |
| 88 | +/* Flags for VIDEO_CMD_STOP */ | |
| 89 | +#define VIDEO_CMD_STOP_TO_BLACK (1 << 0) | |
| 90 | +#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) | |
| 91 | + | |
| 92 | +/* Play input formats: */ | |
| 93 | +/* The decoder has no special format requirements */ | |
| 94 | +#define VIDEO_PLAY_FMT_NONE (0) | |
| 95 | +/* The decoder requires full GOPs */ | |
| 96 | +#define VIDEO_PLAY_FMT_GOP (1) | |
| 97 | + | |
| 98 | +/* The structure must be zeroed before use by the application | |
| 99 | + This ensures it can be extended safely in the future. */ | |
| 100 | +struct video_command { | |
| 101 | + __u32 cmd; | |
| 102 | + __u32 flags; | |
| 103 | + union { | |
| 104 | + struct { | |
| 105 | + __u64 pts; | |
| 106 | + } stop; | |
| 107 | + | |
| 108 | + struct { | |
| 109 | + /* 0 or 1000 specifies normal speed, | |
| 110 | + 1 specifies forward single stepping, | |
| 111 | + -1 specifies backward single stepping, | |
| 112 | + >1: playback at speed/1000 of the normal speed, | |
| 113 | + <-1: reverse playback at (-speed/1000) of the normal speed. */ | |
| 114 | + __s32 speed; | |
| 115 | + __u32 format; | |
| 116 | + } play; | |
| 117 | + | |
| 118 | + struct { | |
| 119 | + __u32 data[16]; | |
| 120 | + } raw; | |
| 121 | + }; | |
| 122 | +}; | |
| 123 | + | |
| 124 | +/* FIELD_UNKNOWN can be used if the hardware does not know whether | |
| 125 | + the Vsync is for an odd, even or progressive (i.e. non-interlaced) | |
| 126 | + field. */ | |
| 127 | +#define VIDEO_VSYNC_FIELD_UNKNOWN (0) | |
| 128 | +#define VIDEO_VSYNC_FIELD_ODD (1) | |
| 129 | +#define VIDEO_VSYNC_FIELD_EVEN (2) | |
| 130 | +#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3) | |
| 131 | + | |
| 132 | +struct video_event { | |
| 133 | + __s32 type; | |
| 134 | +#define VIDEO_EVENT_SIZE_CHANGED 1 | |
| 135 | +#define VIDEO_EVENT_FRAME_RATE_CHANGED 2 | |
| 136 | +#define VIDEO_EVENT_DECODER_STOPPED 3 | |
| 137 | +#define VIDEO_EVENT_VSYNC 4 | |
| 138 | + __kernel_time_t timestamp; | |
| 139 | + union { | |
| 140 | + video_size_t size; | |
| 141 | + unsigned int frame_rate; /* in frames per 1000sec */ | |
| 142 | + unsigned char vsync_field; /* unknown/odd/even/progressive */ | |
| 143 | + } u; | |
| 144 | +}; | |
| 145 | + | |
| 146 | + | |
| 147 | +struct video_status { | |
| 148 | + int video_blank; /* blank video on freeze? */ | |
| 149 | + video_play_state_t play_state; /* current state of playback */ | |
| 150 | + video_stream_source_t stream_source; /* current source (demux/memory) */ | |
| 151 | + video_format_t video_format; /* current aspect ratio of stream*/ | |
| 152 | + video_displayformat_t display_format;/* selected cropping mode */ | |
| 153 | +}; | |
| 154 | + | |
| 155 | + | |
| 156 | +struct video_still_picture { | |
| 157 | + char __user *iFrame; /* pointer to a single iframe in memory */ | |
| 158 | + __s32 size; | |
| 159 | +}; | |
| 160 | + | |
| 161 | + | |
| 162 | +typedef | |
| 163 | +struct video_highlight { | |
| 164 | + int active; /* 1=show highlight, 0=hide highlight */ | |
| 165 | + __u8 contrast1; /* 7- 4 Pattern pixel contrast */ | |
| 166 | + /* 3- 0 Background pixel contrast */ | |
| 167 | + __u8 contrast2; /* 7- 4 Emphasis pixel-2 contrast */ | |
| 168 | + /* 3- 0 Emphasis pixel-1 contrast */ | |
| 169 | + __u8 color1; /* 7- 4 Pattern pixel color */ | |
| 170 | + /* 3- 0 Background pixel color */ | |
| 171 | + __u8 color2; /* 7- 4 Emphasis pixel-2 color */ | |
| 172 | + /* 3- 0 Emphasis pixel-1 color */ | |
| 173 | + __u32 ypos; /* 23-22 auto action mode */ | |
| 174 | + /* 21-12 start y */ | |
| 175 | + /* 9- 0 end y */ | |
| 176 | + __u32 xpos; /* 23-22 button color number */ | |
| 177 | + /* 21-12 start x */ | |
| 178 | + /* 9- 0 end x */ | |
| 179 | +} video_highlight_t; | |
| 180 | + | |
| 181 | + | |
| 182 | +typedef struct video_spu { | |
| 183 | + int active; | |
| 184 | + int stream_id; | |
| 185 | +} video_spu_t; | |
| 186 | + | |
| 187 | + | |
| 188 | +typedef struct video_spu_palette { /* SPU Palette information */ | |
| 189 | + int length; | |
| 190 | + __u8 __user *palette; | |
| 191 | +} video_spu_palette_t; | |
| 192 | + | |
| 193 | + | |
| 194 | +typedef struct video_navi_pack { | |
| 195 | + int length; /* 0 ... 1024 */ | |
| 196 | + __u8 data[1024]; | |
| 197 | +} video_navi_pack_t; | |
| 198 | + | |
| 199 | + | |
| 200 | +typedef __u16 video_attributes_t; | |
| 201 | +/* bits: descr. */ | |
| 202 | +/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */ | |
| 203 | +/* 13-12 TV system (0=525/60, 1=625/50) */ | |
| 204 | +/* 11-10 Aspect ratio (0=4:3, 3=16:9) */ | |
| 205 | +/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */ | |
| 206 | +/* 7 line 21-1 data present in GOP (1=yes, 0=no) */ | |
| 207 | +/* 6 line 21-2 data present in GOP (1=yes, 0=no) */ | |
| 208 | +/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */ | |
| 209 | +/* 2 source letterboxed (1=yes, 0=no) */ | |
| 210 | +/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */ | |
| 211 | + | |
| 212 | + | |
| 213 | +/* bit definitions for capabilities: */ | |
| 214 | +/* can the hardware decode MPEG1 and/or MPEG2? */ | |
| 215 | +#define VIDEO_CAP_MPEG1 1 | |
| 216 | +#define VIDEO_CAP_MPEG2 2 | |
| 217 | +/* can you send a system and/or program stream to video device? | |
| 218 | + (you still have to open the video and the audio device but only | |
| 219 | + send the stream to the video device) */ | |
| 220 | +#define VIDEO_CAP_SYS 4 | |
| 221 | +#define VIDEO_CAP_PROG 8 | |
| 222 | +/* can the driver also handle SPU, NAVI and CSS encoded data? | |
| 223 | + (CSS API is not present yet) */ | |
| 224 | +#define VIDEO_CAP_SPU 16 | |
| 225 | +#define VIDEO_CAP_NAVI 32 | |
| 226 | +#define VIDEO_CAP_CSS 64 | |
| 227 | + | |
| 228 | + | |
| 229 | +#define VIDEO_STOP _IO('o', 21) | |
| 230 | +#define VIDEO_PLAY _IO('o', 22) | |
| 231 | +#define VIDEO_FREEZE _IO('o', 23) | |
| 232 | +#define VIDEO_CONTINUE _IO('o', 24) | |
| 233 | +#define VIDEO_SELECT_SOURCE _IO('o', 25) | |
| 234 | +#define VIDEO_SET_BLANK _IO('o', 26) | |
| 235 | +#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status) | |
| 236 | +#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event) | |
| 237 | +#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29) | |
| 238 | +#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture) | |
| 239 | +#define VIDEO_FAST_FORWARD _IO('o', 31) | |
| 240 | +#define VIDEO_SLOWMOTION _IO('o', 32) | |
| 241 | +#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int) | |
| 242 | +#define VIDEO_CLEAR_BUFFER _IO('o', 34) | |
| 243 | +#define VIDEO_SET_ID _IO('o', 35) | |
| 244 | +#define VIDEO_SET_STREAMTYPE _IO('o', 36) | |
| 245 | +#define VIDEO_SET_FORMAT _IO('o', 37) | |
| 246 | +#define VIDEO_SET_SYSTEM _IO('o', 38) | |
| 247 | +#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t) | |
| 248 | +#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t) | |
| 249 | +#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t) | |
| 250 | +#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t) | |
| 251 | +#define VIDEO_SET_ATTRIBUTES _IO('o', 53) | |
| 252 | +#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t) | |
| 253 | +#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int) | |
| 254 | + | |
| 255 | +/** | |
| 256 | + * VIDEO_GET_PTS | |
| 257 | + * | |
| 258 | + * Read the 33 bit presentation time stamp as defined | |
| 259 | + * in ITU T-REC-H.222.0 / ISO/IEC 13818-1. | |
| 260 | + * | |
| 261 | + * The PTS should belong to the currently played | |
| 262 | + * frame if possible, but may also be a value close to it | |
| 263 | + * like the PTS of the last decoded frame or the last PTS | |
| 264 | + * extracted by the PES parser. | |
| 265 | + */ | |
| 266 | +#define VIDEO_GET_PTS _IOR('o', 57, __u64) | |
| 267 | + | |
| 268 | +/* Read the number of displayed frames since the decoder was started */ | |
| 269 | +#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64) | |
| 270 | + | |
| 271 | +#define VIDEO_COMMAND _IOWR('o', 59, struct video_command) | |
| 272 | +#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command) | |
| 273 | + | |
| 274 | +#endif /* _UAPI_DVBVIDEO_H_ */ | |
| @@ -1 +1,2 @@ | ||
| 1 | 1 | # UAPI Header export list |
| 2 | +header-y += hsi_char.h | |
| @@ -0,0 +1,63 @@ | ||
| 1 | +/* | |
| 2 | + * Part of the HSI character device driver. | |
| 3 | + * | |
| 4 | + * Copyright (C) 2010 Nokia Corporation. All rights reserved. | |
| 5 | + * | |
| 6 | + * Contact: Andras Domokos <andras.domokos at nokia.com> | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or | |
| 9 | + * modify it under the terms of the GNU General Public License | |
| 10 | + * version 2 as published by the Free Software Foundation. | |
| 11 | + * | |
| 12 | + * This program is distributed in the hope that it will be useful, but | |
| 13 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 | + * General Public License for more details. | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License | |
| 18 | + * along with this program; if not, write to the Free Software | |
| 19 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 20 | + * 02110-1301 USA | |
| 21 | + */ | |
| 22 | + | |
| 23 | + | |
| 24 | +#ifndef __HSI_CHAR_H | |
| 25 | +#define __HSI_CHAR_H | |
| 26 | + | |
| 27 | +#define HSI_CHAR_MAGIC 'k' | |
| 28 | +#define HSC_IOW(num, dtype) _IOW(HSI_CHAR_MAGIC, num, dtype) | |
| 29 | +#define HSC_IOR(num, dtype) _IOR(HSI_CHAR_MAGIC, num, dtype) | |
| 30 | +#define HSC_IOWR(num, dtype) _IOWR(HSI_CHAR_MAGIC, num, dtype) | |
| 31 | +#define HSC_IO(num) _IO(HSI_CHAR_MAGIC, num) | |
| 32 | + | |
| 33 | +#define HSC_RESET HSC_IO(16) | |
| 34 | +#define HSC_SET_PM HSC_IO(17) | |
| 35 | +#define HSC_SEND_BREAK HSC_IO(18) | |
| 36 | +#define HSC_SET_RX HSC_IOW(19, struct hsc_rx_config) | |
| 37 | +#define HSC_GET_RX HSC_IOW(20, struct hsc_rx_config) | |
| 38 | +#define HSC_SET_TX HSC_IOW(21, struct hsc_tx_config) | |
| 39 | +#define HSC_GET_TX HSC_IOW(22, struct hsc_tx_config) | |
| 40 | + | |
| 41 | +#define HSC_PM_DISABLE 0 | |
| 42 | +#define HSC_PM_ENABLE 1 | |
| 43 | + | |
| 44 | +#define HSC_MODE_STREAM 1 | |
| 45 | +#define HSC_MODE_FRAME 2 | |
| 46 | +#define HSC_FLOW_SYNC 0 | |
| 47 | +#define HSC_ARB_RR 0 | |
| 48 | +#define HSC_ARB_PRIO 1 | |
| 49 | + | |
| 50 | +struct hsc_rx_config { | |
| 51 | + uint32_t mode; | |
| 52 | + uint32_t flow; | |
| 53 | + uint32_t channels; | |
| 54 | +}; | |
| 55 | + | |
| 56 | +struct hsc_tx_config { | |
| 57 | + uint32_t mode; | |
| 58 | + uint32_t channels; | |
| 59 | + uint32_t speed; | |
| 60 | + uint32_t arb_mode; | |
| 61 | +}; | |
| 62 | + | |
| 63 | +#endif /* __HSI_CHAR_H */ | |
| @@ -1 +1,3 @@ | ||
| 1 | 1 | # UAPI Header export list |
| 2 | +header-y += md_p.h | |
| 3 | +header-y += md_u.h | |
| @@ -0,0 +1,301 @@ | ||
| 1 | +/* | |
| 2 | + md_p.h : physical layout of Linux RAID devices | |
| 3 | + Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman | |
| 4 | + | |
| 5 | + This program is free software; you can redistribute it and/or modify | |
| 6 | + it under the terms of the GNU General Public License as published by | |
| 7 | + the Free Software Foundation; either version 2, or (at your option) | |
| 8 | + any later version. | |
| 9 | + | |
| 10 | + You should have received a copy of the GNU General Public License | |
| 11 | + (for example /usr/src/linux/COPYING); if not, write to the Free | |
| 12 | + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 13 | +*/ | |
| 14 | + | |
| 15 | +#ifndef _MD_P_H | |
| 16 | +#define _MD_P_H | |
| 17 | + | |
| 18 | +#include <linux/types.h> | |
| 19 | + | |
| 20 | +/* | |
| 21 | + * RAID superblock. | |
| 22 | + * | |
| 23 | + * The RAID superblock maintains some statistics on each RAID configuration. | |
| 24 | + * Each real device in the RAID set contains it near the end of the device. | |
| 25 | + * Some of the ideas are copied from the ext2fs implementation. | |
| 26 | + * | |
| 27 | + * We currently use 4096 bytes as follows: | |
| 28 | + * | |
| 29 | + * word offset function | |
| 30 | + * | |
| 31 | + * 0 - 31 Constant generic RAID device information. | |
| 32 | + * 32 - 63 Generic state information. | |
| 33 | + * 64 - 127 Personality specific information. | |
| 34 | + * 128 - 511 12 32-words descriptors of the disks in the raid set. | |
| 35 | + * 512 - 911 Reserved. | |
| 36 | + * 912 - 1023 Disk specific descriptor. | |
| 37 | + */ | |
| 38 | + | |
| 39 | +/* | |
| 40 | + * If x is the real device size in bytes, we return an apparent size of: | |
| 41 | + * | |
| 42 | + * y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES | |
| 43 | + * | |
| 44 | + * and place the 4kB superblock at offset y. | |
| 45 | + */ | |
| 46 | +#define MD_RESERVED_BYTES (64 * 1024) | |
| 47 | +#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512) | |
| 48 | + | |
| 49 | +#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS) | |
| 50 | + | |
| 51 | +#define MD_SB_BYTES 4096 | |
| 52 | +#define MD_SB_WORDS (MD_SB_BYTES / 4) | |
| 53 | +#define MD_SB_SECTORS (MD_SB_BYTES / 512) | |
| 54 | + | |
| 55 | +/* | |
| 56 | + * The following are counted in 32-bit words | |
| 57 | + */ | |
| 58 | +#define MD_SB_GENERIC_OFFSET 0 | |
| 59 | +#define MD_SB_PERSONALITY_OFFSET 64 | |
| 60 | +#define MD_SB_DISKS_OFFSET 128 | |
| 61 | +#define MD_SB_DESCRIPTOR_OFFSET 992 | |
| 62 | + | |
| 63 | +#define MD_SB_GENERIC_CONSTANT_WORDS 32 | |
| 64 | +#define MD_SB_GENERIC_STATE_WORDS 32 | |
| 65 | +#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS) | |
| 66 | +#define MD_SB_PERSONALITY_WORDS 64 | |
| 67 | +#define MD_SB_DESCRIPTOR_WORDS 32 | |
| 68 | +#define MD_SB_DISKS 27 | |
| 69 | +#define MD_SB_DISKS_WORDS (MD_SB_DISKS*MD_SB_DESCRIPTOR_WORDS) | |
| 70 | +#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS) | |
| 71 | +#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS) | |
| 72 | + | |
| 73 | +/* | |
| 74 | + * Device "operational" state bits | |
| 75 | + */ | |
| 76 | +#define MD_DISK_FAULTY 0 /* disk is faulty / operational */ | |
| 77 | +#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */ | |
| 78 | +#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */ | |
| 79 | +#define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */ | |
| 80 | + | |
| 81 | +#define MD_DISK_WRITEMOSTLY 9 /* disk is "write-mostly" is RAID1 config. | |
| 82 | + * read requests will only be sent here in | |
| 83 | + * dire need | |
| 84 | + */ | |
| 85 | + | |
| 86 | +typedef struct mdp_device_descriptor_s { | |
| 87 | + __u32 number; /* 0 Device number in the entire set */ | |
| 88 | + __u32 major; /* 1 Device major number */ | |
| 89 | + __u32 minor; /* 2 Device minor number */ | |
| 90 | + __u32 raid_disk; /* 3 The role of the device in the raid set */ | |
| 91 | + __u32 state; /* 4 Operational state */ | |
| 92 | + __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5]; | |
| 93 | +} mdp_disk_t; | |
| 94 | + | |
| 95 | +#define MD_SB_MAGIC 0xa92b4efc | |
| 96 | + | |
| 97 | +/* | |
| 98 | + * Superblock state bits | |
| 99 | + */ | |
| 100 | +#define MD_SB_CLEAN 0 | |
| 101 | +#define MD_SB_ERRORS 1 | |
| 102 | + | |
| 103 | +#define MD_SB_BITMAP_PRESENT 8 /* bitmap may be present nearby */ | |
| 104 | + | |
| 105 | +/* | |
| 106 | + * Notes: | |
| 107 | + * - if an array is being reshaped (restriped) in order to change the | |
| 108 | + * the number of active devices in the array, 'raid_disks' will be | |
| 109 | + * the larger of the old and new numbers. 'delta_disks' will | |
| 110 | + * be the "new - old". So if +ve, raid_disks is the new value, and | |
| 111 | + * "raid_disks-delta_disks" is the old. If -ve, raid_disks is the | |
| 112 | + * old value and "raid_disks+delta_disks" is the new (smaller) value. | |
| 113 | + */ | |
| 114 | + | |
| 115 | + | |
| 116 | +typedef struct mdp_superblock_s { | |
| 117 | + /* | |
| 118 | + * Constant generic information | |
| 119 | + */ | |
| 120 | + __u32 md_magic; /* 0 MD identifier */ | |
| 121 | + __u32 major_version; /* 1 major version to which the set conforms */ | |
| 122 | + __u32 minor_version; /* 2 minor version ... */ | |
| 123 | + __u32 patch_version; /* 3 patchlevel version ... */ | |
| 124 | + __u32 gvalid_words; /* 4 Number of used words in this section */ | |
| 125 | + __u32 set_uuid0; /* 5 Raid set identifier */ | |
| 126 | + __u32 ctime; /* 6 Creation time */ | |
| 127 | + __u32 level; /* 7 Raid personality */ | |
| 128 | + __u32 size; /* 8 Apparent size of each individual disk */ | |
| 129 | + __u32 nr_disks; /* 9 total disks in the raid set */ | |
| 130 | + __u32 raid_disks; /* 10 disks in a fully functional raid set */ | |
| 131 | + __u32 md_minor; /* 11 preferred MD minor device number */ | |
| 132 | + __u32 not_persistent; /* 12 does it have a persistent superblock */ | |
| 133 | + __u32 set_uuid1; /* 13 Raid set identifier #2 */ | |
| 134 | + __u32 set_uuid2; /* 14 Raid set identifier #3 */ | |
| 135 | + __u32 set_uuid3; /* 15 Raid set identifier #4 */ | |
| 136 | + __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16]; | |
| 137 | + | |
| 138 | + /* | |
| 139 | + * Generic state information | |
| 140 | + */ | |
| 141 | + __u32 utime; /* 0 Superblock update time */ | |
| 142 | + __u32 state; /* 1 State bits (clean, ...) */ | |
| 143 | + __u32 active_disks; /* 2 Number of currently active disks */ | |
| 144 | + __u32 working_disks; /* 3 Number of working disks */ | |
| 145 | + __u32 failed_disks; /* 4 Number of failed disks */ | |
| 146 | + __u32 spare_disks; /* 5 Number of spare disks */ | |
| 147 | + __u32 sb_csum; /* 6 checksum of the whole superblock */ | |
| 148 | +#ifdef __BIG_ENDIAN | |
| 149 | + __u32 events_hi; /* 7 high-order of superblock update count */ | |
| 150 | + __u32 events_lo; /* 8 low-order of superblock update count */ | |
| 151 | + __u32 cp_events_hi; /* 9 high-order of checkpoint update count */ | |
| 152 | + __u32 cp_events_lo; /* 10 low-order of checkpoint update count */ | |
| 153 | +#else | |
| 154 | + __u32 events_lo; /* 7 low-order of superblock update count */ | |
| 155 | + __u32 events_hi; /* 8 high-order of superblock update count */ | |
| 156 | + __u32 cp_events_lo; /* 9 low-order of checkpoint update count */ | |
| 157 | + __u32 cp_events_hi; /* 10 high-order of checkpoint update count */ | |
| 158 | +#endif | |
| 159 | + __u32 recovery_cp; /* 11 recovery checkpoint sector count */ | |
| 160 | + /* There are only valid for minor_version > 90 */ | |
| 161 | + __u64 reshape_position; /* 12,13 next address in array-space for reshape */ | |
| 162 | + __u32 new_level; /* 14 new level we are reshaping to */ | |
| 163 | + __u32 delta_disks; /* 15 change in number of raid_disks */ | |
| 164 | + __u32 new_layout; /* 16 new layout */ | |
| 165 | + __u32 new_chunk; /* 17 new chunk size (bytes) */ | |
| 166 | + __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 18]; | |
| 167 | + | |
| 168 | + /* | |
| 169 | + * Personality information | |
| 170 | + */ | |
| 171 | + __u32 layout; /* 0 the array's physical layout */ | |
| 172 | + __u32 chunk_size; /* 1 chunk size in bytes */ | |
| 173 | + __u32 root_pv; /* 2 LV root PV */ | |
| 174 | + __u32 root_block; /* 3 LV root block */ | |
| 175 | + __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4]; | |
| 176 | + | |
| 177 | + /* | |
| 178 | + * Disks information | |
| 179 | + */ | |
| 180 | + mdp_disk_t disks[MD_SB_DISKS]; | |
| 181 | + | |
| 182 | + /* | |
| 183 | + * Reserved | |
| 184 | + */ | |
| 185 | + __u32 reserved[MD_SB_RESERVED_WORDS]; | |
| 186 | + | |
| 187 | + /* | |
| 188 | + * Active descriptor | |
| 189 | + */ | |
| 190 | + mdp_disk_t this_disk; | |
| 191 | + | |
| 192 | +} mdp_super_t; | |
| 193 | + | |
| 194 | +static inline __u64 md_event(mdp_super_t *sb) { | |
| 195 | + __u64 ev = sb->events_hi; | |
| 196 | + return (ev<<32)| sb->events_lo; | |
| 197 | +} | |
| 198 | + | |
| 199 | +#define MD_SUPERBLOCK_1_TIME_SEC_MASK ((1ULL<<40) - 1) | |
| 200 | + | |
| 201 | +/* | |
| 202 | + * The version-1 superblock : | |
| 203 | + * All numeric fields are little-endian. | |
| 204 | + * | |
| 205 | + * total size: 256 bytes plus 2 per device. | |
| 206 | + * 1K allows 384 devices. | |
| 207 | + */ | |
| 208 | +struct mdp_superblock_1 { | |
| 209 | + /* constant array information - 128 bytes */ | |
| 210 | + __le32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ | |
| 211 | + __le32 major_version; /* 1 */ | |
| 212 | + __le32 feature_map; /* bit 0 set if 'bitmap_offset' is meaningful */ | |
| 213 | + __le32 pad0; /* always set to 0 when writing */ | |
| 214 | + | |
| 215 | + __u8 set_uuid[16]; /* user-space generated. */ | |
| 216 | + char set_name[32]; /* set and interpreted by user-space */ | |
| 217 | + | |
| 218 | + __le64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ | |
| 219 | + __le32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ | |
| 220 | + __le32 layout; /* only for raid5 and raid10 currently */ | |
| 221 | + __le64 size; /* used size of component devices, in 512byte sectors */ | |
| 222 | + | |
| 223 | + __le32 chunksize; /* in 512byte sectors */ | |
| 224 | + __le32 raid_disks; | |
| 225 | + __le32 bitmap_offset; /* sectors after start of superblock that bitmap starts | |
| 226 | + * NOTE: signed, so bitmap can be before superblock | |
| 227 | + * only meaningful of feature_map[0] is set. | |
| 228 | + */ | |
| 229 | + | |
| 230 | + /* These are only valid with feature bit '4' */ | |
| 231 | + __le32 new_level; /* new level we are reshaping to */ | |
| 232 | + __le64 reshape_position; /* next address in array-space for reshape */ | |
| 233 | + __le32 delta_disks; /* change in number of raid_disks */ | |
| 234 | + __le32 new_layout; /* new layout */ | |
| 235 | + __le32 new_chunk; /* new chunk size (512byte sectors) */ | |
| 236 | + __le32 new_offset; /* signed number to add to data_offset in new | |
| 237 | + * layout. 0 == no-change. This can be | |
| 238 | + * different on each device in the array. | |
| 239 | + */ | |
| 240 | + | |
| 241 | + /* constant this-device information - 64 bytes */ | |
| 242 | + __le64 data_offset; /* sector start of data, often 0 */ | |
| 243 | + __le64 data_size; /* sectors in this device that can be used for data */ | |
| 244 | + __le64 super_offset; /* sector start of this superblock */ | |
| 245 | + __le64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */ | |
| 246 | + __le32 dev_number; /* permanent identifier of this device - not role in raid */ | |
| 247 | + __le32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ | |
| 248 | + __u8 device_uuid[16]; /* user-space setable, ignored by kernel */ | |
| 249 | + __u8 devflags; /* per-device flags. Only one defined...*/ | |
| 250 | +#define WriteMostly1 1 /* mask for writemostly flag in above */ | |
| 251 | + /* Bad block log. If there are any bad blocks the feature flag is set. | |
| 252 | + * If offset and size are non-zero, that space is reserved and available | |
| 253 | + */ | |
| 254 | + __u8 bblog_shift; /* shift from sectors to block size */ | |
| 255 | + __le16 bblog_size; /* number of sectors reserved for list */ | |
| 256 | + __le32 bblog_offset; /* sector offset from superblock to bblog, | |
| 257 | + * signed - not unsigned */ | |
| 258 | + | |
| 259 | + /* array state information - 64 bytes */ | |
| 260 | + __le64 utime; /* 40 bits second, 24 bits microseconds */ | |
| 261 | + __le64 events; /* incremented when superblock updated */ | |
| 262 | + __le64 resync_offset; /* data before this offset (from data_offset) known to be in sync */ | |
| 263 | + __le32 sb_csum; /* checksum up to devs[max_dev] */ | |
| 264 | + __le32 max_dev; /* size of devs[] array to consider */ | |
| 265 | + __u8 pad3[64-32]; /* set to 0 when writing */ | |
| 266 | + | |
| 267 | + /* device state information. Indexed by dev_number. | |
| 268 | + * 2 bytes per device | |
| 269 | + * Note there are no per-device state flags. State information is rolled | |
| 270 | + * into the 'roles' value. If a device is spare or faulty, then it doesn't | |
| 271 | + * have a meaningful role. | |
| 272 | + */ | |
| 273 | + __le16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ | |
| 274 | +}; | |
| 275 | + | |
| 276 | +/* feature_map bits */ | |
| 277 | +#define MD_FEATURE_BITMAP_OFFSET 1 | |
| 278 | +#define MD_FEATURE_RECOVERY_OFFSET 2 /* recovery_offset is present and | |
| 279 | + * must be honoured | |
| 280 | + */ | |
| 281 | +#define MD_FEATURE_RESHAPE_ACTIVE 4 | |
| 282 | +#define MD_FEATURE_BAD_BLOCKS 8 /* badblock list is not empty */ | |
| 283 | +#define MD_FEATURE_REPLACEMENT 16 /* This device is replacing an | |
| 284 | + * active device with same 'role'. | |
| 285 | + * 'recovery_offset' is also set. | |
| 286 | + */ | |
| 287 | +#define MD_FEATURE_RESHAPE_BACKWARDS 32 /* Reshape doesn't change number | |
| 288 | + * of devices, but is going | |
| 289 | + * backwards anyway. | |
| 290 | + */ | |
| 291 | +#define MD_FEATURE_NEW_OFFSET 64 /* new_offset must be honoured */ | |
| 292 | +#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \ | |
| 293 | + |MD_FEATURE_RECOVERY_OFFSET \ | |
| 294 | + |MD_FEATURE_RESHAPE_ACTIVE \ | |
| 295 | + |MD_FEATURE_BAD_BLOCKS \ | |
| 296 | + |MD_FEATURE_REPLACEMENT \ | |
| 297 | + |MD_FEATURE_RESHAPE_BACKWARDS \ | |
| 298 | + |MD_FEATURE_NEW_OFFSET \ | |
| 299 | + ) | |
| 300 | + | |
| 301 | +#endif | |
| @@ -0,0 +1,155 @@ | ||
| 1 | +/* | |
| 2 | + md_u.h : user <=> kernel API between Linux raidtools and RAID drivers | |
| 3 | + Copyright (C) 1998 Ingo Molnar | |
| 4 | + | |
| 5 | + This program is free software; you can redistribute it and/or modify | |
| 6 | + it under the terms of the GNU General Public License as published by | |
| 7 | + the Free Software Foundation; either version 2, or (at your option) | |
| 8 | + any later version. | |
| 9 | + | |
| 10 | + You should have received a copy of the GNU General Public License | |
| 11 | + (for example /usr/src/linux/COPYING); if not, write to the Free | |
| 12 | + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 13 | +*/ | |
| 14 | + | |
| 15 | +#ifndef _UAPI_MD_U_H | |
| 16 | +#define _UAPI_MD_U_H | |
| 17 | + | |
| 18 | +/* | |
| 19 | + * Different major versions are not compatible. | |
| 20 | + * Different minor versions are only downward compatible. | |
| 21 | + * Different patchlevel versions are downward and upward compatible. | |
| 22 | + */ | |
| 23 | +#define MD_MAJOR_VERSION 0 | |
| 24 | +#define MD_MINOR_VERSION 90 | |
| 25 | +/* | |
| 26 | + * MD_PATCHLEVEL_VERSION indicates kernel functionality. | |
| 27 | + * >=1 means different superblock formats are selectable using SET_ARRAY_INFO | |
| 28 | + * and major_version/minor_version accordingly | |
| 29 | + * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT | |
| 30 | + * in the super status byte | |
| 31 | + * >=3 means that bitmap superblock version 4 is supported, which uses | |
| 32 | + * little-ending representation rather than host-endian | |
| 33 | + */ | |
| 34 | +#define MD_PATCHLEVEL_VERSION 3 | |
| 35 | + | |
| 36 | +/* ioctls */ | |
| 37 | + | |
| 38 | +/* status */ | |
| 39 | +#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t) | |
| 40 | +#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t) | |
| 41 | +#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t) | |
| 42 | +#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13) | |
| 43 | +#define RAID_AUTORUN _IO (MD_MAJOR, 0x14) | |
| 44 | +#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t) | |
| 45 | + | |
| 46 | +/* configuration */ | |
| 47 | +#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20) | |
| 48 | +#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t) | |
| 49 | +#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22) | |
| 50 | +#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t) | |
| 51 | +#define SET_DISK_INFO _IO (MD_MAJOR, 0x24) | |
| 52 | +#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25) | |
| 53 | +#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26) | |
| 54 | +#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27) | |
| 55 | +#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28) | |
| 56 | +#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29) | |
| 57 | +#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a) | |
| 58 | +#define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int) | |
| 59 | + | |
| 60 | +/* usage */ | |
| 61 | +#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t) | |
| 62 | +/* 0x31 was START_ARRAY */ | |
| 63 | +#define STOP_ARRAY _IO (MD_MAJOR, 0x32) | |
| 64 | +#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) | |
| 65 | +#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) | |
| 66 | + | |
| 67 | +/* 63 partitions with the alternate major number (mdp) */ | |
| 68 | +#define MdpMinorShift 6 | |
| 69 | + | |
| 70 | +typedef struct mdu_version_s { | |
| 71 | + int major; | |
| 72 | + int minor; | |
| 73 | + int patchlevel; | |
| 74 | +} mdu_version_t; | |
| 75 | + | |
| 76 | +typedef struct mdu_array_info_s { | |
| 77 | + /* | |
| 78 | + * Generic constant information | |
| 79 | + */ | |
| 80 | + int major_version; | |
| 81 | + int minor_version; | |
| 82 | + int patch_version; | |
| 83 | + int ctime; | |
| 84 | + int level; | |
| 85 | + int size; | |
| 86 | + int nr_disks; | |
| 87 | + int raid_disks; | |
| 88 | + int md_minor; | |
| 89 | + int not_persistent; | |
| 90 | + | |
| 91 | + /* | |
| 92 | + * Generic state information | |
| 93 | + */ | |
| 94 | + int utime; /* 0 Superblock update time */ | |
| 95 | + int state; /* 1 State bits (clean, ...) */ | |
| 96 | + int active_disks; /* 2 Number of currently active disks */ | |
| 97 | + int working_disks; /* 3 Number of working disks */ | |
| 98 | + int failed_disks; /* 4 Number of failed disks */ | |
| 99 | + int spare_disks; /* 5 Number of spare disks */ | |
| 100 | + | |
| 101 | + /* | |
| 102 | + * Personality information | |
| 103 | + */ | |
| 104 | + int layout; /* 0 the array's physical layout */ | |
| 105 | + int chunk_size; /* 1 chunk size in bytes */ | |
| 106 | + | |
| 107 | +} mdu_array_info_t; | |
| 108 | + | |
| 109 | +/* non-obvious values for 'level' */ | |
| 110 | +#define LEVEL_MULTIPATH (-4) | |
| 111 | +#define LEVEL_LINEAR (-1) | |
| 112 | +#define LEVEL_FAULTY (-5) | |
| 113 | + | |
| 114 | +/* we need a value for 'no level specified' and 0 | |
| 115 | + * means 'raid0', so we need something else. This is | |
| 116 | + * for internal use only | |
| 117 | + */ | |
| 118 | +#define LEVEL_NONE (-1000000) | |
| 119 | + | |
| 120 | +typedef struct mdu_disk_info_s { | |
| 121 | + /* | |
| 122 | + * configuration/status of one particular disk | |
| 123 | + */ | |
| 124 | + int number; | |
| 125 | + int major; | |
| 126 | + int minor; | |
| 127 | + int raid_disk; | |
| 128 | + int state; | |
| 129 | + | |
| 130 | +} mdu_disk_info_t; | |
| 131 | + | |
| 132 | +typedef struct mdu_start_info_s { | |
| 133 | + /* | |
| 134 | + * configuration/status of one particular disk | |
| 135 | + */ | |
| 136 | + int major; | |
| 137 | + int minor; | |
| 138 | + int raid_disk; | |
| 139 | + int state; | |
| 140 | + | |
| 141 | +} mdu_start_info_t; | |
| 142 | + | |
| 143 | +typedef struct mdu_bitmap_file_s | |
| 144 | +{ | |
| 145 | + char pathname[4096]; | |
| 146 | +} mdu_bitmap_file_t; | |
| 147 | + | |
| 148 | +typedef struct mdu_param_s | |
| 149 | +{ | |
| 150 | + int personality; /* 1,2,3,4 */ | |
| 151 | + int chunk_size; /* in bytes */ | |
| 152 | + int max_fault; /* unused for now */ | |
| 153 | +} mdu_param_t; | |
| 154 | + | |
| 155 | +#endif /* _UAPI_MD_U_H */ | |
| @@ -130,6 +130,7 @@ enum { · 129 unmodified lines | ||
| 130 | 130 | #define TCPI_OPT_WSCALE 4 |
| 131 | 131 | #define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */ |
| 132 | 132 | #define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */ |
| 133 | +#define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */ | |
| 133 | 134 | |
| 134 | 135 | enum tcp_ca_state { |
| 135 | 136 | TCP_CA_Open = 0, |
| @@ -1 +1,11 @@ | ||
| 1 | 1 | # UAPI Header export list |
| 2 | +header-y += audio.h | |
| 3 | +header-y += cdc.h | |
| 4 | +header-y += ch11.h | |
| 5 | +header-y += ch9.h | |
| 6 | +header-y += functionfs.h | |
| 7 | +header-y += g_printer.h | |
| 8 | +header-y += gadgetfs.h | |
| 9 | +header-y += midi.h | |
| 10 | +header-y += tmc.h | |
| 11 | +header-y += video.h | |
| @@ -0,0 +1,545 @@ | ||
| 1 | +/* | |
| 2 | + * <linux/usb/audio.h> -- USB Audio definitions. | |
| 3 | + * | |
| 4 | + * Copyright (C) 2006 Thumtronics Pty Ltd. | |
| 5 | + * Developed for Thumtronics by Grey Innovation | |
| 6 | + * Ben Williamson <ben.williamson@greyinnovation.com> | |
| 7 | + * | |
| 8 | + * This software is distributed under the terms of the GNU General Public | |
| 9 | + * License ("GPL") version 2, as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This file holds USB constants and structures defined | |
| 12 | + * by the USB Device Class Definition for Audio Devices. | |
| 13 | + * Comments below reference relevant sections of that document: | |
| 14 | + * | |
| 15 | + * http://www.usb.org/developers/devclass_docs/audio10.pdf | |
| 16 | + * | |
| 17 | + * Types and defines in this file are either specific to version 1.0 of | |
| 18 | + * this standard or common for newer versions. | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#ifndef _UAPI__LINUX_USB_AUDIO_H | |
| 22 | +#define _UAPI__LINUX_USB_AUDIO_H | |
| 23 | + | |
| 24 | +#include <linux/types.h> | |
| 25 | + | |
| 26 | +/* bInterfaceProtocol values to denote the version of the standard used */ | |
| 27 | +#define UAC_VERSION_1 0x00 | |
| 28 | +#define UAC_VERSION_2 0x20 | |
| 29 | + | |
| 30 | +/* A.2 Audio Interface Subclass Codes */ | |
| 31 | +#define USB_SUBCLASS_AUDIOCONTROL 0x01 | |
| 32 | +#define USB_SUBCLASS_AUDIOSTREAMING 0x02 | |
| 33 | +#define USB_SUBCLASS_MIDISTREAMING 0x03 | |
| 34 | + | |
| 35 | +/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ | |
| 36 | +#define UAC_HEADER 0x01 | |
| 37 | +#define UAC_INPUT_TERMINAL 0x02 | |
| 38 | +#define UAC_OUTPUT_TERMINAL 0x03 | |
| 39 | +#define UAC_MIXER_UNIT 0x04 | |
| 40 | +#define UAC_SELECTOR_UNIT 0x05 | |
| 41 | +#define UAC_FEATURE_UNIT 0x06 | |
| 42 | +#define UAC1_PROCESSING_UNIT 0x07 | |
| 43 | +#define UAC1_EXTENSION_UNIT 0x08 | |
| 44 | + | |
| 45 | +/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ | |
| 46 | +#define UAC_AS_GENERAL 0x01 | |
| 47 | +#define UAC_FORMAT_TYPE 0x02 | |
| 48 | +#define UAC_FORMAT_SPECIFIC 0x03 | |
| 49 | + | |
| 50 | +/* A.7 Processing Unit Process Types */ | |
| 51 | +#define UAC_PROCESS_UNDEFINED 0x00 | |
| 52 | +#define UAC_PROCESS_UP_DOWNMIX 0x01 | |
| 53 | +#define UAC_PROCESS_DOLBY_PROLOGIC 0x02 | |
| 54 | +#define UAC_PROCESS_STEREO_EXTENDER 0x03 | |
| 55 | +#define UAC_PROCESS_REVERB 0x04 | |
| 56 | +#define UAC_PROCESS_CHORUS 0x05 | |
| 57 | +#define UAC_PROCESS_DYN_RANGE_COMP 0x06 | |
| 58 | + | |
| 59 | +/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ | |
| 60 | +#define UAC_EP_GENERAL 0x01 | |
| 61 | + | |
| 62 | +/* A.9 Audio Class-Specific Request Codes */ | |
| 63 | +#define UAC_SET_ 0x00 | |
| 64 | +#define UAC_GET_ 0x80 | |
| 65 | + | |
| 66 | +#define UAC__CUR 0x1 | |
| 67 | +#define UAC__MIN 0x2 | |
| 68 | +#define UAC__MAX 0x3 | |
| 69 | +#define UAC__RES 0x4 | |
| 70 | +#define UAC__MEM 0x5 | |
| 71 | + | |
| 72 | +#define UAC_SET_CUR (UAC_SET_ | UAC__CUR) | |
| 73 | +#define UAC_GET_CUR (UAC_GET_ | UAC__CUR) | |
| 74 | +#define UAC_SET_MIN (UAC_SET_ | UAC__MIN) | |
| 75 | +#define UAC_GET_MIN (UAC_GET_ | UAC__MIN) | |
| 76 | +#define UAC_SET_MAX (UAC_SET_ | UAC__MAX) | |
| 77 | +#define UAC_GET_MAX (UAC_GET_ | UAC__MAX) | |
| 78 | +#define UAC_SET_RES (UAC_SET_ | UAC__RES) | |
| 79 | +#define UAC_GET_RES (UAC_GET_ | UAC__RES) | |
| 80 | +#define UAC_SET_MEM (UAC_SET_ | UAC__MEM) | |
| 81 | +#define UAC_GET_MEM (UAC_GET_ | UAC__MEM) | |
| 82 | + | |
| 83 | +#define UAC_GET_STAT 0xff | |
| 84 | + | |
| 85 | +/* A.10 Control Selector Codes */ | |
| 86 | + | |
| 87 | +/* A.10.1 Terminal Control Selectors */ | |
| 88 | +#define UAC_TERM_COPY_PROTECT 0x01 | |
| 89 | + | |
| 90 | +/* A.10.2 Feature Unit Control Selectors */ | |
| 91 | +#define UAC_FU_MUTE 0x01 | |
| 92 | +#define UAC_FU_VOLUME 0x02 | |
| 93 | +#define UAC_FU_BASS 0x03 | |
| 94 | +#define UAC_FU_MID 0x04 | |
| 95 | +#define UAC_FU_TREBLE 0x05 | |
| 96 | +#define UAC_FU_GRAPHIC_EQUALIZER 0x06 | |
| 97 | +#define UAC_FU_AUTOMATIC_GAIN 0x07 | |
| 98 | +#define UAC_FU_DELAY 0x08 | |
| 99 | +#define UAC_FU_BASS_BOOST 0x09 | |
| 100 | +#define UAC_FU_LOUDNESS 0x0a | |
| 101 | + | |
| 102 | +#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1)) | |
| 103 | + | |
| 104 | +/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */ | |
| 105 | +#define UAC_UD_ENABLE 0x01 | |
| 106 | +#define UAC_UD_MODE_SELECT 0x02 | |
| 107 | + | |
| 108 | +/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */ | |
| 109 | +#define UAC_DP_ENABLE 0x01 | |
| 110 | +#define UAC_DP_MODE_SELECT 0x02 | |
| 111 | + | |
| 112 | +/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */ | |
| 113 | +#define UAC_3D_ENABLE 0x01 | |
| 114 | +#define UAC_3D_SPACE 0x02 | |
| 115 | + | |
| 116 | +/* A.10.3.4 Reverberation Processing Unit Control Selectors */ | |
| 117 | +#define UAC_REVERB_ENABLE 0x01 | |
| 118 | +#define UAC_REVERB_LEVEL 0x02 | |
| 119 | +#define UAC_REVERB_TIME 0x03 | |
| 120 | +#define UAC_REVERB_FEEDBACK 0x04 | |
| 121 | + | |
| 122 | +/* A.10.3.5 Chorus Processing Unit Control Selectors */ | |
| 123 | +#define UAC_CHORUS_ENABLE 0x01 | |
| 124 | +#define UAC_CHORUS_LEVEL 0x02 | |
| 125 | +#define UAC_CHORUS_RATE 0x03 | |
| 126 | +#define UAC_CHORUS_DEPTH 0x04 | |
| 127 | + | |
| 128 | +/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */ | |
| 129 | +#define UAC_DCR_ENABLE 0x01 | |
| 130 | +#define UAC_DCR_RATE 0x02 | |
| 131 | +#define UAC_DCR_MAXAMPL 0x03 | |
| 132 | +#define UAC_DCR_THRESHOLD 0x04 | |
| 133 | +#define UAC_DCR_ATTACK_TIME 0x05 | |
| 134 | +#define UAC_DCR_RELEASE_TIME 0x06 | |
| 135 | + | |
| 136 | +/* A.10.4 Extension Unit Control Selectors */ | |
| 137 | +#define UAC_XU_ENABLE 0x01 | |
| 138 | + | |
| 139 | +/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ | |
| 140 | +#define UAC_MS_HEADER 0x01 | |
| 141 | +#define UAC_MIDI_IN_JACK 0x02 | |
| 142 | +#define UAC_MIDI_OUT_JACK 0x03 | |
| 143 | + | |
| 144 | +/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */ | |
| 145 | +#define UAC_MS_GENERAL 0x01 | |
| 146 | + | |
| 147 | +/* Terminals - 2.1 USB Terminal Types */ | |
| 148 | +#define UAC_TERMINAL_UNDEFINED 0x100 | |
| 149 | +#define UAC_TERMINAL_STREAMING 0x101 | |
| 150 | +#define UAC_TERMINAL_VENDOR_SPEC 0x1FF | |
| 151 | + | |
| 152 | +/* Terminal Control Selectors */ | |
| 153 | +/* 4.3.2 Class-Specific AC Interface Descriptor */ | |
| 154 | +struct uac1_ac_header_descriptor { | |
| 155 | + __u8 bLength; /* 8 + n */ | |
| 156 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 157 | + __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ | |
| 158 | + __le16 bcdADC; /* 0x0100 */ | |
| 159 | + __le16 wTotalLength; /* includes Unit and Terminal desc. */ | |
| 160 | + __u8 bInCollection; /* n */ | |
| 161 | + __u8 baInterfaceNr[]; /* [n] */ | |
| 162 | +} __attribute__ ((packed)); | |
| 163 | + | |
| 164 | +#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) | |
| 165 | + | |
| 166 | +/* As above, but more useful for defining your own descriptors: */ | |
| 167 | +#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ | |
| 168 | +struct uac1_ac_header_descriptor_##n { \ | |
| 169 | + __u8 bLength; \ | |
| 170 | + __u8 bDescriptorType; \ | |
| 171 | + __u8 bDescriptorSubtype; \ | |
| 172 | + __le16 bcdADC; \ | |
| 173 | + __le16 wTotalLength; \ | |
| 174 | + __u8 bInCollection; \ | |
| 175 | + __u8 baInterfaceNr[n]; \ | |
| 176 | +} __attribute__ ((packed)) | |
| 177 | + | |
| 178 | +/* 4.3.2.1 Input Terminal Descriptor */ | |
| 179 | +struct uac_input_terminal_descriptor { | |
| 180 | + __u8 bLength; /* in bytes: 12 */ | |
| 181 | + __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | |
| 182 | + __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ | |
| 183 | + __u8 bTerminalID; /* Constant uniquely terminal ID */ | |
| 184 | + __le16 wTerminalType; /* USB Audio Terminal Types */ | |
| 185 | + __u8 bAssocTerminal; /* ID of the Output Terminal associated */ | |
| 186 | + __u8 bNrChannels; /* Number of logical output channels */ | |
| 187 | + __le16 wChannelConfig; | |
| 188 | + __u8 iChannelNames; | |
| 189 | + __u8 iTerminal; | |
| 190 | +} __attribute__ ((packed)); | |
| 191 | + | |
| 192 | +#define UAC_DT_INPUT_TERMINAL_SIZE 12 | |
| 193 | + | |
| 194 | +/* Terminals - 2.2 Input Terminal Types */ | |
| 195 | +#define UAC_INPUT_TERMINAL_UNDEFINED 0x200 | |
| 196 | +#define UAC_INPUT_TERMINAL_MICROPHONE 0x201 | |
| 197 | +#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 | |
| 198 | +#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 | |
| 199 | +#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 | |
| 200 | +#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 | |
| 201 | +#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 | |
| 202 | + | |
| 203 | +/* Terminals - control selectors */ | |
| 204 | + | |
| 205 | +#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 | |
| 206 | + | |
| 207 | +/* 4.3.2.2 Output Terminal Descriptor */ | |
| 208 | +struct uac1_output_terminal_descriptor { | |
| 209 | + __u8 bLength; /* in bytes: 9 */ | |
| 210 | + __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | |
| 211 | + __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ | |
| 212 | + __u8 bTerminalID; /* Constant uniquely terminal ID */ | |
| 213 | + __le16 wTerminalType; /* USB Audio Terminal Types */ | |
| 214 | + __u8 bAssocTerminal; /* ID of the Input Terminal associated */ | |
| 215 | + __u8 bSourceID; /* ID of the connected Unit or Terminal*/ | |
| 216 | + __u8 iTerminal; | |
| 217 | +} __attribute__ ((packed)); | |
| 218 | + | |
| 219 | +#define UAC_DT_OUTPUT_TERMINAL_SIZE 9 | |
| 220 | + | |
| 221 | +/* Terminals - 2.3 Output Terminal Types */ | |
| 222 | +#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300 | |
| 223 | +#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301 | |
| 224 | +#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302 | |
| 225 | +#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 | |
| 226 | +#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 | |
| 227 | +#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 | |
| 228 | +#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 | |
| 229 | +#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 | |
| 230 | + | |
| 231 | +/* Set bControlSize = 2 as default setting */ | |
| 232 | +#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) | |
| 233 | + | |
| 234 | +/* As above, but more useful for defining your own descriptors: */ | |
| 235 | +#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ | |
| 236 | +struct uac_feature_unit_descriptor_##ch { \ | |
| 237 | + __u8 bLength; \ | |
| 238 | + __u8 bDescriptorType; \ | |
| 239 | + __u8 bDescriptorSubtype; \ | |
| 240 | + __u8 bUnitID; \ | |
| 241 | + __u8 bSourceID; \ | |
| 242 | + __u8 bControlSize; \ | |
| 243 | + __le16 bmaControls[ch + 1]; \ | |
| 244 | + __u8 iFeature; \ | |
| 245 | +} __attribute__ ((packed)) | |
| 246 | + | |
| 247 | +/* 4.3.2.3 Mixer Unit Descriptor */ | |
| 248 | +struct uac_mixer_unit_descriptor { | |
| 249 | + __u8 bLength; | |
| 250 | + __u8 bDescriptorType; | |
| 251 | + __u8 bDescriptorSubtype; | |
| 252 | + __u8 bUnitID; | |
| 253 | + __u8 bNrInPins; | |
| 254 | + __u8 baSourceID[]; | |
| 255 | +} __attribute__ ((packed)); | |
| 256 | + | |
| 257 | +static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) | |
| 258 | +{ | |
| 259 | + return desc->baSourceID[desc->bNrInPins]; | |
| 260 | +} | |
| 261 | + | |
| 262 | +static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc, | |
| 263 | + int protocol) | |
| 264 | +{ | |
| 265 | + if (protocol == UAC_VERSION_1) | |
| 266 | + return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | |
| 267 | + desc->baSourceID[desc->bNrInPins + 1]; | |
| 268 | + else | |
| 269 | + return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | |
| 270 | + (desc->baSourceID[desc->bNrInPins + 3] << 16) | | |
| 271 | + (desc->baSourceID[desc->bNrInPins + 2] << 8) | | |
| 272 | + (desc->baSourceID[desc->bNrInPins + 1]); | |
| 273 | +} | |
| 274 | + | |
| 275 | +static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc, | |
| 276 | + int protocol) | |
| 277 | +{ | |
| 278 | + return (protocol == UAC_VERSION_1) ? | |
| 279 | + desc->baSourceID[desc->bNrInPins + 3] : | |
| 280 | + desc->baSourceID[desc->bNrInPins + 5]; | |
| 281 | +} | |
| 282 | + | |
| 283 | +static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc, | |
| 284 | + int protocol) | |
| 285 | +{ | |
| 286 | + return (protocol == UAC_VERSION_1) ? | |
| 287 | + &desc->baSourceID[desc->bNrInPins + 4] : | |
| 288 | + &desc->baSourceID[desc->bNrInPins + 6]; | |
| 289 | +} | |
| 290 | + | |
| 291 | +static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc) | |
| 292 | +{ | |
| 293 | + __u8 *raw = (__u8 *) desc; | |
| 294 | + return raw[desc->bLength - 1]; | |
| 295 | +} | |
| 296 | + | |
| 297 | +/* 4.3.2.4 Selector Unit Descriptor */ | |
| 298 | +struct uac_selector_unit_descriptor { | |
| 299 | + __u8 bLength; | |
| 300 | + __u8 bDescriptorType; | |
| 301 | + __u8 bDescriptorSubtype; | |
| 302 | + __u8 bUintID; | |
| 303 | + __u8 bNrInPins; | |
| 304 | + __u8 baSourceID[]; | |
| 305 | +} __attribute__ ((packed)); | |
| 306 | + | |
| 307 | +static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) | |
| 308 | +{ | |
| 309 | + __u8 *raw = (__u8 *) desc; | |
| 310 | + return raw[desc->bLength - 1]; | |
| 311 | +} | |
| 312 | + | |
| 313 | +/* 4.3.2.5 Feature Unit Descriptor */ | |
| 314 | +struct uac_feature_unit_descriptor { | |
| 315 | + __u8 bLength; | |
| 316 | + __u8 bDescriptorType; | |
| 317 | + __u8 bDescriptorSubtype; | |
| 318 | + __u8 bUnitID; | |
| 319 | + __u8 bSourceID; | |
| 320 | + __u8 bControlSize; | |
| 321 | + __u8 bmaControls[0]; /* variable length */ | |
| 322 | +} __attribute__((packed)); | |
| 323 | + | |
| 324 | +static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) | |
| 325 | +{ | |
| 326 | + __u8 *raw = (__u8 *) desc; | |
| 327 | + return raw[desc->bLength - 1]; | |
| 328 | +} | |
| 329 | + | |
| 330 | +/* 4.3.2.6 Processing Unit Descriptors */ | |
| 331 | +struct uac_processing_unit_descriptor { | |
| 332 | + __u8 bLength; | |
| 333 | + __u8 bDescriptorType; | |
| 334 | + __u8 bDescriptorSubtype; | |
| 335 | + __u8 bUnitID; | |
| 336 | + __u16 wProcessType; | |
| 337 | + __u8 bNrInPins; | |
| 338 | + __u8 baSourceID[]; | |
| 339 | +} __attribute__ ((packed)); | |
| 340 | + | |
| 341 | +static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) | |
| 342 | +{ | |
| 343 | + return desc->baSourceID[desc->bNrInPins]; | |
| 344 | +} | |
| 345 | + | |
| 346 | +static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc, | |
| 347 | + int protocol) | |
| 348 | +{ | |
| 349 | + if (protocol == UAC_VERSION_1) | |
| 350 | + return (desc->baSourceID[desc->bNrInPins + 2] << 8) | | |
| 351 | + desc->baSourceID[desc->bNrInPins + 1]; | |
| 352 | + else | |
| 353 | + return (desc->baSourceID[desc->bNrInPins + 4] << 24) | | |
| 354 | + (desc->baSourceID[desc->bNrInPins + 3] << 16) | | |
| 355 | + (desc->baSourceID[desc->bNrInPins + 2] << 8) | | |
| 356 | + (desc->baSourceID[desc->bNrInPins + 1]); | |
| 357 | +} | |
| 358 | + | |
| 359 | +static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc, | |
| 360 | + int protocol) | |
| 361 | +{ | |
| 362 | + return (protocol == UAC_VERSION_1) ? | |
| 363 | + desc->baSourceID[desc->bNrInPins + 3] : | |
| 364 | + desc->baSourceID[desc->bNrInPins + 5]; | |
| 365 | +} | |
| 366 | + | |
| 367 | +static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc, | |
| 368 | + int protocol) | |
| 369 | +{ | |
| 370 | + return (protocol == UAC_VERSION_1) ? | |
| 371 | + desc->baSourceID[desc->bNrInPins + 4] : | |
| 372 | + desc->baSourceID[desc->bNrInPins + 6]; | |
| 373 | +} | |
| 374 | + | |
| 375 | +static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc, | |
| 376 | + int protocol) | |
| 377 | +{ | |
| 378 | + return (protocol == UAC_VERSION_1) ? | |
| 379 | + &desc->baSourceID[desc->bNrInPins + 5] : | |
| 380 | + &desc->baSourceID[desc->bNrInPins + 7]; | |
| 381 | +} | |
| 382 | + | |
| 383 | +static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc, | |
| 384 | + int protocol) | |
| 385 | +{ | |
| 386 | + __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | |
| 387 | + return desc->baSourceID[desc->bNrInPins + control_size]; | |
| 388 | +} | |
| 389 | + | |
| 390 | +static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, | |
| 391 | + int protocol) | |
| 392 | +{ | |
| 393 | + __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); | |
| 394 | + return &desc->baSourceID[desc->bNrInPins + control_size + 1]; | |
| 395 | +} | |
| 396 | + | |
| 397 | +/* 4.5.2 Class-Specific AS Interface Descriptor */ | |
| 398 | +struct uac1_as_header_descriptor { | |
| 399 | + __u8 bLength; /* in bytes: 7 */ | |
| 400 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 401 | + __u8 bDescriptorSubtype; /* AS_GENERAL */ | |
| 402 | + __u8 bTerminalLink; /* Terminal ID of connected Terminal */ | |
| 403 | + __u8 bDelay; /* Delay introduced by the data path */ | |
| 404 | + __le16 wFormatTag; /* The Audio Data Format */ | |
| 405 | +} __attribute__ ((packed)); | |
| 406 | + | |
| 407 | +#define UAC_DT_AS_HEADER_SIZE 7 | |
| 408 | + | |
| 409 | +/* Formats - A.1.1 Audio Data Format Type I Codes */ | |
| 410 | +#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0 | |
| 411 | +#define UAC_FORMAT_TYPE_I_PCM 0x1 | |
| 412 | +#define UAC_FORMAT_TYPE_I_PCM8 0x2 | |
| 413 | +#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3 | |
| 414 | +#define UAC_FORMAT_TYPE_I_ALAW 0x4 | |
| 415 | +#define UAC_FORMAT_TYPE_I_MULAW 0x5 | |
| 416 | + | |
| 417 | +struct uac_format_type_i_continuous_descriptor { | |
| 418 | + __u8 bLength; /* in bytes: 8 + (ns * 3) */ | |
| 419 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 420 | + __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | |
| 421 | + __u8 bFormatType; /* FORMAT_TYPE_1 */ | |
| 422 | + __u8 bNrChannels; /* physical channels in the stream */ | |
| 423 | + __u8 bSubframeSize; /* */ | |
| 424 | + __u8 bBitResolution; | |
| 425 | + __u8 bSamFreqType; | |
| 426 | + __u8 tLowerSamFreq[3]; | |
| 427 | + __u8 tUpperSamFreq[3]; | |
| 428 | +} __attribute__ ((packed)); | |
| 429 | + | |
| 430 | +#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 | |
| 431 | + | |
| 432 | +struct uac_format_type_i_discrete_descriptor { | |
| 433 | + __u8 bLength; /* in bytes: 8 + (ns * 3) */ | |
| 434 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 435 | + __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | |
| 436 | + __u8 bFormatType; /* FORMAT_TYPE_1 */ | |
| 437 | + __u8 bNrChannels; /* physical channels in the stream */ | |
| 438 | + __u8 bSubframeSize; /* */ | |
| 439 | + __u8 bBitResolution; | |
| 440 | + __u8 bSamFreqType; | |
| 441 | + __u8 tSamFreq[][3]; | |
| 442 | +} __attribute__ ((packed)); | |
| 443 | + | |
| 444 | +#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ | |
| 445 | +struct uac_format_type_i_discrete_descriptor_##n { \ | |
| 446 | + __u8 bLength; \ | |
| 447 | + __u8 bDescriptorType; \ | |
| 448 | + __u8 bDescriptorSubtype; \ | |
| 449 | + __u8 bFormatType; \ | |
| 450 | + __u8 bNrChannels; \ | |
| 451 | + __u8 bSubframeSize; \ | |
| 452 | + __u8 bBitResolution; \ | |
| 453 | + __u8 bSamFreqType; \ | |
| 454 | + __u8 tSamFreq[n][3]; \ | |
| 455 | +} __attribute__ ((packed)) | |
| 456 | + | |
| 457 | +#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) | |
| 458 | + | |
| 459 | +struct uac_format_type_i_ext_descriptor { | |
| 460 | + __u8 bLength; | |
| 461 | + __u8 bDescriptorType; | |
| 462 | + __u8 bDescriptorSubtype; | |
| 463 | + __u8 bFormatType; | |
| 464 | + __u8 bSubslotSize; | |
| 465 | + __u8 bBitResolution; | |
| 466 | + __u8 bHeaderLength; | |
| 467 | + __u8 bControlSize; | |
| 468 | + __u8 bSideBandProtocol; | |
| 469 | +} __attribute__((packed)); | |
| 470 | + | |
| 471 | +/* Formats - Audio Data Format Type I Codes */ | |
| 472 | + | |
| 473 | +#define UAC_FORMAT_TYPE_II_MPEG 0x1001 | |
| 474 | +#define UAC_FORMAT_TYPE_II_AC3 0x1002 | |
| 475 | + | |
| 476 | +struct uac_format_type_ii_discrete_descriptor { | |
| 477 | + __u8 bLength; | |
| 478 | + __u8 bDescriptorType; | |
| 479 | + __u8 bDescriptorSubtype; | |
| 480 | + __u8 bFormatType; | |
| 481 | + __le16 wMaxBitRate; | |
| 482 | + __le16 wSamplesPerFrame; | |
| 483 | + __u8 bSamFreqType; | |
| 484 | + __u8 tSamFreq[][3]; | |
| 485 | +} __attribute__((packed)); | |
| 486 | + | |
| 487 | +struct uac_format_type_ii_ext_descriptor { | |
| 488 | + __u8 bLength; | |
| 489 | + __u8 bDescriptorType; | |
| 490 | + __u8 bDescriptorSubtype; | |
| 491 | + __u8 bFormatType; | |
| 492 | + __u16 wMaxBitRate; | |
| 493 | + __u16 wSamplesPerFrame; | |
| 494 | + __u8 bHeaderLength; | |
| 495 | + __u8 bSideBandProtocol; | |
| 496 | +} __attribute__((packed)); | |
| 497 | + | |
| 498 | +/* type III */ | |
| 499 | +#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001 | |
| 500 | +#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002 | |
| 501 | +#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003 | |
| 502 | +#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004 | |
| 503 | +#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005 | |
| 504 | +#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006 | |
| 505 | + | |
| 506 | +/* Formats - A.2 Format Type Codes */ | |
| 507 | +#define UAC_FORMAT_TYPE_UNDEFINED 0x0 | |
| 508 | +#define UAC_FORMAT_TYPE_I 0x1 | |
| 509 | +#define UAC_FORMAT_TYPE_II 0x2 | |
| 510 | +#define UAC_FORMAT_TYPE_III 0x3 | |
| 511 | +#define UAC_EXT_FORMAT_TYPE_I 0x81 | |
| 512 | +#define UAC_EXT_FORMAT_TYPE_II 0x82 | |
| 513 | +#define UAC_EXT_FORMAT_TYPE_III 0x83 | |
| 514 | + | |
| 515 | +struct uac_iso_endpoint_descriptor { | |
| 516 | + __u8 bLength; /* in bytes: 7 */ | |
| 517 | + __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ | |
| 518 | + __u8 bDescriptorSubtype; /* EP_GENERAL */ | |
| 519 | + __u8 bmAttributes; | |
| 520 | + __u8 bLockDelayUnits; | |
| 521 | + __le16 wLockDelay; | |
| 522 | +} __attribute__((packed)); | |
| 523 | +#define UAC_ISO_ENDPOINT_DESC_SIZE 7 | |
| 524 | + | |
| 525 | +#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 | |
| 526 | +#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 | |
| 527 | +#define UAC_EP_CS_ATTR_FILL_MAX 0x80 | |
| 528 | + | |
| 529 | +/* status word format (3.7.1.1) */ | |
| 530 | + | |
| 531 | +#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f | |
| 532 | +#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 | |
| 533 | +#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 | |
| 534 | +#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 | |
| 535 | + | |
| 536 | +#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) | |
| 537 | +#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) | |
| 538 | + | |
| 539 | +struct uac1_status_word { | |
| 540 | + __u8 bStatusType; | |
| 541 | + __u8 bOriginator; | |
| 542 | +} __attribute__((packed)); | |
| 543 | + | |
| 544 | + | |
| 545 | +#endif /* _UAPI__LINUX_USB_AUDIO_H */ | |
| @@ -0,0 +1,435 @@ | ||
| 1 | +/* | |
| 2 | + * USB Communications Device Class (CDC) definitions | |
| 3 | + * | |
| 4 | + * CDC says how to talk to lots of different types of network adapters, | |
| 5 | + * notably ethernet adapters and various modems. It's used mostly with | |
| 6 | + * firmware based USB peripherals. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#ifndef __LINUX_USB_CDC_H | |
| 10 | +#define __LINUX_USB_CDC_H | |
| 11 | + | |
| 12 | +#include <linux/types.h> | |
| 13 | + | |
| 14 | +#define USB_CDC_SUBCLASS_ACM 0x02 | |
| 15 | +#define USB_CDC_SUBCLASS_ETHERNET 0x06 | |
| 16 | +#define USB_CDC_SUBCLASS_WHCM 0x08 | |
| 17 | +#define USB_CDC_SUBCLASS_DMM 0x09 | |
| 18 | +#define USB_CDC_SUBCLASS_MDLM 0x0a | |
| 19 | +#define USB_CDC_SUBCLASS_OBEX 0x0b | |
| 20 | +#define USB_CDC_SUBCLASS_EEM 0x0c | |
| 21 | +#define USB_CDC_SUBCLASS_NCM 0x0d | |
| 22 | +#define USB_CDC_SUBCLASS_MBIM 0x0e | |
| 23 | + | |
| 24 | +#define USB_CDC_PROTO_NONE 0 | |
| 25 | + | |
| 26 | +#define USB_CDC_ACM_PROTO_AT_V25TER 1 | |
| 27 | +#define USB_CDC_ACM_PROTO_AT_PCCA101 2 | |
| 28 | +#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3 | |
| 29 | +#define USB_CDC_ACM_PROTO_AT_GSM 4 | |
| 30 | +#define USB_CDC_ACM_PROTO_AT_3G 5 | |
| 31 | +#define USB_CDC_ACM_PROTO_AT_CDMA 6 | |
| 32 | +#define USB_CDC_ACM_PROTO_VENDOR 0xff | |
| 33 | + | |
| 34 | +#define USB_CDC_PROTO_EEM 7 | |
| 35 | + | |
| 36 | +#define USB_CDC_NCM_PROTO_NTB 1 | |
| 37 | +#define USB_CDC_MBIM_PROTO_NTB 2 | |
| 38 | + | |
| 39 | +/*-------------------------------------------------------------------------*/ | |
| 40 | + | |
| 41 | +/* | |
| 42 | + * Class-Specific descriptors ... there are a couple dozen of them | |
| 43 | + */ | |
| 44 | + | |
| 45 | +#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ | |
| 46 | +#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ | |
| 47 | +#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ | |
| 48 | +#define USB_CDC_UNION_TYPE 0x06 /* union_desc */ | |
| 49 | +#define USB_CDC_COUNTRY_TYPE 0x07 | |
| 50 | +#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ | |
| 51 | +#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ | |
| 52 | +#define USB_CDC_WHCM_TYPE 0x11 | |
| 53 | +#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ | |
| 54 | +#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ | |
| 55 | +#define USB_CDC_DMM_TYPE 0x14 | |
| 56 | +#define USB_CDC_OBEX_TYPE 0x15 | |
| 57 | +#define USB_CDC_NCM_TYPE 0x1a | |
| 58 | +#define USB_CDC_MBIM_TYPE 0x1b | |
| 59 | + | |
| 60 | +/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */ | |
| 61 | +struct usb_cdc_header_desc { | |
| 62 | + __u8 bLength; | |
| 63 | + __u8 bDescriptorType; | |
| 64 | + __u8 bDescriptorSubType; | |
| 65 | + | |
| 66 | + __le16 bcdCDC; | |
| 67 | +} __attribute__ ((packed)); | |
| 68 | + | |
| 69 | +/* "Call Management Descriptor" from CDC spec 5.2.3.2 */ | |
| 70 | +struct usb_cdc_call_mgmt_descriptor { | |
| 71 | + __u8 bLength; | |
| 72 | + __u8 bDescriptorType; | |
| 73 | + __u8 bDescriptorSubType; | |
| 74 | + | |
| 75 | + __u8 bmCapabilities; | |
| 76 | +#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01 | |
| 77 | +#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02 | |
| 78 | + | |
| 79 | + __u8 bDataInterface; | |
| 80 | +} __attribute__ ((packed)); | |
| 81 | + | |
| 82 | +/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */ | |
| 83 | +struct usb_cdc_acm_descriptor { | |
| 84 | + __u8 bLength; | |
| 85 | + __u8 bDescriptorType; | |
| 86 | + __u8 bDescriptorSubType; | |
| 87 | + | |
| 88 | + __u8 bmCapabilities; | |
| 89 | +} __attribute__ ((packed)); | |
| 90 | + | |
| 91 | +/* capabilities from 5.2.3.3 */ | |
| 92 | + | |
| 93 | +#define USB_CDC_COMM_FEATURE 0x01 | |
| 94 | +#define USB_CDC_CAP_LINE 0x02 | |
| 95 | +#define USB_CDC_CAP_BRK 0x04 | |
| 96 | +#define USB_CDC_CAP_NOTIFY 0x08 | |
| 97 | + | |
| 98 | +/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */ | |
| 99 | +struct usb_cdc_union_desc { | |
| 100 | + __u8 bLength; | |
| 101 | + __u8 bDescriptorType; | |
| 102 | + __u8 bDescriptorSubType; | |
| 103 | + | |
| 104 | + __u8 bMasterInterface0; | |
| 105 | + __u8 bSlaveInterface0; | |
| 106 | + /* ... and there could be other slave interfaces */ | |
| 107 | +} __attribute__ ((packed)); | |
| 108 | + | |
| 109 | +/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */ | |
| 110 | +struct usb_cdc_country_functional_desc { | |
| 111 | + __u8 bLength; | |
| 112 | + __u8 bDescriptorType; | |
| 113 | + __u8 bDescriptorSubType; | |
| 114 | + | |
| 115 | + __u8 iCountryCodeRelDate; | |
| 116 | + __le16 wCountyCode0; | |
| 117 | + /* ... and there can be a lot of country codes */ | |
| 118 | +} __attribute__ ((packed)); | |
| 119 | + | |
| 120 | +/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */ | |
| 121 | +struct usb_cdc_network_terminal_desc { | |
| 122 | + __u8 bLength; | |
| 123 | + __u8 bDescriptorType; | |
| 124 | + __u8 bDescriptorSubType; | |
| 125 | + | |
| 126 | + __u8 bEntityId; | |
| 127 | + __u8 iName; | |
| 128 | + __u8 bChannelIndex; | |
| 129 | + __u8 bPhysicalInterface; | |
| 130 | +} __attribute__ ((packed)); | |
| 131 | + | |
| 132 | +/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */ | |
| 133 | +struct usb_cdc_ether_desc { | |
| 134 | + __u8 bLength; | |
| 135 | + __u8 bDescriptorType; | |
| 136 | + __u8 bDescriptorSubType; | |
| 137 | + | |
| 138 | + __u8 iMACAddress; | |
| 139 | + __le32 bmEthernetStatistics; | |
| 140 | + __le16 wMaxSegmentSize; | |
| 141 | + __le16 wNumberMCFilters; | |
| 142 | + __u8 bNumberPowerFilters; | |
| 143 | +} __attribute__ ((packed)); | |
| 144 | + | |
| 145 | +/* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */ | |
| 146 | +struct usb_cdc_dmm_desc { | |
| 147 | + __u8 bFunctionLength; | |
| 148 | + __u8 bDescriptorType; | |
| 149 | + __u8 bDescriptorSubtype; | |
| 150 | + __u16 bcdVersion; | |
| 151 | + __le16 wMaxCommand; | |
| 152 | +} __attribute__ ((packed)); | |
| 153 | + | |
| 154 | +/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */ | |
| 155 | +struct usb_cdc_mdlm_desc { | |
| 156 | + __u8 bLength; | |
| 157 | + __u8 bDescriptorType; | |
| 158 | + __u8 bDescriptorSubType; | |
| 159 | + | |
| 160 | + __le16 bcdVersion; | |
| 161 | + __u8 bGUID[16]; | |
| 162 | +} __attribute__ ((packed)); | |
| 163 | + | |
| 164 | +/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */ | |
| 165 | +struct usb_cdc_mdlm_detail_desc { | |
| 166 | + __u8 bLength; | |
| 167 | + __u8 bDescriptorType; | |
| 168 | + __u8 bDescriptorSubType; | |
| 169 | + | |
| 170 | + /* type is associated with mdlm_desc.bGUID */ | |
| 171 | + __u8 bGuidDescriptorType; | |
| 172 | + __u8 bDetailData[0]; | |
| 173 | +} __attribute__ ((packed)); | |
| 174 | + | |
| 175 | +/* "OBEX Control Model Functional Descriptor" */ | |
| 176 | +struct usb_cdc_obex_desc { | |
| 177 | + __u8 bLength; | |
| 178 | + __u8 bDescriptorType; | |
| 179 | + __u8 bDescriptorSubType; | |
| 180 | + | |
| 181 | + __le16 bcdVersion; | |
| 182 | +} __attribute__ ((packed)); | |
| 183 | + | |
| 184 | +/* "NCM Control Model Functional Descriptor" */ | |
| 185 | +struct usb_cdc_ncm_desc { | |
| 186 | + __u8 bLength; | |
| 187 | + __u8 bDescriptorType; | |
| 188 | + __u8 bDescriptorSubType; | |
| 189 | + | |
| 190 | + __le16 bcdNcmVersion; | |
| 191 | + __u8 bmNetworkCapabilities; | |
| 192 | +} __attribute__ ((packed)); | |
| 193 | + | |
| 194 | +/* "MBIM Control Model Functional Descriptor" */ | |
| 195 | +struct usb_cdc_mbim_desc { | |
| 196 | + __u8 bLength; | |
| 197 | + __u8 bDescriptorType; | |
| 198 | + __u8 bDescriptorSubType; | |
| 199 | + | |
| 200 | + __le16 bcdMBIMVersion; | |
| 201 | + __le16 wMaxControlMessage; | |
| 202 | + __u8 bNumberFilters; | |
| 203 | + __u8 bMaxFilterSize; | |
| 204 | + __le16 wMaxSegmentSize; | |
| 205 | + __u8 bmNetworkCapabilities; | |
| 206 | +} __attribute__ ((packed)); | |
| 207 | + | |
| 208 | +/*-------------------------------------------------------------------------*/ | |
| 209 | + | |
| 210 | +/* | |
| 211 | + * Class-Specific Control Requests (6.2) | |
| 212 | + * | |
| 213 | + * section 3.6.2.1 table 4 has the ACM profile, for modems. | |
| 214 | + * section 3.8.2 table 10 has the ethernet profile. | |
| 215 | + * | |
| 216 | + * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant, | |
| 217 | + * heavily dependent on the encapsulated (proprietary) command mechanism. | |
| 218 | + */ | |
| 219 | + | |
| 220 | +#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00 | |
| 221 | +#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01 | |
| 222 | +#define USB_CDC_REQ_SET_LINE_CODING 0x20 | |
| 223 | +#define USB_CDC_REQ_GET_LINE_CODING 0x21 | |
| 224 | +#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22 | |
| 225 | +#define USB_CDC_REQ_SEND_BREAK 0x23 | |
| 226 | +#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40 | |
| 227 | +#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41 | |
| 228 | +#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42 | |
| 229 | +#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 | |
| 230 | +#define USB_CDC_GET_ETHERNET_STATISTIC 0x44 | |
| 231 | +#define USB_CDC_GET_NTB_PARAMETERS 0x80 | |
| 232 | +#define USB_CDC_GET_NET_ADDRESS 0x81 | |
| 233 | +#define USB_CDC_SET_NET_ADDRESS 0x82 | |
| 234 | +#define USB_CDC_GET_NTB_FORMAT 0x83 | |
| 235 | +#define USB_CDC_SET_NTB_FORMAT 0x84 | |
| 236 | +#define USB_CDC_GET_NTB_INPUT_SIZE 0x85 | |
| 237 | +#define USB_CDC_SET_NTB_INPUT_SIZE 0x86 | |
| 238 | +#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87 | |
| 239 | +#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88 | |
| 240 | +#define USB_CDC_GET_CRC_MODE 0x89 | |
| 241 | +#define USB_CDC_SET_CRC_MODE 0x8a | |
| 242 | + | |
| 243 | +/* Line Coding Structure from CDC spec 6.2.13 */ | |
| 244 | +struct usb_cdc_line_coding { | |
| 245 | + __le32 dwDTERate; | |
| 246 | + __u8 bCharFormat; | |
| 247 | +#define USB_CDC_1_STOP_BITS 0 | |
| 248 | +#define USB_CDC_1_5_STOP_BITS 1 | |
| 249 | +#define USB_CDC_2_STOP_BITS 2 | |
| 250 | + | |
| 251 | + __u8 bParityType; | |
| 252 | +#define USB_CDC_NO_PARITY 0 | |
| 253 | +#define USB_CDC_ODD_PARITY 1 | |
| 254 | +#define USB_CDC_EVEN_PARITY 2 | |
| 255 | +#define USB_CDC_MARK_PARITY 3 | |
| 256 | +#define USB_CDC_SPACE_PARITY 4 | |
| 257 | + | |
| 258 | + __u8 bDataBits; | |
| 259 | +} __attribute__ ((packed)); | |
| 260 | + | |
| 261 | +/* table 62; bits in multicast filter */ | |
| 262 | +#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0) | |
| 263 | +#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */ | |
| 264 | +#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2) | |
| 265 | +#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3) | |
| 266 | +#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */ | |
| 267 | + | |
| 268 | + | |
| 269 | +/*-------------------------------------------------------------------------*/ | |
| 270 | + | |
| 271 | +/* | |
| 272 | + * Class-Specific Notifications (6.3) sent by interrupt transfers | |
| 273 | + * | |
| 274 | + * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications | |
| 275 | + * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS | |
| 276 | + * RNDIS also defines its own bit-incompatible notifications | |
| 277 | + */ | |
| 278 | + | |
| 279 | +#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00 | |
| 280 | +#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01 | |
| 281 | +#define USB_CDC_NOTIFY_SERIAL_STATE 0x20 | |
| 282 | +#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a | |
| 283 | + | |
| 284 | +struct usb_cdc_notification { | |
| 285 | + __u8 bmRequestType; | |
| 286 | + __u8 bNotificationType; | |
| 287 | + __le16 wValue; | |
| 288 | + __le16 wIndex; | |
| 289 | + __le16 wLength; | |
| 290 | +} __attribute__ ((packed)); | |
| 291 | + | |
| 292 | +struct usb_cdc_speed_change { | |
| 293 | + __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */ | |
| 294 | + __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */ | |
| 295 | +} __attribute__ ((packed)); | |
| 296 | + | |
| 297 | +/*-------------------------------------------------------------------------*/ | |
| 298 | + | |
| 299 | +/* | |
| 300 | + * Class Specific structures and constants | |
| 301 | + * | |
| 302 | + * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1 | |
| 303 | + * | |
| 304 | + */ | |
| 305 | + | |
| 306 | +struct usb_cdc_ncm_ntb_parameters { | |
| 307 | + __le16 wLength; | |
| 308 | + __le16 bmNtbFormatsSupported; | |
| 309 | + __le32 dwNtbInMaxSize; | |
| 310 | + __le16 wNdpInDivisor; | |
| 311 | + __le16 wNdpInPayloadRemainder; | |
| 312 | + __le16 wNdpInAlignment; | |
| 313 | + __le16 wPadding1; | |
| 314 | + __le32 dwNtbOutMaxSize; | |
| 315 | + __le16 wNdpOutDivisor; | |
| 316 | + __le16 wNdpOutPayloadRemainder; | |
| 317 | + __le16 wNdpOutAlignment; | |
| 318 | + __le16 wNtbOutMaxDatagrams; | |
| 319 | +} __attribute__ ((packed)); | |
| 320 | + | |
| 321 | +/* | |
| 322 | + * CDC NCM transfer headers, CDC NCM subclass 3.2 | |
| 323 | + */ | |
| 324 | + | |
| 325 | +#define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */ | |
| 326 | +#define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */ | |
| 327 | + | |
| 328 | +struct usb_cdc_ncm_nth16 { | |
| 329 | + __le32 dwSignature; | |
| 330 | + __le16 wHeaderLength; | |
| 331 | + __le16 wSequence; | |
| 332 | + __le16 wBlockLength; | |
| 333 | + __le16 wNdpIndex; | |
| 334 | +} __attribute__ ((packed)); | |
| 335 | + | |
| 336 | +struct usb_cdc_ncm_nth32 { | |
| 337 | + __le32 dwSignature; | |
| 338 | + __le16 wHeaderLength; | |
| 339 | + __le16 wSequence; | |
| 340 | + __le32 dwBlockLength; | |
| 341 | + __le32 dwNdpIndex; | |
| 342 | +} __attribute__ ((packed)); | |
| 343 | + | |
| 344 | +/* | |
| 345 | + * CDC NCM datagram pointers, CDC NCM subclass 3.3 | |
| 346 | + */ | |
| 347 | + | |
| 348 | +#define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */ | |
| 349 | +#define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */ | |
| 350 | +#define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */ | |
| 351 | +#define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */ | |
| 352 | + | |
| 353 | +#define USB_CDC_MBIM_NDP16_IPS_SIGN 0x00535049 /* IPS<sessionID> : IPS0 for now */ | |
| 354 | +#define USB_CDC_MBIM_NDP32_IPS_SIGN 0x00737069 /* ips<sessionID> : ips0 for now */ | |
| 355 | +#define USB_CDC_MBIM_NDP16_DSS_SIGN 0x00535344 /* DSS<sessionID> */ | |
| 356 | +#define USB_CDC_MBIM_NDP32_DSS_SIGN 0x00737364 /* dss<sessionID> */ | |
| 357 | + | |
| 358 | +/* 16-bit NCM Datagram Pointer Entry */ | |
| 359 | +struct usb_cdc_ncm_dpe16 { | |
| 360 | + __le16 wDatagramIndex; | |
| 361 | + __le16 wDatagramLength; | |
| 362 | +} __attribute__((__packed__)); | |
| 363 | + | |
| 364 | +/* 16-bit NCM Datagram Pointer Table */ | |
| 365 | +struct usb_cdc_ncm_ndp16 { | |
| 366 | + __le32 dwSignature; | |
| 367 | + __le16 wLength; | |
| 368 | + __le16 wNextNdpIndex; | |
| 369 | + struct usb_cdc_ncm_dpe16 dpe16[0]; | |
| 370 | +} __attribute__ ((packed)); | |
| 371 | + | |
| 372 | +/* 32-bit NCM Datagram Pointer Entry */ | |
| 373 | +struct usb_cdc_ncm_dpe32 { | |
| 374 | + __le32 dwDatagramIndex; | |
| 375 | + __le32 dwDatagramLength; | |
| 376 | +} __attribute__((__packed__)); | |
| 377 | + | |
| 378 | +/* 32-bit NCM Datagram Pointer Table */ | |
| 379 | +struct usb_cdc_ncm_ndp32 { | |
| 380 | + __le32 dwSignature; | |
| 381 | + __le16 wLength; | |
| 382 | + __le16 wReserved6; | |
| 383 | + __le32 dwNextNdpIndex; | |
| 384 | + __le32 dwReserved12; | |
| 385 | + struct usb_cdc_ncm_dpe32 dpe32[0]; | |
| 386 | +} __attribute__ ((packed)); | |
| 387 | + | |
| 388 | +/* CDC NCM subclass 3.2.1 and 3.2.2 */ | |
| 389 | +#define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C | |
| 390 | +#define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010 | |
| 391 | + | |
| 392 | +/* CDC NCM subclass 3.3.3 Datagram Formatting */ | |
| 393 | +#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30 | |
| 394 | +#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31 | |
| 395 | + | |
| 396 | +/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */ | |
| 397 | +#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00 | |
| 398 | +#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE | |
| 399 | + | |
| 400 | +/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */ | |
| 401 | +#define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0) | |
| 402 | +#define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1) | |
| 403 | +#define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2) | |
| 404 | +#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3) | |
| 405 | +#define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4) | |
| 406 | +#define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE (1 << 5) | |
| 407 | + | |
| 408 | +/* CDC NCM subclass Table 6-3: NTB Parameter Structure */ | |
| 409 | +#define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0) | |
| 410 | +#define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1) | |
| 411 | + | |
| 412 | +/* CDC NCM subclass Table 6-3: NTB Parameter Structure */ | |
| 413 | +#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04 | |
| 414 | +#define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C | |
| 415 | + | |
| 416 | +/* CDC NCM subclass 6.2.5 SetNtbFormat */ | |
| 417 | +#define USB_CDC_NCM_NTB16_FORMAT 0x00 | |
| 418 | +#define USB_CDC_NCM_NTB32_FORMAT 0x01 | |
| 419 | + | |
| 420 | +/* CDC NCM subclass 6.2.7 SetNtbInputSize */ | |
| 421 | +#define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048 | |
| 422 | +#define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048 | |
| 423 | + | |
| 424 | +/* NTB Input Size Structure */ | |
| 425 | +struct usb_cdc_ncm_ndp_input_size { | |
| 426 | + __le32 dwNtbInMaxSize; | |
| 427 | + __le16 wNtbInMaxDatagrams; | |
| 428 | + __le16 wReserved; | |
| 429 | +} __attribute__ ((packed)); | |
| 430 | + | |
| 431 | +/* CDC NCM subclass 6.2.11 SetCrcMode */ | |
| 432 | +#define USB_CDC_NCM_CRC_NOT_APPENDED 0x00 | |
| 433 | +#define USB_CDC_NCM_CRC_APPENDED 0x01 | |
| 434 | + | |
| 435 | +#endif /* __LINUX_USB_CDC_H */ | |
| @@ -0,0 +1,266 @@ | ||
| 1 | +/* | |
| 2 | + * This file holds Hub protocol constants and data structures that are | |
| 3 | + * defined in chapter 11 (Hub Specification) of the USB 2.0 specification. | |
| 4 | + * | |
| 5 | + * It is used/shared between the USB core, the HCDs and couple of other USB | |
| 6 | + * drivers. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#ifndef __LINUX_CH11_H | |
| 10 | +#define __LINUX_CH11_H | |
| 11 | + | |
| 12 | +#include <linux/types.h> /* __u8 etc */ | |
| 13 | + | |
| 14 | +/* | |
| 15 | + * Hub request types | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) | |
| 19 | +#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) | |
| 20 | + | |
| 21 | +/* | |
| 22 | + * Hub class requests | |
| 23 | + * See USB 2.0 spec Table 11-16 | |
| 24 | + */ | |
| 25 | +#define HUB_CLEAR_TT_BUFFER 8 | |
| 26 | +#define HUB_RESET_TT 9 | |
| 27 | +#define HUB_GET_TT_STATE 10 | |
| 28 | +#define HUB_STOP_TT 11 | |
| 29 | + | |
| 30 | +/* | |
| 31 | + * Hub class additional requests defined by USB 3.0 spec | |
| 32 | + * See USB 3.0 spec Table 10-6 | |
| 33 | + */ | |
| 34 | +#define HUB_SET_DEPTH 12 | |
| 35 | +#define HUB_GET_PORT_ERR_COUNT 13 | |
| 36 | + | |
| 37 | +/* | |
| 38 | + * Hub Class feature numbers | |
| 39 | + * See USB 2.0 spec Table 11-17 | |
| 40 | + */ | |
| 41 | +#define C_HUB_LOCAL_POWER 0 | |
| 42 | +#define C_HUB_OVER_CURRENT 1 | |
| 43 | + | |
| 44 | +/* | |
| 45 | + * Port feature numbers | |
| 46 | + * See USB 2.0 spec Table 11-17 | |
| 47 | + */ | |
| 48 | +#define USB_PORT_FEAT_CONNECTION 0 | |
| 49 | +#define USB_PORT_FEAT_ENABLE 1 | |
| 50 | +#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ | |
| 51 | +#define USB_PORT_FEAT_OVER_CURRENT 3 | |
| 52 | +#define USB_PORT_FEAT_RESET 4 | |
| 53 | +#define USB_PORT_FEAT_L1 5 /* L1 suspend */ | |
| 54 | +#define USB_PORT_FEAT_POWER 8 | |
| 55 | +#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ | |
| 56 | +#define USB_PORT_FEAT_C_CONNECTION 16 | |
| 57 | +#define USB_PORT_FEAT_C_ENABLE 17 | |
| 58 | +#define USB_PORT_FEAT_C_SUSPEND 18 | |
| 59 | +#define USB_PORT_FEAT_C_OVER_CURRENT 19 | |
| 60 | +#define USB_PORT_FEAT_C_RESET 20 | |
| 61 | +#define USB_PORT_FEAT_TEST 21 | |
| 62 | +#define USB_PORT_FEAT_INDICATOR 22 | |
| 63 | +#define USB_PORT_FEAT_C_PORT_L1 23 | |
| 64 | + | |
| 65 | +/* | |
| 66 | + * Port feature selectors added by USB 3.0 spec. | |
| 67 | + * See USB 3.0 spec Table 10-7 | |
| 68 | + */ | |
| 69 | +#define USB_PORT_FEAT_LINK_STATE 5 | |
| 70 | +#define USB_PORT_FEAT_U1_TIMEOUT 23 | |
| 71 | +#define USB_PORT_FEAT_U2_TIMEOUT 24 | |
| 72 | +#define USB_PORT_FEAT_C_PORT_LINK_STATE 25 | |
| 73 | +#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26 | |
| 74 | +#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27 | |
| 75 | +#define USB_PORT_FEAT_BH_PORT_RESET 28 | |
| 76 | +#define USB_PORT_FEAT_C_BH_PORT_RESET 29 | |
| 77 | +#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 | |
| 78 | + | |
| 79 | +#define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8) | |
| 80 | + | |
| 81 | +/* USB 3.0 hub remote wake mask bits, see table 10-14 */ | |
| 82 | +#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) | |
| 83 | +#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) | |
| 84 | +#define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) | |
| 85 | + | |
| 86 | +/* | |
| 87 | + * Hub Status and Hub Change results | |
| 88 | + * See USB 2.0 spec Table 11-19 and Table 11-20 | |
| 89 | + */ | |
| 90 | +struct usb_port_status { | |
| 91 | + __le16 wPortStatus; | |
| 92 | + __le16 wPortChange; | |
| 93 | +} __attribute__ ((packed)); | |
| 94 | + | |
| 95 | +/* | |
| 96 | + * wPortStatus bit field | |
| 97 | + * See USB 2.0 spec Table 11-21 | |
| 98 | + */ | |
| 99 | +#define USB_PORT_STAT_CONNECTION 0x0001 | |
| 100 | +#define USB_PORT_STAT_ENABLE 0x0002 | |
| 101 | +#define USB_PORT_STAT_SUSPEND 0x0004 | |
| 102 | +#define USB_PORT_STAT_OVERCURRENT 0x0008 | |
| 103 | +#define USB_PORT_STAT_RESET 0x0010 | |
| 104 | +#define USB_PORT_STAT_L1 0x0020 | |
| 105 | +/* bits 6 to 7 are reserved */ | |
| 106 | +#define USB_PORT_STAT_POWER 0x0100 | |
| 107 | +#define USB_PORT_STAT_LOW_SPEED 0x0200 | |
| 108 | +#define USB_PORT_STAT_HIGH_SPEED 0x0400 | |
| 109 | +#define USB_PORT_STAT_TEST 0x0800 | |
| 110 | +#define USB_PORT_STAT_INDICATOR 0x1000 | |
| 111 | +/* bits 13 to 15 are reserved */ | |
| 112 | + | |
| 113 | +/* | |
| 114 | + * Additions to wPortStatus bit field from USB 3.0 | |
| 115 | + * See USB 3.0 spec Table 10-10 | |
| 116 | + */ | |
| 117 | +#define USB_PORT_STAT_LINK_STATE 0x01e0 | |
| 118 | +#define USB_SS_PORT_STAT_POWER 0x0200 | |
| 119 | +#define USB_SS_PORT_STAT_SPEED 0x1c00 | |
| 120 | +#define USB_PORT_STAT_SPEED_5GBPS 0x0000 | |
| 121 | +/* Valid only if port is enabled */ | |
| 122 | +/* Bits that are the same from USB 2.0 */ | |
| 123 | +#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \ | |
| 124 | + USB_PORT_STAT_ENABLE | \ | |
| 125 | + USB_PORT_STAT_OVERCURRENT | \ | |
| 126 | + USB_PORT_STAT_RESET) | |
| 127 | + | |
| 128 | +/* | |
| 129 | + * Definitions for PORT_LINK_STATE values | |
| 130 | + * (bits 5-8) in wPortStatus | |
| 131 | + */ | |
| 132 | +#define USB_SS_PORT_LS_U0 0x0000 | |
| 133 | +#define USB_SS_PORT_LS_U1 0x0020 | |
| 134 | +#define USB_SS_PORT_LS_U2 0x0040 | |
| 135 | +#define USB_SS_PORT_LS_U3 0x0060 | |
| 136 | +#define USB_SS_PORT_LS_SS_DISABLED 0x0080 | |
| 137 | +#define USB_SS_PORT_LS_RX_DETECT 0x00a0 | |
| 138 | +#define USB_SS_PORT_LS_SS_INACTIVE 0x00c0 | |
| 139 | +#define USB_SS_PORT_LS_POLLING 0x00e0 | |
| 140 | +#define USB_SS_PORT_LS_RECOVERY 0x0100 | |
| 141 | +#define USB_SS_PORT_LS_HOT_RESET 0x0120 | |
| 142 | +#define USB_SS_PORT_LS_COMP_MOD 0x0140 | |
| 143 | +#define USB_SS_PORT_LS_LOOPBACK 0x0160 | |
| 144 | + | |
| 145 | +/* | |
| 146 | + * wPortChange bit field | |
| 147 | + * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 | |
| 148 | + * Bits 0 to 5 shown, bits 6 to 15 are reserved | |
| 149 | + */ | |
| 150 | +#define USB_PORT_STAT_C_CONNECTION 0x0001 | |
| 151 | +#define USB_PORT_STAT_C_ENABLE 0x0002 | |
| 152 | +#define USB_PORT_STAT_C_SUSPEND 0x0004 | |
| 153 | +#define USB_PORT_STAT_C_OVERCURRENT 0x0008 | |
| 154 | +#define USB_PORT_STAT_C_RESET 0x0010 | |
| 155 | +#define USB_PORT_STAT_C_L1 0x0020 | |
| 156 | +/* | |
| 157 | + * USB 3.0 wPortChange bit fields | |
| 158 | + * See USB 3.0 spec Table 10-11 | |
| 159 | + */ | |
| 160 | +#define USB_PORT_STAT_C_BH_RESET 0x0020 | |
| 161 | +#define USB_PORT_STAT_C_LINK_STATE 0x0040 | |
| 162 | +#define USB_PORT_STAT_C_CONFIG_ERROR 0x0080 | |
| 163 | + | |
| 164 | +/* | |
| 165 | + * wHubCharacteristics (masks) | |
| 166 | + * See USB 2.0 spec Table 11-13, offset 3 | |
| 167 | + */ | |
| 168 | +#define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */ | |
| 169 | +#define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */ | |
| 170 | +#define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */ | |
| 171 | +#define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */ | |
| 172 | + | |
| 173 | +#define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */ | |
| 174 | + | |
| 175 | +#define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */ | |
| 176 | +#define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */ | |
| 177 | +#define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */ | |
| 178 | +#define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */ | |
| 179 | + | |
| 180 | +#define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */ | |
| 181 | +#define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */ | |
| 182 | + | |
| 183 | +struct usb_hub_status { | |
| 184 | + __le16 wHubStatus; | |
| 185 | + __le16 wHubChange; | |
| 186 | +} __attribute__ ((packed)); | |
| 187 | + | |
| 188 | +/* | |
| 189 | + * Hub Status & Hub Change bit masks | |
| 190 | + * See USB 2.0 spec Table 11-19 and Table 11-20 | |
| 191 | + * Bits 0 and 1 for wHubStatus and wHubChange | |
| 192 | + * Bits 2 to 15 are reserved for both | |
| 193 | + */ | |
| 194 | +#define HUB_STATUS_LOCAL_POWER 0x0001 | |
| 195 | +#define HUB_STATUS_OVERCURRENT 0x0002 | |
| 196 | +#define HUB_CHANGE_LOCAL_POWER 0x0001 | |
| 197 | +#define HUB_CHANGE_OVERCURRENT 0x0002 | |
| 198 | + | |
| 199 | + | |
| 200 | +/* | |
| 201 | + * Hub descriptor | |
| 202 | + * See USB 2.0 spec Table 11-13 | |
| 203 | + */ | |
| 204 | + | |
| 205 | +#define USB_DT_HUB (USB_TYPE_CLASS | 0x09) | |
| 206 | +#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a) | |
| 207 | +#define USB_DT_HUB_NONVAR_SIZE 7 | |
| 208 | +#define USB_DT_SS_HUB_SIZE 12 | |
| 209 | + | |
| 210 | +/* | |
| 211 | + * Hub Device descriptor | |
| 212 | + * USB Hub class device protocols | |
| 213 | + */ | |
| 214 | + | |
| 215 | +#define USB_HUB_PR_FS 0 /* Full speed hub */ | |
| 216 | +#define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */ | |
| 217 | +#define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */ | |
| 218 | +#define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */ | |
| 219 | +#define USB_HUB_PR_SS 3 /* Super speed hub */ | |
| 220 | + | |
| 221 | +struct usb_hub_descriptor { | |
| 222 | + __u8 bDescLength; | |
| 223 | + __u8 bDescriptorType; | |
| 224 | + __u8 bNbrPorts; | |
| 225 | + __le16 wHubCharacteristics; | |
| 226 | + __u8 bPwrOn2PwrGood; | |
| 227 | + __u8 bHubContrCurrent; | |
| 228 | + | |
| 229 | + /* 2.0 and 3.0 hubs differ here */ | |
| 230 | + union { | |
| 231 | + struct { | |
| 232 | + /* add 1 bit for hub status change; round to bytes */ | |
| 233 | + __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; | |
| 234 | + __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; | |
| 235 | + } __attribute__ ((packed)) hs; | |
| 236 | + | |
| 237 | + struct { | |
| 238 | + __u8 bHubHdrDecLat; | |
| 239 | + __le16 wHubDelay; | |
| 240 | + __le16 DeviceRemovable; | |
| 241 | + } __attribute__ ((packed)) ss; | |
| 242 | + } u; | |
| 243 | +} __attribute__ ((packed)); | |
| 244 | + | |
| 245 | +/* port indicator status selectors, tables 11-7 and 11-25 */ | |
| 246 | +#define HUB_LED_AUTO 0 | |
| 247 | +#define HUB_LED_AMBER 1 | |
| 248 | +#define HUB_LED_GREEN 2 | |
| 249 | +#define HUB_LED_OFF 3 | |
| 250 | + | |
| 251 | +enum hub_led_mode { | |
| 252 | + INDICATOR_AUTO = 0, | |
| 253 | + INDICATOR_CYCLE, | |
| 254 | + /* software blinks for attention: software, hardware, reserved */ | |
| 255 | + INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF, | |
| 256 | + INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF, | |
| 257 | + INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF | |
| 258 | +} __attribute__ ((packed)); | |
| 259 | + | |
| 260 | +/* Transaction Translator Think Times, in bits */ | |
| 261 | +#define HUB_TTTT_8_BITS 0x00 | |
| 262 | +#define HUB_TTTT_16_BITS 0x20 | |
| 263 | +#define HUB_TTTT_24_BITS 0x40 | |
| 264 | +#define HUB_TTTT_32_BITS 0x60 | |
| 265 | + | |
| 266 | +#endif /* __LINUX_CH11_H */ | |
| @@ -0,0 +1,993 @@ | ||
| 1 | +/* | |
| 2 | + * This file holds USB constants and structures that are needed for | |
| 3 | + * USB device APIs. These are used by the USB device model, which is | |
| 4 | + * defined in chapter 9 of the USB 2.0 specification and in the | |
| 5 | + * Wireless USB 1.0 (spread around). Linux has several APIs in C that | |
| 6 | + * need these: | |
| 7 | + * | |
| 8 | + * - the master/host side Linux-USB kernel driver API; | |
| 9 | + * - the "usbfs" user space API; and | |
| 10 | + * - the Linux "gadget" slave/device/peripheral side driver API. | |
| 11 | + * | |
| 12 | + * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems | |
| 13 | + * act either as a USB master/host or as a USB slave/device. That means | |
| 14 | + * the master and slave side APIs benefit from working well together. | |
| 15 | + * | |
| 16 | + * There's also "Wireless USB", using low power short range radios for | |
| 17 | + * peripheral interconnection but otherwise building on the USB framework. | |
| 18 | + * | |
| 19 | + * Note all descriptors are declared '__attribute__((packed))' so that: | |
| 20 | + * | |
| 21 | + * [a] they never get padded, either internally (USB spec writers | |
| 22 | + * probably handled that) or externally; | |
| 23 | + * | |
| 24 | + * [b] so that accessing bigger-than-a-bytes fields will never | |
| 25 | + * generate bus errors on any platform, even when the location of | |
| 26 | + * its descriptor inside a bundle isn't "naturally aligned", and | |
| 27 | + * | |
| 28 | + * [c] for consistency, removing all doubt even when it appears to | |
| 29 | + * someone that the two other points are non-issues for that | |
| 30 | + * particular descriptor type. | |
| 31 | + */ | |
| 32 | + | |
| 33 | +#ifndef _UAPI__LINUX_USB_CH9_H | |
| 34 | +#define _UAPI__LINUX_USB_CH9_H | |
| 35 | + | |
| 36 | +#include <linux/types.h> /* __u8 etc */ | |
| 37 | +#include <asm/byteorder.h> /* le16_to_cpu */ | |
| 38 | + | |
| 39 | +/*-------------------------------------------------------------------------*/ | |
| 40 | + | |
| 41 | +/* CONTROL REQUEST SUPPORT */ | |
| 42 | + | |
| 43 | +/* | |
| 44 | + * USB directions | |
| 45 | + * | |
| 46 | + * This bit flag is used in endpoint descriptors' bEndpointAddress field. | |
| 47 | + * It's also one of three fields in control requests bRequestType. | |
| 48 | + */ | |
| 49 | +#define USB_DIR_OUT 0 /* to device */ | |
| 50 | +#define USB_DIR_IN 0x80 /* to host */ | |
| 51 | + | |
| 52 | +/* | |
| 53 | + * USB types, the second of three bRequestType fields | |
| 54 | + */ | |
| 55 | +#define USB_TYPE_MASK (0x03 << 5) | |
| 56 | +#define USB_TYPE_STANDARD (0x00 << 5) | |
| 57 | +#define USB_TYPE_CLASS (0x01 << 5) | |
| 58 | +#define USB_TYPE_VENDOR (0x02 << 5) | |
| 59 | +#define USB_TYPE_RESERVED (0x03 << 5) | |
| 60 | + | |
| 61 | +/* | |
| 62 | + * USB recipients, the third of three bRequestType fields | |
| 63 | + */ | |
| 64 | +#define USB_RECIP_MASK 0x1f | |
| 65 | +#define USB_RECIP_DEVICE 0x00 | |
| 66 | +#define USB_RECIP_INTERFACE 0x01 | |
| 67 | +#define USB_RECIP_ENDPOINT 0x02 | |
| 68 | +#define USB_RECIP_OTHER 0x03 | |
| 69 | +/* From Wireless USB 1.0 */ | |
| 70 | +#define USB_RECIP_PORT 0x04 | |
| 71 | +#define USB_RECIP_RPIPE 0x05 | |
| 72 | + | |
| 73 | +/* | |
| 74 | + * Standard requests, for the bRequest field of a SETUP packet. | |
| 75 | + * | |
| 76 | + * These are qualified by the bRequestType field, so that for example | |
| 77 | + * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved | |
| 78 | + * by a GET_STATUS request. | |
| 79 | + */ | |
| 80 | +#define USB_REQ_GET_STATUS 0x00 | |
| 81 | +#define USB_REQ_CLEAR_FEATURE 0x01 | |
| 82 | +#define USB_REQ_SET_FEATURE 0x03 | |
| 83 | +#define USB_REQ_SET_ADDRESS 0x05 | |
| 84 | +#define USB_REQ_GET_DESCRIPTOR 0x06 | |
| 85 | +#define USB_REQ_SET_DESCRIPTOR 0x07 | |
| 86 | +#define USB_REQ_GET_CONFIGURATION 0x08 | |
| 87 | +#define USB_REQ_SET_CONFIGURATION 0x09 | |
| 88 | +#define USB_REQ_GET_INTERFACE 0x0A | |
| 89 | +#define USB_REQ_SET_INTERFACE 0x0B | |
| 90 | +#define USB_REQ_SYNCH_FRAME 0x0C | |
| 91 | +#define USB_REQ_SET_SEL 0x30 | |
| 92 | +#define USB_REQ_SET_ISOCH_DELAY 0x31 | |
| 93 | + | |
| 94 | +#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */ | |
| 95 | +#define USB_REQ_GET_ENCRYPTION 0x0E | |
| 96 | +#define USB_REQ_RPIPE_ABORT 0x0E | |
| 97 | +#define USB_REQ_SET_HANDSHAKE 0x0F | |
| 98 | +#define USB_REQ_RPIPE_RESET 0x0F | |
| 99 | +#define USB_REQ_GET_HANDSHAKE 0x10 | |
| 100 | +#define USB_REQ_SET_CONNECTION 0x11 | |
| 101 | +#define USB_REQ_SET_SECURITY_DATA 0x12 | |
| 102 | +#define USB_REQ_GET_SECURITY_DATA 0x13 | |
| 103 | +#define USB_REQ_SET_WUSB_DATA 0x14 | |
| 104 | +#define USB_REQ_LOOPBACK_DATA_WRITE 0x15 | |
| 105 | +#define USB_REQ_LOOPBACK_DATA_READ 0x16 | |
| 106 | +#define USB_REQ_SET_INTERFACE_DS 0x17 | |
| 107 | + | |
| 108 | +/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, | |
| 109 | + * used by hubs to put ports into a new L1 suspend state, except that it | |
| 110 | + * forgot to define its number ... | |
| 111 | + */ | |
| 112 | + | |
| 113 | +/* | |
| 114 | + * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and | |
| 115 | + * are read as a bit array returned by USB_REQ_GET_STATUS. (So there | |
| 116 | + * are at most sixteen features of each type.) Hubs may also support a | |
| 117 | + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. | |
| 118 | + */ | |
| 119 | +#define USB_DEVICE_SELF_POWERED 0 /* (read only) */ | |
| 120 | +#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ | |
| 121 | +#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ | |
| 122 | +#define USB_DEVICE_BATTERY 2 /* (wireless) */ | |
| 123 | +#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ | |
| 124 | +#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ | |
| 125 | +#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ | |
| 126 | +#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ | |
| 127 | +#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ | |
| 128 | + | |
| 129 | +/* | |
| 130 | + * Test Mode Selectors | |
| 131 | + * See USB 2.0 spec Table 9-7 | |
| 132 | + */ | |
| 133 | +#define TEST_J 1 | |
| 134 | +#define TEST_K 2 | |
| 135 | +#define TEST_SE0_NAK 3 | |
| 136 | +#define TEST_PACKET 4 | |
| 137 | +#define TEST_FORCE_EN 5 | |
| 138 | + | |
| 139 | +/* | |
| 140 | + * New Feature Selectors as added by USB 3.0 | |
| 141 | + * See USB 3.0 spec Table 9-6 | |
| 142 | + */ | |
| 143 | +#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ | |
| 144 | +#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */ | |
| 145 | +#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */ | |
| 146 | +#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */ | |
| 147 | + | |
| 148 | +#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 | |
| 149 | +/* | |
| 150 | + * Suspend Options, Table 9-7 USB 3.0 spec | |
| 151 | + */ | |
| 152 | +#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0)) | |
| 153 | +#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1)) | |
| 154 | + | |
| 155 | +#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ | |
| 156 | + | |
| 157 | +/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */ | |
| 158 | +#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */ | |
| 159 | +#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ | |
| 160 | +#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ | |
| 161 | + | |
| 162 | +/** | |
| 163 | + * struct usb_ctrlrequest - SETUP data for a USB device control request | |
| 164 | + * @bRequestType: matches the USB bmRequestType field | |
| 165 | + * @bRequest: matches the USB bRequest field | |
| 166 | + * @wValue: matches the USB wValue field (le16 byte order) | |
| 167 | + * @wIndex: matches the USB wIndex field (le16 byte order) | |
| 168 | + * @wLength: matches the USB wLength field (le16 byte order) | |
| 169 | + * | |
| 170 | + * This structure is used to send control requests to a USB device. It matches | |
| 171 | + * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the | |
| 172 | + * USB spec for a fuller description of the different fields, and what they are | |
| 173 | + * used for. | |
| 174 | + * | |
| 175 | + * Note that the driver for any interface can issue control requests. | |
| 176 | + * For most devices, interfaces don't coordinate with each other, so | |
| 177 | + * such requests may be made at any time. | |
| 178 | + */ | |
| 179 | +struct usb_ctrlrequest { | |
| 180 | + __u8 bRequestType; | |
| 181 | + __u8 bRequest; | |
| 182 | + __le16 wValue; | |
| 183 | + __le16 wIndex; | |
| 184 | + __le16 wLength; | |
| 185 | +} __attribute__ ((packed)); | |
| 186 | + | |
| 187 | +/*-------------------------------------------------------------------------*/ | |
| 188 | + | |
| 189 | +/* | |
| 190 | + * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or | |
| 191 | + * (rarely) accepted by SET_DESCRIPTOR. | |
| 192 | + * | |
| 193 | + * Note that all multi-byte values here are encoded in little endian | |
| 194 | + * byte order "on the wire". Within the kernel and when exposed | |
| 195 | + * through the Linux-USB APIs, they are not converted to cpu byte | |
| 196 | + * order; it is the responsibility of the client code to do this. | |
| 197 | + * The single exception is when device and configuration descriptors (but | |
| 198 | + * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD); | |
| 199 | + * in this case the fields are converted to host endianness by the kernel. | |
| 200 | + */ | |
| 201 | + | |
| 202 | +/* | |
| 203 | + * Descriptor types ... USB 2.0 spec table 9.5 | |
| 204 | + */ | |
| 205 | +#define USB_DT_DEVICE 0x01 | |
| 206 | +#define USB_DT_CONFIG 0x02 | |
| 207 | +#define USB_DT_STRING 0x03 | |
| 208 | +#define USB_DT_INTERFACE 0x04 | |
| 209 | +#define USB_DT_ENDPOINT 0x05 | |
| 210 | +#define USB_DT_DEVICE_QUALIFIER 0x06 | |
| 211 | +#define USB_DT_OTHER_SPEED_CONFIG 0x07 | |
| 212 | +#define USB_DT_INTERFACE_POWER 0x08 | |
| 213 | +/* these are from a minor usb 2.0 revision (ECN) */ | |
| 214 | +#define USB_DT_OTG 0x09 | |
| 215 | +#define USB_DT_DEBUG 0x0a | |
| 216 | +#define USB_DT_INTERFACE_ASSOCIATION 0x0b | |
| 217 | +/* these are from the Wireless USB spec */ | |
| 218 | +#define USB_DT_SECURITY 0x0c | |
| 219 | +#define USB_DT_KEY 0x0d | |
| 220 | +#define USB_DT_ENCRYPTION_TYPE 0x0e | |
| 221 | +#define USB_DT_BOS 0x0f | |
| 222 | +#define USB_DT_DEVICE_CAPABILITY 0x10 | |
| 223 | +#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 | |
| 224 | +#define USB_DT_WIRE_ADAPTER 0x21 | |
| 225 | +#define USB_DT_RPIPE 0x22 | |
| 226 | +#define USB_DT_CS_RADIO_CONTROL 0x23 | |
| 227 | +/* From the T10 UAS specification */ | |
| 228 | +#define USB_DT_PIPE_USAGE 0x24 | |
| 229 | +/* From the USB 3.0 spec */ | |
| 230 | +#define USB_DT_SS_ENDPOINT_COMP 0x30 | |
| 231 | + | |
| 232 | +/* Conventional codes for class-specific descriptors. The convention is | |
| 233 | + * defined in the USB "Common Class" Spec (3.11). Individual class specs | |
| 234 | + * are authoritative for their usage, not the "common class" writeup. | |
| 235 | + */ | |
| 236 | +#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) | |
| 237 | +#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) | |
| 238 | +#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | |
| 239 | +#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | |
| 240 | +#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | |
| 241 | + | |
| 242 | +/* All standard descriptors have these 2 fields at the beginning */ | |
| 243 | +struct usb_descriptor_header { | |
| 244 | + __u8 bLength; | |
| 245 | + __u8 bDescriptorType; | |
| 246 | +} __attribute__ ((packed)); | |
| 247 | + | |
| 248 | + | |
| 249 | +/*-------------------------------------------------------------------------*/ | |
| 250 | + | |
| 251 | +/* USB_DT_DEVICE: Device descriptor */ | |
| 252 | +struct usb_device_descriptor { | |
| 253 | + __u8 bLength; | |
| 254 | + __u8 bDescriptorType; | |
| 255 | + | |
| 256 | + __le16 bcdUSB; | |
| 257 | + __u8 bDeviceClass; | |
| 258 | + __u8 bDeviceSubClass; | |
| 259 | + __u8 bDeviceProtocol; | |
| 260 | + __u8 bMaxPacketSize0; | |
| 261 | + __le16 idVendor; | |
| 262 | + __le16 idProduct; | |
| 263 | + __le16 bcdDevice; | |
| 264 | + __u8 iManufacturer; | |
| 265 | + __u8 iProduct; | |
| 266 | + __u8 iSerialNumber; | |
| 267 | + __u8 bNumConfigurations; | |
| 268 | +} __attribute__ ((packed)); | |
| 269 | + | |
| 270 | +#define USB_DT_DEVICE_SIZE 18 | |
| 271 | + | |
| 272 | + | |
| 273 | +/* | |
| 274 | + * Device and/or Interface Class codes | |
| 275 | + * as found in bDeviceClass or bInterfaceClass | |
| 276 | + * and defined by www.usb.org documents | |
| 277 | + */ | |
| 278 | +#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ | |
| 279 | +#define USB_CLASS_AUDIO 1 | |
| 280 | +#define USB_CLASS_COMM 2 | |
| 281 | +#define USB_CLASS_HID 3 | |
| 282 | +#define USB_CLASS_PHYSICAL 5 | |
| 283 | +#define USB_CLASS_STILL_IMAGE 6 | |
| 284 | +#define USB_CLASS_PRINTER 7 | |
| 285 | +#define USB_CLASS_MASS_STORAGE 8 | |
| 286 | +#define USB_CLASS_HUB 9 | |
| 287 | +#define USB_CLASS_CDC_DATA 0x0a | |
| 288 | +#define USB_CLASS_CSCID 0x0b /* chip+ smart card */ | |
| 289 | +#define USB_CLASS_CONTENT_SEC 0x0d /* content security */ | |
| 290 | +#define USB_CLASS_VIDEO 0x0e | |
| 291 | +#define USB_CLASS_WIRELESS_CONTROLLER 0xe0 | |
| 292 | +#define USB_CLASS_MISC 0xef | |
| 293 | +#define USB_CLASS_APP_SPEC 0xfe | |
| 294 | +#define USB_CLASS_VENDOR_SPEC 0xff | |
| 295 | + | |
| 296 | +#define USB_SUBCLASS_VENDOR_SPEC 0xff | |
| 297 | + | |
| 298 | +/*-------------------------------------------------------------------------*/ | |
| 299 | + | |
| 300 | +/* USB_DT_CONFIG: Configuration descriptor information. | |
| 301 | + * | |
| 302 | + * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the | |
| 303 | + * descriptor type is different. Highspeed-capable devices can look | |
| 304 | + * different depending on what speed they're currently running. Only | |
| 305 | + * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG | |
| 306 | + * descriptors. | |
| 307 | + */ | |
| 308 | +struct usb_config_descriptor { | |
| 309 | + __u8 bLength; | |
| 310 | + __u8 bDescriptorType; | |
| 311 | + | |
| 312 | + __le16 wTotalLength; | |
| 313 | + __u8 bNumInterfaces; | |
| 314 | + __u8 bConfigurationValue; | |
| 315 | + __u8 iConfiguration; | |
| 316 | + __u8 bmAttributes; | |
| 317 | + __u8 bMaxPower; | |
| 318 | +} __attribute__ ((packed)); | |
| 319 | + | |
| 320 | +#define USB_DT_CONFIG_SIZE 9 | |
| 321 | + | |
| 322 | +/* from config descriptor bmAttributes */ | |
| 323 | +#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ | |
| 324 | +#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ | |
| 325 | +#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ | |
| 326 | +#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ | |
| 327 | + | |
| 328 | +/*-------------------------------------------------------------------------*/ | |
| 329 | + | |
| 330 | +/* USB_DT_STRING: String descriptor */ | |
| 331 | +struct usb_string_descriptor { | |
| 332 | + __u8 bLength; | |
| 333 | + __u8 bDescriptorType; | |
| 334 | + | |
| 335 | + __le16 wData[1]; /* UTF-16LE encoded */ | |
| 336 | +} __attribute__ ((packed)); | |
| 337 | + | |
| 338 | +/* note that "string" zero is special, it holds language codes that | |
| 339 | + * the device supports, not Unicode characters. | |
| 340 | + */ | |
| 341 | + | |
| 342 | +/*-------------------------------------------------------------------------*/ | |
| 343 | + | |
| 344 | +/* USB_DT_INTERFACE: Interface descriptor */ | |
| 345 | +struct usb_interface_descriptor { | |
| 346 | + __u8 bLength; | |
| 347 | + __u8 bDescriptorType; | |
| 348 | + | |
| 349 | + __u8 bInterfaceNumber; | |
| 350 | + __u8 bAlternateSetting; | |
| 351 | + __u8 bNumEndpoints; | |
| 352 | + __u8 bInterfaceClass; | |
| 353 | + __u8 bInterfaceSubClass; | |
| 354 | + __u8 bInterfaceProtocol; | |
| 355 | + __u8 iInterface; | |
| 356 | +} __attribute__ ((packed)); | |
| 357 | + | |
| 358 | +#define USB_DT_INTERFACE_SIZE 9 | |
| 359 | + | |
| 360 | +/*-------------------------------------------------------------------------*/ | |
| 361 | + | |
| 362 | +/* USB_DT_ENDPOINT: Endpoint descriptor */ | |
| 363 | +struct usb_endpoint_descriptor { | |
| 364 | + __u8 bLength; | |
| 365 | + __u8 bDescriptorType; | |
| 366 | + | |
| 367 | + __u8 bEndpointAddress; | |
| 368 | + __u8 bmAttributes; | |
| 369 | + __le16 wMaxPacketSize; | |
| 370 | + __u8 bInterval; | |
| 371 | + | |
| 372 | + /* NOTE: these two are _only_ in audio endpoints. */ | |
| 373 | + /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | |
| 374 | + __u8 bRefresh; | |
| 375 | + __u8 bSynchAddress; | |
| 376 | +} __attribute__ ((packed)); | |
| 377 | + | |
| 378 | +#define USB_DT_ENDPOINT_SIZE 7 | |
| 379 | +#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | |
| 380 | + | |
| 381 | + | |
| 382 | +/* | |
| 383 | + * Endpoints | |
| 384 | + */ | |
| 385 | +#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ | |
| 386 | +#define USB_ENDPOINT_DIR_MASK 0x80 | |
| 387 | + | |
| 388 | +#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ | |
| 389 | +#define USB_ENDPOINT_XFER_CONTROL 0 | |
| 390 | +#define USB_ENDPOINT_XFER_ISOC 1 | |
| 391 | +#define USB_ENDPOINT_XFER_BULK 2 | |
| 392 | +#define USB_ENDPOINT_XFER_INT 3 | |
| 393 | +#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | |
| 394 | + | |
| 395 | +/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */ | |
| 396 | +#define USB_ENDPOINT_INTRTYPE 0x30 | |
| 397 | +#define USB_ENDPOINT_INTR_PERIODIC (0 << 4) | |
| 398 | +#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4) | |
| 399 | + | |
| 400 | +#define USB_ENDPOINT_SYNCTYPE 0x0c | |
| 401 | +#define USB_ENDPOINT_SYNC_NONE (0 << 2) | |
| 402 | +#define USB_ENDPOINT_SYNC_ASYNC (1 << 2) | |
| 403 | +#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) | |
| 404 | +#define USB_ENDPOINT_SYNC_SYNC (3 << 2) | |
| 405 | + | |
| 406 | +#define USB_ENDPOINT_USAGE_MASK 0x30 | |
| 407 | +#define USB_ENDPOINT_USAGE_DATA 0x00 | |
| 408 | +#define USB_ENDPOINT_USAGE_FEEDBACK 0x10 | |
| 409 | +#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */ | |
| 410 | + | |
| 411 | +/*-------------------------------------------------------------------------*/ | |
| 412 | + | |
| 413 | +/** | |
| 414 | + * usb_endpoint_num - get the endpoint's number | |
| 415 | + * @epd: endpoint to be checked | |
| 416 | + * | |
| 417 | + * Returns @epd's number: 0 to 15. | |
| 418 | + */ | |
| 419 | +static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) | |
| 420 | +{ | |
| 421 | + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | |
| 422 | +} | |
| 423 | + | |
| 424 | +/** | |
| 425 | + * usb_endpoint_type - get the endpoint's transfer type | |
| 426 | + * @epd: endpoint to be checked | |
| 427 | + * | |
| 428 | + * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according | |
| 429 | + * to @epd's transfer type. | |
| 430 | + */ | |
| 431 | +static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) | |
| 432 | +{ | |
| 433 | + return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | |
| 434 | +} | |
| 435 | + | |
| 436 | +/** | |
| 437 | + * usb_endpoint_dir_in - check if the endpoint has IN direction | |
| 438 | + * @epd: endpoint to be checked | |
| 439 | + * | |
| 440 | + * Returns true if the endpoint is of type IN, otherwise it returns false. | |
| 441 | + */ | |
| 442 | +static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | |
| 443 | +{ | |
| 444 | + return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | |
| 445 | +} | |
| 446 | + | |
| 447 | +/** | |
| 448 | + * usb_endpoint_dir_out - check if the endpoint has OUT direction | |
| 449 | + * @epd: endpoint to be checked | |
| 450 | + * | |
| 451 | + * Returns true if the endpoint is of type OUT, otherwise it returns false. | |
| 452 | + */ | |
| 453 | +static inline int usb_endpoint_dir_out( | |
| 454 | + const struct usb_endpoint_descriptor *epd) | |
| 455 | +{ | |
| 456 | + return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | |
| 457 | +} | |
| 458 | + | |
| 459 | +/** | |
| 460 | + * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | |
| 461 | + * @epd: endpoint to be checked | |
| 462 | + * | |
| 463 | + * Returns true if the endpoint is of type bulk, otherwise it returns false. | |
| 464 | + */ | |
| 465 | +static inline int usb_endpoint_xfer_bulk( | |
| 466 | + const struct usb_endpoint_descriptor *epd) | |
| 467 | +{ | |
| 468 | + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | |
| 469 | + USB_ENDPOINT_XFER_BULK); | |
| 470 | +} | |
| 471 | + | |
| 472 | +/** | |
| 473 | + * usb_endpoint_xfer_control - check if the endpoint has control transfer type | |
| 474 | + * @epd: endpoint to be checked | |
| 475 | + * | |
| 476 | + * Returns true if the endpoint is of type control, otherwise it returns false. | |
| 477 | + */ | |
| 478 | +static inline int usb_endpoint_xfer_control( | |
| 479 | + const struct usb_endpoint_descriptor *epd) | |
| 480 | +{ | |
| 481 | + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | |
| 482 | + USB_ENDPOINT_XFER_CONTROL); | |
| 483 | +} | |
| 484 | + | |
| 485 | +/** | |
| 486 | + * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | |
| 487 | + * @epd: endpoint to be checked | |
| 488 | + * | |
| 489 | + * Returns true if the endpoint is of type interrupt, otherwise it returns | |
| 490 | + * false. | |
| 491 | + */ | |
| 492 | +static inline int usb_endpoint_xfer_int( | |
| 493 | + const struct usb_endpoint_descriptor *epd) | |
| 494 | +{ | |
| 495 | + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | |
| 496 | + USB_ENDPOINT_XFER_INT); | |
| 497 | +} | |
| 498 | + | |
| 499 | +/** | |
| 500 | + * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | |
| 501 | + * @epd: endpoint to be checked | |
| 502 | + * | |
| 503 | + * Returns true if the endpoint is of type isochronous, otherwise it returns | |
| 504 | + * false. | |
| 505 | + */ | |
| 506 | +static inline int usb_endpoint_xfer_isoc( | |
| 507 | + const struct usb_endpoint_descriptor *epd) | |
| 508 | +{ | |
| 509 | + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | |
| 510 | + USB_ENDPOINT_XFER_ISOC); | |
| 511 | +} | |
| 512 | + | |
| 513 | +/** | |
| 514 | + * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | |
| 515 | + * @epd: endpoint to be checked | |
| 516 | + * | |
| 517 | + * Returns true if the endpoint has bulk transfer type and IN direction, | |
| 518 | + * otherwise it returns false. | |
| 519 | + */ | |
| 520 | +static inline int usb_endpoint_is_bulk_in( | |
| 521 | + const struct usb_endpoint_descriptor *epd) | |
| 522 | +{ | |
| 523 | + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); | |
| 524 | +} | |
| 525 | + | |
| 526 | +/** | |
| 527 | + * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | |
| 528 | + * @epd: endpoint to be checked | |
| 529 | + * | |
| 530 | + * Returns true if the endpoint has bulk transfer type and OUT direction, | |
| 531 | + * otherwise it returns false. | |
| 532 | + */ | |
| 533 | +static inline int usb_endpoint_is_bulk_out( | |
| 534 | + const struct usb_endpoint_descriptor *epd) | |
| 535 | +{ | |
| 536 | + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); | |
| 537 | +} | |
| 538 | + | |
| 539 | +/** | |
| 540 | + * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | |
| 541 | + * @epd: endpoint to be checked | |
| 542 | + * | |
| 543 | + * Returns true if the endpoint has interrupt transfer type and IN direction, | |
| 544 | + * otherwise it returns false. | |
| 545 | + */ | |
| 546 | +static inline int usb_endpoint_is_int_in( | |
| 547 | + const struct usb_endpoint_descriptor *epd) | |
| 548 | +{ | |
| 549 | + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); | |
| 550 | +} | |
| 551 | + | |
| 552 | +/** | |
| 553 | + * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | |
| 554 | + * @epd: endpoint to be checked | |
| 555 | + * | |
| 556 | + * Returns true if the endpoint has interrupt transfer type and OUT direction, | |
| 557 | + * otherwise it returns false. | |
| 558 | + */ | |
| 559 | +static inline int usb_endpoint_is_int_out( | |
| 560 | + const struct usb_endpoint_descriptor *epd) | |
| 561 | +{ | |
| 562 | + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); | |
| 563 | +} | |
| 564 | + | |
| 565 | +/** | |
| 566 | + * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | |
| 567 | + * @epd: endpoint to be checked | |
| 568 | + * | |
| 569 | + * Returns true if the endpoint has isochronous transfer type and IN direction, | |
| 570 | + * otherwise it returns false. | |
| 571 | + */ | |
| 572 | +static inline int usb_endpoint_is_isoc_in( | |
| 573 | + const struct usb_endpoint_descriptor *epd) | |
| 574 | +{ | |
| 575 | + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); | |
| 576 | +} | |
| 577 | + | |
| 578 | +/** | |
| 579 | + * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | |
| 580 | + * @epd: endpoint to be checked | |
| 581 | + * | |
| 582 | + * Returns true if the endpoint has isochronous transfer type and OUT direction, | |
| 583 | + * otherwise it returns false. | |
| 584 | + */ | |
| 585 | +static inline int usb_endpoint_is_isoc_out( | |
| 586 | + const struct usb_endpoint_descriptor *epd) | |
| 587 | +{ | |
| 588 | + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); | |
| 589 | +} | |
| 590 | + | |
| 591 | +/** | |
| 592 | + * usb_endpoint_maxp - get endpoint's max packet size | |
| 593 | + * @epd: endpoint to be checked | |
| 594 | + * | |
| 595 | + * Returns @epd's max packet | |
| 596 | + */ | |
| 597 | +static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd) | |
| 598 | +{ | |
| 599 | + return __le16_to_cpu(epd->wMaxPacketSize); | |
| 600 | +} | |
| 601 | + | |
| 602 | +static inline int usb_endpoint_interrupt_type( | |
| 603 | + const struct usb_endpoint_descriptor *epd) | |
| 604 | +{ | |
| 605 | + return epd->bmAttributes & USB_ENDPOINT_INTRTYPE; | |
| 606 | +} | |
| 607 | + | |
| 608 | +/*-------------------------------------------------------------------------*/ | |
| 609 | + | |
| 610 | +/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ | |
| 611 | +struct usb_ss_ep_comp_descriptor { | |
| 612 | + __u8 bLength; | |
| 613 | + __u8 bDescriptorType; | |
| 614 | + | |
| 615 | + __u8 bMaxBurst; | |
| 616 | + __u8 bmAttributes; | |
| 617 | + __le16 wBytesPerInterval; | |
| 618 | +} __attribute__ ((packed)); | |
| 619 | + | |
| 620 | +#define USB_DT_SS_EP_COMP_SIZE 6 | |
| 621 | + | |
| 622 | +/* Bits 4:0 of bmAttributes if this is a bulk endpoint */ | |
| 623 | +static inline int | |
| 624 | +usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp) | |
| 625 | +{ | |
| 626 | + int max_streams; | |
| 627 | + | |
| 628 | + if (!comp) | |
| 629 | + return 0; | |
| 630 | + | |
| 631 | + max_streams = comp->bmAttributes & 0x1f; | |
| 632 | + | |
| 633 | + if (!max_streams) | |
| 634 | + return 0; | |
| 635 | + | |
| 636 | + max_streams = 1 << max_streams; | |
| 637 | + | |
| 638 | + return max_streams; | |
| 639 | +} | |
| 640 | + | |
| 641 | +/* Bits 1:0 of bmAttributes if this is an isoc endpoint */ | |
| 642 | +#define USB_SS_MULT(p) (1 + ((p) & 0x3)) | |
| 643 | + | |
| 644 | +/*-------------------------------------------------------------------------*/ | |
| 645 | + | |
| 646 | +/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ | |
| 647 | +struct usb_qualifier_descriptor { | |
| 648 | + __u8 bLength; | |
| 649 | + __u8 bDescriptorType; | |
| 650 | + | |
| 651 | + __le16 bcdUSB; | |
| 652 | + __u8 bDeviceClass; | |
| 653 | + __u8 bDeviceSubClass; | |
| 654 | + __u8 bDeviceProtocol; | |
| 655 | + __u8 bMaxPacketSize0; | |
| 656 | + __u8 bNumConfigurations; | |
| 657 | + __u8 bRESERVED; | |
| 658 | +} __attribute__ ((packed)); | |
| 659 | + | |
| 660 | + | |
| 661 | +/*-------------------------------------------------------------------------*/ | |
| 662 | + | |
| 663 | +/* USB_DT_OTG (from OTG 1.0a supplement) */ | |
| 664 | +struct usb_otg_descriptor { | |
| 665 | + __u8 bLength; | |
| 666 | + __u8 bDescriptorType; | |
| 667 | + | |
| 668 | + __u8 bmAttributes; /* support for HNP, SRP, etc */ | |
| 669 | +} __attribute__ ((packed)); | |
| 670 | + | |
| 671 | +/* from usb_otg_descriptor.bmAttributes */ | |
| 672 | +#define USB_OTG_SRP (1 << 0) | |
| 673 | +#define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | |
| 674 | + | |
| 675 | +/*-------------------------------------------------------------------------*/ | |
| 676 | + | |
| 677 | +/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ | |
| 678 | +struct usb_debug_descriptor { | |
| 679 | + __u8 bLength; | |
| 680 | + __u8 bDescriptorType; | |
| 681 | + | |
| 682 | + /* bulk endpoints with 8 byte maxpacket */ | |
| 683 | + __u8 bDebugInEndpoint; | |
| 684 | + __u8 bDebugOutEndpoint; | |
| 685 | +} __attribute__((packed)); | |
| 686 | + | |
| 687 | +/*-------------------------------------------------------------------------*/ | |
| 688 | + | |
| 689 | +/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ | |
| 690 | +struct usb_interface_assoc_descriptor { | |
| 691 | + __u8 bLength; | |
| 692 | + __u8 bDescriptorType; | |
| 693 | + | |
| 694 | + __u8 bFirstInterface; | |
| 695 | + __u8 bInterfaceCount; | |
| 696 | + __u8 bFunctionClass; | |
| 697 | + __u8 bFunctionSubClass; | |
| 698 | + __u8 bFunctionProtocol; | |
| 699 | + __u8 iFunction; | |
| 700 | +} __attribute__ ((packed)); | |
| 701 | + | |
| 702 | + | |
| 703 | +/*-------------------------------------------------------------------------*/ | |
| 704 | + | |
| 705 | +/* USB_DT_SECURITY: group of wireless security descriptors, including | |
| 706 | + * encryption types available for setting up a CC/association. | |
| 707 | + */ | |
| 708 | +struct usb_security_descriptor { | |
| 709 | + __u8 bLength; | |
| 710 | + __u8 bDescriptorType; | |
| 711 | + | |
| 712 | + __le16 wTotalLength; | |
| 713 | + __u8 bNumEncryptionTypes; | |
| 714 | +} __attribute__((packed)); | |
| 715 | + | |
| 716 | +/*-------------------------------------------------------------------------*/ | |
| 717 | + | |
| 718 | +/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys | |
| 719 | + * may be retrieved. | |
| 720 | + */ | |
| 721 | +struct usb_key_descriptor { | |
| 722 | + __u8 bLength; | |
| 723 | + __u8 bDescriptorType; | |
| 724 | + | |
| 725 | + __u8 tTKID[3]; | |
| 726 | + __u8 bReserved; | |
| 727 | + __u8 bKeyData[0]; | |
| 728 | +} __attribute__((packed)); | |
| 729 | + | |
| 730 | +/*-------------------------------------------------------------------------*/ | |
| 731 | + | |
| 732 | +/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */ | |
| 733 | +struct usb_encryption_descriptor { | |
| 734 | + __u8 bLength; | |
| 735 | + __u8 bDescriptorType; | |
| 736 | + | |
| 737 | + __u8 bEncryptionType; | |
| 738 | +#define USB_ENC_TYPE_UNSECURE 0 | |
| 739 | +#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */ | |
| 740 | +#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */ | |
| 741 | +#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ | |
| 742 | + __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ | |
| 743 | + __u8 bAuthKeyIndex; | |
| 744 | +} __attribute__((packed)); | |
| 745 | + | |
| 746 | + | |
| 747 | +/*-------------------------------------------------------------------------*/ | |
| 748 | + | |
| 749 | +/* USB_DT_BOS: group of device-level capabilities */ | |
| 750 | +struct usb_bos_descriptor { | |
| 751 | + __u8 bLength; | |
| 752 | + __u8 bDescriptorType; | |
| 753 | + | |
| 754 | + __le16 wTotalLength; | |
| 755 | + __u8 bNumDeviceCaps; | |
| 756 | +} __attribute__((packed)); | |
| 757 | + | |
| 758 | +#define USB_DT_BOS_SIZE 5 | |
| 759 | +/*-------------------------------------------------------------------------*/ | |
| 760 | + | |
| 761 | +/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ | |
| 762 | +struct usb_dev_cap_header { | |
| 763 | + __u8 bLength; | |
| 764 | + __u8 bDescriptorType; | |
| 765 | + __u8 bDevCapabilityType; | |
| 766 | +} __attribute__((packed)); | |
| 767 | + | |
| 768 | +#define USB_CAP_TYPE_WIRELESS_USB 1 | |
| 769 | + | |
| 770 | +struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ | |
| 771 | + __u8 bLength; | |
| 772 | + __u8 bDescriptorType; | |
| 773 | + __u8 bDevCapabilityType; | |
| 774 | + | |
| 775 | + __u8 bmAttributes; | |
| 776 | +#define USB_WIRELESS_P2P_DRD (1 << 1) | |
| 777 | +#define USB_WIRELESS_BEACON_MASK (3 << 2) | |
| 778 | +#define USB_WIRELESS_BEACON_SELF (1 << 2) | |
| 779 | +#define USB_WIRELESS_BEACON_DIRECTED (2 << 2) | |
| 780 | +#define USB_WIRELESS_BEACON_NONE (3 << 2) | |
| 781 | + __le16 wPHYRates; /* bit rates, Mbps */ | |
| 782 | +#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */ | |
| 783 | +#define USB_WIRELESS_PHY_80 (1 << 1) | |
| 784 | +#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */ | |
| 785 | +#define USB_WIRELESS_PHY_160 (1 << 3) | |
| 786 | +#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */ | |
| 787 | +#define USB_WIRELESS_PHY_320 (1 << 5) | |
| 788 | +#define USB_WIRELESS_PHY_400 (1 << 6) | |
| 789 | +#define USB_WIRELESS_PHY_480 (1 << 7) | |
| 790 | + __u8 bmTFITXPowerInfo; /* TFI power levels */ | |
| 791 | + __u8 bmFFITXPowerInfo; /* FFI power levels */ | |
| 792 | + __le16 bmBandGroup; | |
| 793 | + __u8 bReserved; | |
| 794 | +} __attribute__((packed)); | |
| 795 | + | |
| 796 | +/* USB 2.0 Extension descriptor */ | |
| 797 | +#define USB_CAP_TYPE_EXT 2 | |
| 798 | + | |
| 799 | +struct usb_ext_cap_descriptor { /* Link Power Management */ | |
| 800 | + __u8 bLength; | |
| 801 | + __u8 bDescriptorType; | |
| 802 | + __u8 bDevCapabilityType; | |
| 803 | + __le32 bmAttributes; | |
| 804 | +#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ | |
| 805 | +#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ | |
| 806 | +#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ | |
| 807 | +#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ | |
| 808 | +#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) | |
| 809 | +#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) | |
| 810 | +} __attribute__((packed)); | |
| 811 | + | |
| 812 | +#define USB_DT_USB_EXT_CAP_SIZE 7 | |
| 813 | + | |
| 814 | +/* | |
| 815 | + * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB | |
| 816 | + * specific device level capabilities | |
| 817 | + */ | |
| 818 | +#define USB_SS_CAP_TYPE 3 | |
| 819 | +struct usb_ss_cap_descriptor { /* Link Power Management */ | |
| 820 | + __u8 bLength; | |
| 821 | + __u8 bDescriptorType; | |
| 822 | + __u8 bDevCapabilityType; | |
| 823 | + __u8 bmAttributes; | |
| 824 | +#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */ | |
| 825 | + __le16 wSpeedSupported; | |
| 826 | +#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */ | |
| 827 | +#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */ | |
| 828 | +#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */ | |
| 829 | +#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */ | |
| 830 | + __u8 bFunctionalitySupport; | |
| 831 | + __u8 bU1devExitLat; | |
| 832 | + __le16 bU2DevExitLat; | |
| 833 | +} __attribute__((packed)); | |
| 834 | + | |
| 835 | +#define USB_DT_USB_SS_CAP_SIZE 10 | |
| 836 | + | |
| 837 | +/* | |
| 838 | + * Container ID Capability descriptor: Defines the instance unique ID used to | |
| 839 | + * identify the instance across all operating modes | |
| 840 | + */ | |
| 841 | +#define CONTAINER_ID_TYPE 4 | |
| 842 | +struct usb_ss_container_id_descriptor { | |
| 843 | + __u8 bLength; | |
| 844 | + __u8 bDescriptorType; | |
| 845 | + __u8 bDevCapabilityType; | |
| 846 | + __u8 bReserved; | |
| 847 | + __u8 ContainerID[16]; /* 128-bit number */ | |
| 848 | +} __attribute__((packed)); | |
| 849 | + | |
| 850 | +#define USB_DT_USB_SS_CONTN_ID_SIZE 20 | |
| 851 | +/*-------------------------------------------------------------------------*/ | |
| 852 | + | |
| 853 | +/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with | |
| 854 | + * each endpoint descriptor for a wireless device | |
| 855 | + */ | |
| 856 | +struct usb_wireless_ep_comp_descriptor { | |
| 857 | + __u8 bLength; | |
| 858 | + __u8 bDescriptorType; | |
| 859 | + | |
| 860 | + __u8 bMaxBurst; | |
| 861 | + __u8 bMaxSequence; | |
| 862 | + __le16 wMaxStreamDelay; | |
| 863 | + __le16 wOverTheAirPacketSize; | |
| 864 | + __u8 bOverTheAirInterval; | |
| 865 | + __u8 bmCompAttributes; | |
| 866 | +#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */ | |
| 867 | +#define USB_ENDPOINT_SWITCH_NO 0 | |
| 868 | +#define USB_ENDPOINT_SWITCH_SWITCH 1 | |
| 869 | +#define USB_ENDPOINT_SWITCH_SCALE 2 | |
| 870 | +} __attribute__((packed)); | |
| 871 | + | |
| 872 | +/*-------------------------------------------------------------------------*/ | |
| 873 | + | |
| 874 | +/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless | |
| 875 | + * host and a device for connection set up, mutual authentication, and | |
| 876 | + * exchanging short lived session keys. The handshake depends on a CC. | |
| 877 | + */ | |
| 878 | +struct usb_handshake { | |
| 879 | + __u8 bMessageNumber; | |
| 880 | + __u8 bStatus; | |
| 881 | + __u8 tTKID[3]; | |
| 882 | + __u8 bReserved; | |
| 883 | + __u8 CDID[16]; | |
| 884 | + __u8 nonce[16]; | |
| 885 | + __u8 MIC[8]; | |
| 886 | +} __attribute__((packed)); | |
| 887 | + | |
| 888 | +/*-------------------------------------------------------------------------*/ | |
| 889 | + | |
| 890 | +/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC). | |
| 891 | + * A CC may also be set up using non-wireless secure channels (including | |
| 892 | + * wired USB!), and some devices may support CCs with multiple hosts. | |
| 893 | + */ | |
| 894 | +struct usb_connection_context { | |
| 895 | + __u8 CHID[16]; /* persistent host id */ | |
| 896 | + __u8 CDID[16]; /* device id (unique w/in host context) */ | |
| 897 | + __u8 CK[16]; /* connection key */ | |
| 898 | +} __attribute__((packed)); | |
| 899 | + | |
| 900 | +/*-------------------------------------------------------------------------*/ | |
| 901 | + | |
| 902 | +/* USB 2.0 defines three speeds, here's how Linux identifies them */ | |
| 903 | + | |
| 904 | +enum usb_device_speed { | |
| 905 | + USB_SPEED_UNKNOWN = 0, /* enumerating */ | |
| 906 | + USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | |
| 907 | + USB_SPEED_HIGH, /* usb 2.0 */ | |
| 908 | + USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ | |
| 909 | + USB_SPEED_SUPER, /* usb 3.0 */ | |
| 910 | +}; | |
| 911 | + | |
| 912 | + | |
| 913 | +enum usb_device_state { | |
| 914 | + /* NOTATTACHED isn't in the USB spec, and this state acts | |
| 915 | + * the same as ATTACHED ... but it's clearer this way. | |
| 916 | + */ | |
| 917 | + USB_STATE_NOTATTACHED = 0, | |
| 918 | + | |
| 919 | + /* chapter 9 and authentication (wireless) device states */ | |
| 920 | + USB_STATE_ATTACHED, | |
| 921 | + USB_STATE_POWERED, /* wired */ | |
| 922 | + USB_STATE_RECONNECTING, /* auth */ | |
| 923 | + USB_STATE_UNAUTHENTICATED, /* auth */ | |
| 924 | + USB_STATE_DEFAULT, /* limited function */ | |
| 925 | + USB_STATE_ADDRESS, | |
| 926 | + USB_STATE_CONFIGURED, /* most functions */ | |
| 927 | + | |
| 928 | + USB_STATE_SUSPENDED | |
| 929 | + | |
| 930 | + /* NOTE: there are actually four different SUSPENDED | |
| 931 | + * states, returning to POWERED, DEFAULT, ADDRESS, or | |
| 932 | + * CONFIGURED respectively when SOF tokens flow again. | |
| 933 | + * At this level there's no difference between L1 and L2 | |
| 934 | + * suspend states. (L2 being original USB 1.1 suspend.) | |
| 935 | + */ | |
| 936 | +}; | |
| 937 | + | |
| 938 | +enum usb3_link_state { | |
| 939 | + USB3_LPM_U0 = 0, | |
| 940 | + USB3_LPM_U1, | |
| 941 | + USB3_LPM_U2, | |
| 942 | + USB3_LPM_U3 | |
| 943 | +}; | |
| 944 | + | |
| 945 | +/* | |
| 946 | + * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1. | |
| 947 | + * 0xff means the parent hub will accept transitions to U1, but will not | |
| 948 | + * initiate a transition. | |
| 949 | + * | |
| 950 | + * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to | |
| 951 | + * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved | |
| 952 | + * values. | |
| 953 | + * | |
| 954 | + * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2. | |
| 955 | + * 0xff means the parent hub will accept transitions to U2, but will not | |
| 956 | + * initiate a transition. | |
| 957 | + * | |
| 958 | + * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to | |
| 959 | + * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2 | |
| 960 | + * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means | |
| 961 | + * 65.024ms. | |
| 962 | + */ | |
| 963 | +#define USB3_LPM_DISABLED 0x0 | |
| 964 | +#define USB3_LPM_U1_MAX_TIMEOUT 0x7F | |
| 965 | +#define USB3_LPM_U2_MAX_TIMEOUT 0xFE | |
| 966 | +#define USB3_LPM_DEVICE_INITIATED 0xFF | |
| 967 | + | |
| 968 | +struct usb_set_sel_req { | |
| 969 | + __u8 u1_sel; | |
| 970 | + __u8 u1_pel; | |
| 971 | + __le16 u2_sel; | |
| 972 | + __le16 u2_pel; | |
| 973 | +} __attribute__ ((packed)); | |
| 974 | + | |
| 975 | +/* | |
| 976 | + * The Set System Exit Latency control transfer provides one byte each for | |
| 977 | + * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each | |
| 978 | + * are two bytes long. | |
| 979 | + */ | |
| 980 | +#define USB3_LPM_MAX_U1_SEL_PEL 0xFF | |
| 981 | +#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF | |
| 982 | + | |
| 983 | +/*-------------------------------------------------------------------------*/ | |
| 984 | + | |
| 985 | +/* | |
| 986 | + * As per USB compliance update, a device that is actively drawing | |
| 987 | + * more than 100mA from USB must report itself as bus-powered in | |
| 988 | + * the GetStatus(DEVICE) call. | |
| 989 | + * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 | |
| 990 | + */ | |
| 991 | +#define USB_SELF_POWER_VBUS_MAX_DRAW 100 | |
| 992 | + | |
| 993 | +#endif /* _UAPI__LINUX_USB_CH9_H */ | |
| @@ -0,0 +1,169 @@ | ||
| 1 | +#ifndef _UAPI__LINUX_FUNCTIONFS_H__ | |
| 2 | +#define _UAPI__LINUX_FUNCTIONFS_H__ | |
| 3 | + | |
| 4 | + | |
| 5 | +#include <linux/types.h> | |
| 6 | +#include <linux/ioctl.h> | |
| 7 | + | |
| 8 | +#include <linux/usb/ch9.h> | |
| 9 | + | |
| 10 | + | |
| 11 | +enum { | |
| 12 | + FUNCTIONFS_DESCRIPTORS_MAGIC = 1, | |
| 13 | + FUNCTIONFS_STRINGS_MAGIC = 2 | |
| 14 | +}; | |
| 15 | + | |
| 16 | + | |
| 17 | +#ifndef __KERNEL__ | |
| 18 | + | |
| 19 | +/* Descriptor of an non-audio endpoint */ | |
| 20 | +struct usb_endpoint_descriptor_no_audio { | |
| 21 | + __u8 bLength; | |
| 22 | + __u8 bDescriptorType; | |
| 23 | + | |
| 24 | + __u8 bEndpointAddress; | |
| 25 | + __u8 bmAttributes; | |
| 26 | + __le16 wMaxPacketSize; | |
| 27 | + __u8 bInterval; | |
| 28 | +} __attribute__((packed)); | |
| 29 | + | |
| 30 | + | |
| 31 | +/* | |
| 32 | + * All numbers must be in little endian order. | |
| 33 | + */ | |
| 34 | + | |
| 35 | +struct usb_functionfs_descs_head { | |
| 36 | + __le32 magic; | |
| 37 | + __le32 length; | |
| 38 | + __le32 fs_count; | |
| 39 | + __le32 hs_count; | |
| 40 | +} __attribute__((packed)); | |
| 41 | + | |
| 42 | +/* | |
| 43 | + * Descriptors format: | |
| 44 | + * | |
| 45 | + * | off | name | type | description | | |
| 46 | + * |-----+-----------+--------------+--------------------------------------| | |
| 47 | + * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | | |
| 48 | + * | 4 | length | LE32 | length of the whole data chunk | | |
| 49 | + * | 8 | fs_count | LE32 | number of full-speed descriptors | | |
| 50 | + * | 12 | hs_count | LE32 | number of high-speed descriptors | | |
| 51 | + * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | | |
| 52 | + * | | hs_descrs | Descriptor[] | list of high-speed descriptors | | |
| 53 | + * | |
| 54 | + * descs are just valid USB descriptors and have the following format: | |
| 55 | + * | |
| 56 | + * | off | name | type | description | | |
| 57 | + * |-----+-----------------+------+--------------------------| | |
| 58 | + * | 0 | bLength | U8 | length of the descriptor | | |
| 59 | + * | 1 | bDescriptorType | U8 | descriptor type | | |
| 60 | + * | 2 | payload | | descriptor's payload | | |
| 61 | + */ | |
| 62 | + | |
| 63 | +struct usb_functionfs_strings_head { | |
| 64 | + __le32 magic; | |
| 65 | + __le32 length; | |
| 66 | + __le32 str_count; | |
| 67 | + __le32 lang_count; | |
| 68 | +} __attribute__((packed)); | |
| 69 | + | |
| 70 | +/* | |
| 71 | + * Strings format: | |
| 72 | + * | |
| 73 | + * | off | name | type | description | | |
| 74 | + * |-----+------------+-----------------------+----------------------------| | |
| 75 | + * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC | | |
| 76 | + * | 4 | length | LE32 | length of the data chunk | | |
| 77 | + * | 8 | str_count | LE32 | number of strings | | |
| 78 | + * | 12 | lang_count | LE32 | number of languages | | |
| 79 | + * | 16 | stringtab | StringTab[lang_count] | table of strings per lang | | |
| 80 | + * | |
| 81 | + * For each language there is one stringtab entry (ie. there are lang_count | |
| 82 | + * stringtab entires). Each StringTab has following format: | |
| 83 | + * | |
| 84 | + * | off | name | type | description | | |
| 85 | + * |-----+---------+-------------------+------------------------------------| | |
| 86 | + * | 0 | lang | LE16 | language code | | |
| 87 | + * | 2 | strings | String[str_count] | array of strings in given language | | |
| 88 | + * | |
| 89 | + * For each string there is one strings entry (ie. there are str_count | |
| 90 | + * string entries). Each String is a NUL terminated string encoded in | |
| 91 | + * UTF-8. | |
| 92 | + */ | |
| 93 | + | |
| 94 | +#endif | |
| 95 | + | |
| 96 | + | |
| 97 | +/* | |
| 98 | + * Events are delivered on the ep0 file descriptor, when the user mode driver | |
| 99 | + * reads from this file descriptor after writing the descriptors. Don't | |
| 100 | + * stop polling this descriptor. | |
| 101 | + */ | |
| 102 | + | |
| 103 | +enum usb_functionfs_event_type { | |
| 104 | + FUNCTIONFS_BIND, | |
| 105 | + FUNCTIONFS_UNBIND, | |
| 106 | + | |
| 107 | + FUNCTIONFS_ENABLE, | |
| 108 | + FUNCTIONFS_DISABLE, | |
| 109 | + | |
| 110 | + FUNCTIONFS_SETUP, | |
| 111 | + | |
| 112 | + FUNCTIONFS_SUSPEND, | |
| 113 | + FUNCTIONFS_RESUME | |
| 114 | +}; | |
| 115 | + | |
| 116 | +/* NOTE: this structure must stay the same size and layout on | |
| 117 | + * both 32-bit and 64-bit kernels. | |
| 118 | + */ | |
| 119 | +struct usb_functionfs_event { | |
| 120 | + union { | |
| 121 | + /* SETUP: packet; DATA phase i/o precedes next event | |
| 122 | + *(setup.bmRequestType & USB_DIR_IN) flags direction */ | |
| 123 | + struct usb_ctrlrequest setup; | |
| 124 | + } __attribute__((packed)) u; | |
| 125 | + | |
| 126 | + /* enum usb_functionfs_event_type */ | |
| 127 | + __u8 type; | |
| 128 | + __u8 _pad[3]; | |
| 129 | +} __attribute__((packed)); | |
| 130 | + | |
| 131 | + | |
| 132 | +/* Endpoint ioctls */ | |
| 133 | +/* The same as in gadgetfs */ | |
| 134 | + | |
| 135 | +/* IN transfers may be reported to the gadget driver as complete | |
| 136 | + * when the fifo is loaded, before the host reads the data; | |
| 137 | + * OUT transfers may be reported to the host's "client" driver as | |
| 138 | + * complete when they're sitting in the FIFO unread. | |
| 139 | + * THIS returns how many bytes are "unclaimed" in the endpoint fifo | |
| 140 | + * (needed for precise fault handling, when the hardware allows it) | |
| 141 | + */ | |
| 142 | +#define FUNCTIONFS_FIFO_STATUS _IO('g', 1) | |
| 143 | + | |
| 144 | +/* discards any unclaimed data in the fifo. */ | |
| 145 | +#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2) | |
| 146 | + | |
| 147 | +/* resets endpoint halt+toggle; used to implement set_interface. | |
| 148 | + * some hardware (like pxa2xx) can't support this. | |
| 149 | + */ | |
| 150 | +#define FUNCTIONFS_CLEAR_HALT _IO('g', 3) | |
| 151 | + | |
| 152 | +/* Specific for functionfs */ | |
| 153 | + | |
| 154 | +/* | |
| 155 | + * Returns reverse mapping of an interface. Called on EP0. If there | |
| 156 | + * is no such interface returns -EDOM. If function is not active | |
| 157 | + * returns -ENODEV. | |
| 158 | + */ | |
| 159 | +#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128) | |
| 160 | + | |
| 161 | +/* | |
| 162 | + * Returns real bEndpointAddress of an endpoint. If function is not | |
| 163 | + * active returns -ENODEV. | |
| 164 | + */ | |
| 165 | +#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | +#endif /* _UAPI__LINUX_FUNCTIONFS_H__ */ | |
| @@ -0,0 +1,35 @@ | ||
| 1 | +/* | |
| 2 | + * g_printer.h -- Header file for USB Printer gadget driver | |
| 3 | + * | |
| 4 | + * Copyright (C) 2007 Craig W. Nadler | |
| 5 | + * | |
| 6 | + * This program is free software; you can redistribute it and/or modify | |
| 7 | + * it under the terms of the GNU General Public License as published by | |
| 8 | + * the Free Software Foundation; either version 2 of the License, or | |
| 9 | + * (at your option) any later version. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU General Public License | |
| 17 | + * along with this program; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#ifndef __LINUX_USB_G_PRINTER_H | |
| 22 | +#define __LINUX_USB_G_PRINTER_H | |
| 23 | + | |
| 24 | +#define PRINTER_NOT_ERROR 0x08 | |
| 25 | +#define PRINTER_SELECTED 0x10 | |
| 26 | +#define PRINTER_PAPER_EMPTY 0x20 | |
| 27 | + | |
| 28 | +/* The 'g' code is also used by gadgetfs ioctl requests. | |
| 29 | + * Don't add any colliding codes to either driver, and keep | |
| 30 | + * them in unique ranges (size 0x20 for now). | |
| 31 | + */ | |
| 32 | +#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char) | |
| 33 | +#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char) | |
| 34 | + | |
| 35 | +#endif /* __LINUX_USB_G_PRINTER_H */ | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +/* | |
| 2 | + * Filesystem based user-mode API to USB Gadget controller hardware | |
| 3 | + * | |
| 4 | + * Other than ep0 operations, most things are done by read() and write() | |
| 5 | + * on endpoint files found in one directory. They are configured by | |
| 6 | + * writing descriptors, and then may be used for normal stream style | |
| 7 | + * i/o requests. When ep0 is configured, the device can enumerate; | |
| 8 | + * when it's closed, the device disconnects from usb. Operations on | |
| 9 | + * ep0 require ioctl() operations. | |
| 10 | + * | |
| 11 | + * Configuration and device descriptors get written to /dev/gadget/$CHIP, | |
| 12 | + * which may then be used to read usb_gadgetfs_event structs. The driver | |
| 13 | + * may activate endpoints as it handles SET_CONFIGURATION setup events, | |
| 14 | + * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT | |
| 15 | + * then performing data transfers by reading or writing. | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#ifndef __LINUX_USB_GADGETFS_H | |
| 19 | +#define __LINUX_USB_GADGETFS_H | |
| 20 | + | |
| 21 | +#include <linux/types.h> | |
| 22 | +#include <linux/ioctl.h> | |
| 23 | + | |
| 24 | +#include <linux/usb/ch9.h> | |
| 25 | + | |
| 26 | +/* | |
| 27 | + * Events are delivered on the ep0 file descriptor, when the user mode driver | |
| 28 | + * reads from this file descriptor after writing the descriptors. Don't | |
| 29 | + * stop polling this descriptor. | |
| 30 | + */ | |
| 31 | + | |
| 32 | +enum usb_gadgetfs_event_type { | |
| 33 | + GADGETFS_NOP = 0, | |
| 34 | + | |
| 35 | + GADGETFS_CONNECT, | |
| 36 | + GADGETFS_DISCONNECT, | |
| 37 | + GADGETFS_SETUP, | |
| 38 | + GADGETFS_SUSPEND, | |
| 39 | + /* and likely more ! */ | |
| 40 | +}; | |
| 41 | + | |
| 42 | +/* NOTE: this structure must stay the same size and layout on | |
| 43 | + * both 32-bit and 64-bit kernels. | |
| 44 | + */ | |
| 45 | +struct usb_gadgetfs_event { | |
| 46 | + union { | |
| 47 | + /* NOP, DISCONNECT, SUSPEND: nothing | |
| 48 | + * ... some hardware can't report disconnection | |
| 49 | + */ | |
| 50 | + | |
| 51 | + /* CONNECT: just the speed */ | |
| 52 | + enum usb_device_speed speed; | |
| 53 | + | |
| 54 | + /* SETUP: packet; DATA phase i/o precedes next event | |
| 55 | + *(setup.bmRequestType & USB_DIR_IN) flags direction | |
| 56 | + * ... includes SET_CONFIGURATION, SET_INTERFACE | |
| 57 | + */ | |
| 58 | + struct usb_ctrlrequest setup; | |
| 59 | + } u; | |
| 60 | + enum usb_gadgetfs_event_type type; | |
| 61 | +}; | |
| 62 | + | |
| 63 | + | |
| 64 | +/* The 'g' code is also used by printer gadget ioctl requests. | |
| 65 | + * Don't add any colliding codes to either driver, and keep | |
| 66 | + * them in unique ranges (size 0x20 for now). | |
| 67 | + */ | |
| 68 | + | |
| 69 | +/* endpoint ioctls */ | |
| 70 | + | |
| 71 | +/* IN transfers may be reported to the gadget driver as complete | |
| 72 | + * when the fifo is loaded, before the host reads the data; | |
| 73 | + * OUT transfers may be reported to the host's "client" driver as | |
| 74 | + * complete when they're sitting in the FIFO unread. | |
| 75 | + * THIS returns how many bytes are "unclaimed" in the endpoint fifo | |
| 76 | + * (needed for precise fault handling, when the hardware allows it) | |
| 77 | + */ | |
| 78 | +#define GADGETFS_FIFO_STATUS _IO('g', 1) | |
| 79 | + | |
| 80 | +/* discards any unclaimed data in the fifo. */ | |
| 81 | +#define GADGETFS_FIFO_FLUSH _IO('g', 2) | |
| 82 | + | |
| 83 | +/* resets endpoint halt+toggle; used to implement set_interface. | |
| 84 | + * some hardware (like pxa2xx) can't support this. | |
| 85 | + */ | |
| 86 | +#define GADGETFS_CLEAR_HALT _IO('g', 3) | |
| 87 | + | |
| 88 | +#endif /* __LINUX_USB_GADGETFS_H */ | |
| @@ -0,0 +1,112 @@ | ||
| 1 | +/* | |
| 2 | + * <linux/usb/midi.h> -- USB MIDI definitions. | |
| 3 | + * | |
| 4 | + * Copyright (C) 2006 Thumtronics Pty Ltd. | |
| 5 | + * Developed for Thumtronics by Grey Innovation | |
| 6 | + * Ben Williamson <ben.williamson@greyinnovation.com> | |
| 7 | + * | |
| 8 | + * This software is distributed under the terms of the GNU General Public | |
| 9 | + * License ("GPL") version 2, as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This file holds USB constants and structures defined | |
| 12 | + * by the USB Device Class Definition for MIDI Devices. | |
| 13 | + * Comments below reference relevant sections of that document: | |
| 14 | + * | |
| 15 | + * http://www.usb.org/developers/devclass_docs/midi10.pdf | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#ifndef __LINUX_USB_MIDI_H | |
| 19 | +#define __LINUX_USB_MIDI_H | |
| 20 | + | |
| 21 | +#include <linux/types.h> | |
| 22 | + | |
| 23 | +/* A.1 MS Class-Specific Interface Descriptor Subtypes */ | |
| 24 | +#define USB_MS_HEADER 0x01 | |
| 25 | +#define USB_MS_MIDI_IN_JACK 0x02 | |
| 26 | +#define USB_MS_MIDI_OUT_JACK 0x03 | |
| 27 | +#define USB_MS_ELEMENT 0x04 | |
| 28 | + | |
| 29 | +/* A.2 MS Class-Specific Endpoint Descriptor Subtypes */ | |
| 30 | +#define USB_MS_GENERAL 0x01 | |
| 31 | + | |
| 32 | +/* A.3 MS MIDI IN and OUT Jack Types */ | |
| 33 | +#define USB_MS_EMBEDDED 0x01 | |
| 34 | +#define USB_MS_EXTERNAL 0x02 | |
| 35 | + | |
| 36 | +/* 6.1.2.1 Class-Specific MS Interface Header Descriptor */ | |
| 37 | +struct usb_ms_header_descriptor { | |
| 38 | + __u8 bLength; | |
| 39 | + __u8 bDescriptorType; | |
| 40 | + __u8 bDescriptorSubtype; | |
| 41 | + __le16 bcdMSC; | |
| 42 | + __le16 wTotalLength; | |
| 43 | +} __attribute__ ((packed)); | |
| 44 | + | |
| 45 | +#define USB_DT_MS_HEADER_SIZE 7 | |
| 46 | + | |
| 47 | +/* 6.1.2.2 MIDI IN Jack Descriptor */ | |
| 48 | +struct usb_midi_in_jack_descriptor { | |
| 49 | + __u8 bLength; | |
| 50 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 51 | + __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */ | |
| 52 | + __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ | |
| 53 | + __u8 bJackID; | |
| 54 | + __u8 iJack; | |
| 55 | +} __attribute__ ((packed)); | |
| 56 | + | |
| 57 | +#define USB_DT_MIDI_IN_SIZE 6 | |
| 58 | + | |
| 59 | +struct usb_midi_source_pin { | |
| 60 | + __u8 baSourceID; | |
| 61 | + __u8 baSourcePin; | |
| 62 | +} __attribute__ ((packed)); | |
| 63 | + | |
| 64 | +/* 6.1.2.3 MIDI OUT Jack Descriptor */ | |
| 65 | +struct usb_midi_out_jack_descriptor { | |
| 66 | + __u8 bLength; | |
| 67 | + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | |
| 68 | + __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */ | |
| 69 | + __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ | |
| 70 | + __u8 bJackID; | |
| 71 | + __u8 bNrInputPins; /* p */ | |
| 72 | + struct usb_midi_source_pin pins[]; /* [p] */ | |
| 73 | + /*__u8 iJack; -- omitted due to variable-sized pins[] */ | |
| 74 | +} __attribute__ ((packed)); | |
| 75 | + | |
| 76 | +#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p)) | |
| 77 | + | |
| 78 | +/* As above, but more useful for defining your own descriptors: */ | |
| 79 | +#define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \ | |
| 80 | +struct usb_midi_out_jack_descriptor_##p { \ | |
| 81 | + __u8 bLength; \ | |
| 82 | + __u8 bDescriptorType; \ | |
| 83 | + __u8 bDescriptorSubtype; \ | |
| 84 | + __u8 bJackType; \ | |
| 85 | + __u8 bJackID; \ | |
| 86 | + __u8 bNrInputPins; \ | |
| 87 | + struct usb_midi_source_pin pins[p]; \ | |
| 88 | + __u8 iJack; \ | |
| 89 | +} __attribute__ ((packed)) | |
| 90 | + | |
| 91 | +/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */ | |
| 92 | +struct usb_ms_endpoint_descriptor { | |
| 93 | + __u8 bLength; /* 4+n */ | |
| 94 | + __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ | |
| 95 | + __u8 bDescriptorSubtype; /* USB_MS_GENERAL */ | |
| 96 | + __u8 bNumEmbMIDIJack; /* n */ | |
| 97 | + __u8 baAssocJackID[]; /* [n] */ | |
| 98 | +} __attribute__ ((packed)); | |
| 99 | + | |
| 100 | +#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n)) | |
| 101 | + | |
| 102 | +/* As above, but more useful for defining your own descriptors: */ | |
| 103 | +#define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \ | |
| 104 | +struct usb_ms_endpoint_descriptor_##n { \ | |
| 105 | + __u8 bLength; \ | |
| 106 | + __u8 bDescriptorType; \ | |
| 107 | + __u8 bDescriptorSubtype; \ | |
| 108 | + __u8 bNumEmbMIDIJack; \ | |
| 109 | + __u8 baAssocJackID[n]; \ | |
| 110 | +} __attribute__ ((packed)) | |
| 111 | + | |
| 112 | +#endif /* __LINUX_USB_MIDI_H */ | |
| @@ -0,0 +1,43 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany | |
| 3 | + * Copyright (C) 2008 Novell, Inc. | |
| 4 | + * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> | |
| 5 | + * | |
| 6 | + * This file holds USB constants defined by the USB Device Class | |
| 7 | + * Definition for Test and Measurement devices published by the USB-IF. | |
| 8 | + * | |
| 9 | + * It also has the ioctl definitions for the usbtmc kernel driver that | |
| 10 | + * userspace needs to know about. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +#ifndef __LINUX_USB_TMC_H | |
| 14 | +#define __LINUX_USB_TMC_H | |
| 15 | + | |
| 16 | +/* USB TMC status values */ | |
| 17 | +#define USBTMC_STATUS_SUCCESS 0x01 | |
| 18 | +#define USBTMC_STATUS_PENDING 0x02 | |
| 19 | +#define USBTMC_STATUS_FAILED 0x80 | |
| 20 | +#define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 | |
| 21 | +#define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82 | |
| 22 | +#define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83 | |
| 23 | + | |
| 24 | +/* USB TMC requests values */ | |
| 25 | +#define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1 | |
| 26 | +#define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2 | |
| 27 | +#define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3 | |
| 28 | +#define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4 | |
| 29 | +#define USBTMC_REQUEST_INITIATE_CLEAR 5 | |
| 30 | +#define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6 | |
| 31 | +#define USBTMC_REQUEST_GET_CAPABILITIES 7 | |
| 32 | +#define USBTMC_REQUEST_INDICATOR_PULSE 64 | |
| 33 | + | |
| 34 | +/* Request values for USBTMC driver's ioctl entry point */ | |
| 35 | +#define USBTMC_IOC_NR 91 | |
| 36 | +#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1) | |
| 37 | +#define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2) | |
| 38 | +#define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3) | |
| 39 | +#define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4) | |
| 40 | +#define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6) | |
| 41 | +#define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7) | |
| 42 | + | |
| 43 | +#endif | |
| @@ -0,0 +1,568 @@ | ||
| 1 | +/* | |
| 2 | + * USB Video Class definitions. | |
| 3 | + * | |
| 4 | + * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be> | |
| 5 | + * | |
| 6 | + * This file holds USB constants and structures defined by the USB Device | |
| 7 | + * Class Definition for Video Devices. Unless otherwise stated, comments | |
| 8 | + * below reference relevant sections of the USB Video Class 1.1 specification | |
| 9 | + * available at | |
| 10 | + * | |
| 11 | + * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip | |
| 12 | + */ | |
| 13 | + | |
| 14 | +#ifndef __LINUX_USB_VIDEO_H | |
| 15 | +#define __LINUX_USB_VIDEO_H | |
| 16 | + | |
| 17 | +#include <linux/types.h> | |
| 18 | + | |
| 19 | +/* -------------------------------------------------------------------------- | |
| 20 | + * UVC constants | |
| 21 | + */ | |
| 22 | + | |
| 23 | +/* A.2. Video Interface Subclass Codes */ | |
| 24 | +#define UVC_SC_UNDEFINED 0x00 | |
| 25 | +#define UVC_SC_VIDEOCONTROL 0x01 | |
| 26 | +#define UVC_SC_VIDEOSTREAMING 0x02 | |
| 27 | +#define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03 | |
| 28 | + | |
| 29 | +/* A.3. Video Interface Protocol Codes */ | |
| 30 | +#define UVC_PC_PROTOCOL_UNDEFINED 0x00 | |
| 31 | + | |
| 32 | +/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */ | |
| 33 | +#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00 | |
| 34 | +#define UVC_VC_HEADER 0x01 | |
| 35 | +#define UVC_VC_INPUT_TERMINAL 0x02 | |
| 36 | +#define UVC_VC_OUTPUT_TERMINAL 0x03 | |
| 37 | +#define UVC_VC_SELECTOR_UNIT 0x04 | |
| 38 | +#define UVC_VC_PROCESSING_UNIT 0x05 | |
| 39 | +#define UVC_VC_EXTENSION_UNIT 0x06 | |
| 40 | + | |
| 41 | +/* A.6. Video Class-Specific VS Interface Descriptor Subtypes */ | |
| 42 | +#define UVC_VS_UNDEFINED 0x00 | |
| 43 | +#define UVC_VS_INPUT_HEADER 0x01 | |
| 44 | +#define UVC_VS_OUTPUT_HEADER 0x02 | |
| 45 | +#define UVC_VS_STILL_IMAGE_FRAME 0x03 | |
| 46 | +#define UVC_VS_FORMAT_UNCOMPRESSED 0x04 | |
| 47 | +#define UVC_VS_FRAME_UNCOMPRESSED 0x05 | |
| 48 | +#define UVC_VS_FORMAT_MJPEG 0x06 | |
| 49 | +#define UVC_VS_FRAME_MJPEG 0x07 | |
| 50 | +#define UVC_VS_FORMAT_MPEG2TS 0x0a | |
| 51 | +#define UVC_VS_FORMAT_DV 0x0c | |
| 52 | +#define UVC_VS_COLORFORMAT 0x0d | |
| 53 | +#define UVC_VS_FORMAT_FRAME_BASED 0x10 | |
| 54 | +#define UVC_VS_FRAME_FRAME_BASED 0x11 | |
| 55 | +#define UVC_VS_FORMAT_STREAM_BASED 0x12 | |
| 56 | + | |
| 57 | +/* A.7. Video Class-Specific Endpoint Descriptor Subtypes */ | |
| 58 | +#define UVC_EP_UNDEFINED 0x00 | |
| 59 | +#define UVC_EP_GENERAL 0x01 | |
| 60 | +#define UVC_EP_ENDPOINT 0x02 | |
| 61 | +#define UVC_EP_INTERRUPT 0x03 | |
| 62 | + | |
| 63 | +/* A.8. Video Class-Specific Request Codes */ | |
| 64 | +#define UVC_RC_UNDEFINED 0x00 | |
| 65 | +#define UVC_SET_CUR 0x01 | |
| 66 | +#define UVC_GET_CUR 0x81 | |
| 67 | +#define UVC_GET_MIN 0x82 | |
| 68 | +#define UVC_GET_MAX 0x83 | |
| 69 | +#define UVC_GET_RES 0x84 | |
| 70 | +#define UVC_GET_LEN 0x85 | |
| 71 | +#define UVC_GET_INFO 0x86 | |
| 72 | +#define UVC_GET_DEF 0x87 | |
| 73 | + | |
| 74 | +/* A.9.1. VideoControl Interface Control Selectors */ | |
| 75 | +#define UVC_VC_CONTROL_UNDEFINED 0x00 | |
| 76 | +#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01 | |
| 77 | +#define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02 | |
| 78 | + | |
| 79 | +/* A.9.2. Terminal Control Selectors */ | |
| 80 | +#define UVC_TE_CONTROL_UNDEFINED 0x00 | |
| 81 | + | |
| 82 | +/* A.9.3. Selector Unit Control Selectors */ | |
| 83 | +#define UVC_SU_CONTROL_UNDEFINED 0x00 | |
| 84 | +#define UVC_SU_INPUT_SELECT_CONTROL 0x01 | |
| 85 | + | |
| 86 | +/* A.9.4. Camera Terminal Control Selectors */ | |
| 87 | +#define UVC_CT_CONTROL_UNDEFINED 0x00 | |
| 88 | +#define UVC_CT_SCANNING_MODE_CONTROL 0x01 | |
| 89 | +#define UVC_CT_AE_MODE_CONTROL 0x02 | |
| 90 | +#define UVC_CT_AE_PRIORITY_CONTROL 0x03 | |
| 91 | +#define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 | |
| 92 | +#define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 | |
| 93 | +#define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06 | |
| 94 | +#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07 | |
| 95 | +#define UVC_CT_FOCUS_AUTO_CONTROL 0x08 | |
| 96 | +#define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09 | |
| 97 | +#define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a | |
| 98 | +#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b | |
| 99 | +#define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c | |
| 100 | +#define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d | |
| 101 | +#define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e | |
| 102 | +#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f | |
| 103 | +#define UVC_CT_ROLL_RELATIVE_CONTROL 0x10 | |
| 104 | +#define UVC_CT_PRIVACY_CONTROL 0x11 | |
| 105 | + | |
| 106 | +/* A.9.5. Processing Unit Control Selectors */ | |
| 107 | +#define UVC_PU_CONTROL_UNDEFINED 0x00 | |
| 108 | +#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 | |
| 109 | +#define UVC_PU_BRIGHTNESS_CONTROL 0x02 | |
| 110 | +#define UVC_PU_CONTRAST_CONTROL 0x03 | |
| 111 | +#define UVC_PU_GAIN_CONTROL 0x04 | |
| 112 | +#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05 | |
| 113 | +#define UVC_PU_HUE_CONTROL 0x06 | |
| 114 | +#define UVC_PU_SATURATION_CONTROL 0x07 | |
| 115 | +#define UVC_PU_SHARPNESS_CONTROL 0x08 | |
| 116 | +#define UVC_PU_GAMMA_CONTROL 0x09 | |
| 117 | +#define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a | |
| 118 | +#define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b | |
| 119 | +#define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c | |
| 120 | +#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d | |
| 121 | +#define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e | |
| 122 | +#define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f | |
| 123 | +#define UVC_PU_HUE_AUTO_CONTROL 0x10 | |
| 124 | +#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 | |
| 125 | +#define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12 | |
| 126 | + | |
| 127 | +/* A.9.7. VideoStreaming Interface Control Selectors */ | |
| 128 | +#define UVC_VS_CONTROL_UNDEFINED 0x00 | |
| 129 | +#define UVC_VS_PROBE_CONTROL 0x01 | |
| 130 | +#define UVC_VS_COMMIT_CONTROL 0x02 | |
| 131 | +#define UVC_VS_STILL_PROBE_CONTROL 0x03 | |
| 132 | +#define UVC_VS_STILL_COMMIT_CONTROL 0x04 | |
| 133 | +#define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 | |
| 134 | +#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06 | |
| 135 | +#define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07 | |
| 136 | +#define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 | |
| 137 | +#define UVC_VS_SYNC_DELAY_CONTROL 0x09 | |
| 138 | + | |
| 139 | +/* B.1. USB Terminal Types */ | |
| 140 | +#define UVC_TT_VENDOR_SPECIFIC 0x0100 | |
| 141 | +#define UVC_TT_STREAMING 0x0101 | |
| 142 | + | |
| 143 | +/* B.2. Input Terminal Types */ | |
| 144 | +#define UVC_ITT_VENDOR_SPECIFIC 0x0200 | |
| 145 | +#define UVC_ITT_CAMERA 0x0201 | |
| 146 | +#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202 | |
| 147 | + | |
| 148 | +/* B.3. Output Terminal Types */ | |
| 149 | +#define UVC_OTT_VENDOR_SPECIFIC 0x0300 | |
| 150 | +#define UVC_OTT_DISPLAY 0x0301 | |
| 151 | +#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 | |
| 152 | + | |
| 153 | +/* B.4. External Terminal Types */ | |
| 154 | +#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400 | |
| 155 | +#define UVC_COMPOSITE_CONNECTOR 0x0401 | |
| 156 | +#define UVC_SVIDEO_CONNECTOR 0x0402 | |
| 157 | +#define UVC_COMPONENT_CONNECTOR 0x0403 | |
| 158 | + | |
| 159 | +/* 2.4.2.2. Status Packet Type */ | |
| 160 | +#define UVC_STATUS_TYPE_CONTROL 1 | |
| 161 | +#define UVC_STATUS_TYPE_STREAMING 2 | |
| 162 | + | |
| 163 | +/* 2.4.3.3. Payload Header Information */ | |
| 164 | +#define UVC_STREAM_EOH (1 << 7) | |
| 165 | +#define UVC_STREAM_ERR (1 << 6) | |
| 166 | +#define UVC_STREAM_STI (1 << 5) | |
| 167 | +#define UVC_STREAM_RES (1 << 4) | |
| 168 | +#define UVC_STREAM_SCR (1 << 3) | |
| 169 | +#define UVC_STREAM_PTS (1 << 2) | |
| 170 | +#define UVC_STREAM_EOF (1 << 1) | |
| 171 | +#define UVC_STREAM_FID (1 << 0) | |
| 172 | + | |
| 173 | +/* 4.1.2. Control Capabilities */ | |
| 174 | +#define UVC_CONTROL_CAP_GET (1 << 0) | |
| 175 | +#define UVC_CONTROL_CAP_SET (1 << 1) | |
| 176 | +#define UVC_CONTROL_CAP_DISABLED (1 << 2) | |
| 177 | +#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3) | |
| 178 | +#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4) | |
| 179 | + | |
| 180 | +/* ------------------------------------------------------------------------ | |
| 181 | + * UVC structures | |
| 182 | + */ | |
| 183 | + | |
| 184 | +/* All UVC descriptors have these 3 fields at the beginning */ | |
| 185 | +struct uvc_descriptor_header { | |
| 186 | + __u8 bLength; | |
| 187 | + __u8 bDescriptorType; | |
| 188 | + __u8 bDescriptorSubType; | |
| 189 | +} __attribute__((packed)); | |
| 190 | + | |
| 191 | +/* 3.7.2. Video Control Interface Header Descriptor */ | |
| 192 | +struct uvc_header_descriptor { | |
| 193 | + __u8 bLength; | |
| 194 | + __u8 bDescriptorType; | |
| 195 | + __u8 bDescriptorSubType; | |
| 196 | + __u16 bcdUVC; | |
| 197 | + __u16 wTotalLength; | |
| 198 | + __u32 dwClockFrequency; | |
| 199 | + __u8 bInCollection; | |
| 200 | + __u8 baInterfaceNr[]; | |
| 201 | +} __attribute__((__packed__)); | |
| 202 | + | |
| 203 | +#define UVC_DT_HEADER_SIZE(n) (12+(n)) | |
| 204 | + | |
| 205 | +#define UVC_HEADER_DESCRIPTOR(n) \ | |
| 206 | + uvc_header_descriptor_##n | |
| 207 | + | |
| 208 | +#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \ | |
| 209 | +struct UVC_HEADER_DESCRIPTOR(n) { \ | |
| 210 | + __u8 bLength; \ | |
| 211 | + __u8 bDescriptorType; \ | |
| 212 | + __u8 bDescriptorSubType; \ | |
| 213 | + __u16 bcdUVC; \ | |
| 214 | + __u16 wTotalLength; \ | |
| 215 | + __u32 dwClockFrequency; \ | |
| 216 | + __u8 bInCollection; \ | |
| 217 | + __u8 baInterfaceNr[n]; \ | |
| 218 | +} __attribute__ ((packed)) | |
| 219 | + | |
| 220 | +/* 3.7.2.1. Input Terminal Descriptor */ | |
| 221 | +struct uvc_input_terminal_descriptor { | |
| 222 | + __u8 bLength; | |
| 223 | + __u8 bDescriptorType; | |
| 224 | + __u8 bDescriptorSubType; | |
| 225 | + __u8 bTerminalID; | |
| 226 | + __u16 wTerminalType; | |
| 227 | + __u8 bAssocTerminal; | |
| 228 | + __u8 iTerminal; | |
| 229 | +} __attribute__((__packed__)); | |
| 230 | + | |
| 231 | +#define UVC_DT_INPUT_TERMINAL_SIZE 8 | |
| 232 | + | |
| 233 | +/* 3.7.2.2. Output Terminal Descriptor */ | |
| 234 | +struct uvc_output_terminal_descriptor { | |
| 235 | + __u8 bLength; | |
| 236 | + __u8 bDescriptorType; | |
| 237 | + __u8 bDescriptorSubType; | |
| 238 | + __u8 bTerminalID; | |
| 239 | + __u16 wTerminalType; | |
| 240 | + __u8 bAssocTerminal; | |
| 241 | + __u8 bSourceID; | |
| 242 | + __u8 iTerminal; | |
| 243 | +} __attribute__((__packed__)); | |
| 244 | + | |
| 245 | +#define UVC_DT_OUTPUT_TERMINAL_SIZE 9 | |
| 246 | + | |
| 247 | +/* 3.7.2.3. Camera Terminal Descriptor */ | |
| 248 | +struct uvc_camera_terminal_descriptor { | |
| 249 | + __u8 bLength; | |
| 250 | + __u8 bDescriptorType; | |
| 251 | + __u8 bDescriptorSubType; | |
| 252 | + __u8 bTerminalID; | |
| 253 | + __u16 wTerminalType; | |
| 254 | + __u8 bAssocTerminal; | |
| 255 | + __u8 iTerminal; | |
| 256 | + __u16 wObjectiveFocalLengthMin; | |
| 257 | + __u16 wObjectiveFocalLengthMax; | |
| 258 | + __u16 wOcularFocalLength; | |
| 259 | + __u8 bControlSize; | |
| 260 | + __u8 bmControls[3]; | |
| 261 | +} __attribute__((__packed__)); | |
| 262 | + | |
| 263 | +#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n)) | |
| 264 | + | |
| 265 | +/* 3.7.2.4. Selector Unit Descriptor */ | |
| 266 | +struct uvc_selector_unit_descriptor { | |
| 267 | + __u8 bLength; | |
| 268 | + __u8 bDescriptorType; | |
| 269 | + __u8 bDescriptorSubType; | |
| 270 | + __u8 bUnitID; | |
| 271 | + __u8 bNrInPins; | |
| 272 | + __u8 baSourceID[0]; | |
| 273 | + __u8 iSelector; | |
| 274 | +} __attribute__((__packed__)); | |
| 275 | + | |
| 276 | +#define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n)) | |
| 277 | + | |
| 278 | +#define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | |
| 279 | + uvc_selector_unit_descriptor_##n | |
| 280 | + | |
| 281 | +#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \ | |
| 282 | +struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \ | |
| 283 | + __u8 bLength; \ | |
| 284 | + __u8 bDescriptorType; \ | |
| 285 | + __u8 bDescriptorSubType; \ | |
| 286 | + __u8 bUnitID; \ | |
| 287 | + __u8 bNrInPins; \ | |
| 288 | + __u8 baSourceID[n]; \ | |
| 289 | + __u8 iSelector; \ | |
| 290 | +} __attribute__ ((packed)) | |
| 291 | + | |
| 292 | +/* 3.7.2.5. Processing Unit Descriptor */ | |
| 293 | +struct uvc_processing_unit_descriptor { | |
| 294 | + __u8 bLength; | |
| 295 | + __u8 bDescriptorType; | |
| 296 | + __u8 bDescriptorSubType; | |
| 297 | + __u8 bUnitID; | |
| 298 | + __u8 bSourceID; | |
| 299 | + __u16 wMaxMultiplier; | |
| 300 | + __u8 bControlSize; | |
| 301 | + __u8 bmControls[2]; | |
| 302 | + __u8 iProcessing; | |
| 303 | +} __attribute__((__packed__)); | |
| 304 | + | |
| 305 | +#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n)) | |
| 306 | + | |
| 307 | +/* 3.7.2.6. Extension Unit Descriptor */ | |
| 308 | +struct uvc_extension_unit_descriptor { | |
| 309 | + __u8 bLength; | |
| 310 | + __u8 bDescriptorType; | |
| 311 | + __u8 bDescriptorSubType; | |
| 312 | + __u8 bUnitID; | |
| 313 | + __u8 guidExtensionCode[16]; | |
| 314 | + __u8 bNumControls; | |
| 315 | + __u8 bNrInPins; | |
| 316 | + __u8 baSourceID[0]; | |
| 317 | + __u8 bControlSize; | |
| 318 | + __u8 bmControls[0]; | |
| 319 | + __u8 iExtension; | |
| 320 | +} __attribute__((__packed__)); | |
| 321 | + | |
| 322 | +#define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n)) | |
| 323 | + | |
| 324 | +#define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | |
| 325 | + uvc_extension_unit_descriptor_##p_##n | |
| 326 | + | |
| 327 | +#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \ | |
| 328 | +struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \ | |
| 329 | + __u8 bLength; \ | |
| 330 | + __u8 bDescriptorType; \ | |
| 331 | + __u8 bDescriptorSubType; \ | |
| 332 | + __u8 bUnitID; \ | |
| 333 | + __u8 guidExtensionCode[16]; \ | |
| 334 | + __u8 bNumControls; \ | |
| 335 | + __u8 bNrInPins; \ | |
| 336 | + __u8 baSourceID[p]; \ | |
| 337 | + __u8 bControlSize; \ | |
| 338 | + __u8 bmControls[n]; \ | |
| 339 | + __u8 iExtension; \ | |
| 340 | +} __attribute__ ((packed)) | |
| 341 | + | |
| 342 | +/* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */ | |
| 343 | +struct uvc_control_endpoint_descriptor { | |
| 344 | + __u8 bLength; | |
| 345 | + __u8 bDescriptorType; | |
| 346 | + __u8 bDescriptorSubType; | |
| 347 | + __u16 wMaxTransferSize; | |
| 348 | +} __attribute__((__packed__)); | |
| 349 | + | |
| 350 | +#define UVC_DT_CONTROL_ENDPOINT_SIZE 5 | |
| 351 | + | |
| 352 | +/* 3.9.2.1. Input Header Descriptor */ | |
| 353 | +struct uvc_input_header_descriptor { | |
| 354 | + __u8 bLength; | |
| 355 | + __u8 bDescriptorType; | |
| 356 | + __u8 bDescriptorSubType; | |
| 357 | + __u8 bNumFormats; | |
| 358 | + __u16 wTotalLength; | |
| 359 | + __u8 bEndpointAddress; | |
| 360 | + __u8 bmInfo; | |
| 361 | + __u8 bTerminalLink; | |
| 362 | + __u8 bStillCaptureMethod; | |
| 363 | + __u8 bTriggerSupport; | |
| 364 | + __u8 bTriggerUsage; | |
| 365 | + __u8 bControlSize; | |
| 366 | + __u8 bmaControls[]; | |
| 367 | +} __attribute__((__packed__)); | |
| 368 | + | |
| 369 | +#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p)) | |
| 370 | + | |
| 371 | +#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | |
| 372 | + uvc_input_header_descriptor_##n_##p | |
| 373 | + | |
| 374 | +#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \ | |
| 375 | +struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \ | |
| 376 | + __u8 bLength; \ | |
| 377 | + __u8 bDescriptorType; \ | |
| 378 | + __u8 bDescriptorSubType; \ | |
| 379 | + __u8 bNumFormats; \ | |
| 380 | + __u16 wTotalLength; \ | |
| 381 | + __u8 bEndpointAddress; \ | |
| 382 | + __u8 bmInfo; \ | |
| 383 | + __u8 bTerminalLink; \ | |
| 384 | + __u8 bStillCaptureMethod; \ | |
| 385 | + __u8 bTriggerSupport; \ | |
| 386 | + __u8 bTriggerUsage; \ | |
| 387 | + __u8 bControlSize; \ | |
| 388 | + __u8 bmaControls[p][n]; \ | |
| 389 | +} __attribute__ ((packed)) | |
| 390 | + | |
| 391 | +/* 3.9.2.2. Output Header Descriptor */ | |
| 392 | +struct uvc_output_header_descriptor { | |
| 393 | + __u8 bLength; | |
| 394 | + __u8 bDescriptorType; | |
| 395 | + __u8 bDescriptorSubType; | |
| 396 | + __u8 bNumFormats; | |
| 397 | + __u16 wTotalLength; | |
| 398 | + __u8 bEndpointAddress; | |
| 399 | + __u8 bTerminalLink; | |
| 400 | + __u8 bControlSize; | |
| 401 | + __u8 bmaControls[]; | |
| 402 | +} __attribute__((__packed__)); | |
| 403 | + | |
| 404 | +#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p)) | |
| 405 | + | |
| 406 | +#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | |
| 407 | + uvc_output_header_descriptor_##n_##p | |
| 408 | + | |
| 409 | +#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \ | |
| 410 | +struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \ | |
| 411 | + __u8 bLength; \ | |
| 412 | + __u8 bDescriptorType; \ | |
| 413 | + __u8 bDescriptorSubType; \ | |
| 414 | + __u8 bNumFormats; \ | |
| 415 | + __u16 wTotalLength; \ | |
| 416 | + __u8 bEndpointAddress; \ | |
| 417 | + __u8 bTerminalLink; \ | |
| 418 | + __u8 bControlSize; \ | |
| 419 | + __u8 bmaControls[p][n]; \ | |
| 420 | +} __attribute__ ((packed)) | |
| 421 | + | |
| 422 | +/* 3.9.2.6. Color matching descriptor */ | |
| 423 | +struct uvc_color_matching_descriptor { | |
| 424 | + __u8 bLength; | |
| 425 | + __u8 bDescriptorType; | |
| 426 | + __u8 bDescriptorSubType; | |
| 427 | + __u8 bColorPrimaries; | |
| 428 | + __u8 bTransferCharacteristics; | |
| 429 | + __u8 bMatrixCoefficients; | |
| 430 | +} __attribute__((__packed__)); | |
| 431 | + | |
| 432 | +#define UVC_DT_COLOR_MATCHING_SIZE 6 | |
| 433 | + | |
| 434 | +/* 4.3.1.1. Video Probe and Commit Controls */ | |
| 435 | +struct uvc_streaming_control { | |
| 436 | + __u16 bmHint; | |
| 437 | + __u8 bFormatIndex; | |
| 438 | + __u8 bFrameIndex; | |
| 439 | + __u32 dwFrameInterval; | |
| 440 | + __u16 wKeyFrameRate; | |
| 441 | + __u16 wPFrameRate; | |
| 442 | + __u16 wCompQuality; | |
| 443 | + __u16 wCompWindowSize; | |
| 444 | + __u16 wDelay; | |
| 445 | + __u32 dwMaxVideoFrameSize; | |
| 446 | + __u32 dwMaxPayloadTransferSize; | |
| 447 | + __u32 dwClockFrequency; | |
| 448 | + __u8 bmFramingInfo; | |
| 449 | + __u8 bPreferedVersion; | |
| 450 | + __u8 bMinVersion; | |
| 451 | + __u8 bMaxVersion; | |
| 452 | +} __attribute__((__packed__)); | |
| 453 | + | |
| 454 | +/* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */ | |
| 455 | +struct uvc_format_uncompressed { | |
| 456 | + __u8 bLength; | |
| 457 | + __u8 bDescriptorType; | |
| 458 | + __u8 bDescriptorSubType; | |
| 459 | + __u8 bFormatIndex; | |
| 460 | + __u8 bNumFrameDescriptors; | |
| 461 | + __u8 guidFormat[16]; | |
| 462 | + __u8 bBitsPerPixel; | |
| 463 | + __u8 bDefaultFrameIndex; | |
| 464 | + __u8 bAspectRatioX; | |
| 465 | + __u8 bAspectRatioY; | |
| 466 | + __u8 bmInterfaceFlags; | |
| 467 | + __u8 bCopyProtect; | |
| 468 | +} __attribute__((__packed__)); | |
| 469 | + | |
| 470 | +#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27 | |
| 471 | + | |
| 472 | +/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */ | |
| 473 | +struct uvc_frame_uncompressed { | |
| 474 | + __u8 bLength; | |
| 475 | + __u8 bDescriptorType; | |
| 476 | + __u8 bDescriptorSubType; | |
| 477 | + __u8 bFrameIndex; | |
| 478 | + __u8 bmCapabilities; | |
| 479 | + __u16 wWidth; | |
| 480 | + __u16 wHeight; | |
| 481 | + __u32 dwMinBitRate; | |
| 482 | + __u32 dwMaxBitRate; | |
| 483 | + __u32 dwMaxVideoFrameBufferSize; | |
| 484 | + __u32 dwDefaultFrameInterval; | |
| 485 | + __u8 bFrameIntervalType; | |
| 486 | + __u32 dwFrameInterval[]; | |
| 487 | +} __attribute__((__packed__)); | |
| 488 | + | |
| 489 | +#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n)) | |
| 490 | + | |
| 491 | +#define UVC_FRAME_UNCOMPRESSED(n) \ | |
| 492 | + uvc_frame_uncompressed_##n | |
| 493 | + | |
| 494 | +#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \ | |
| 495 | +struct UVC_FRAME_UNCOMPRESSED(n) { \ | |
| 496 | + __u8 bLength; \ | |
| 497 | + __u8 bDescriptorType; \ | |
| 498 | + __u8 bDescriptorSubType; \ | |
| 499 | + __u8 bFrameIndex; \ | |
| 500 | + __u8 bmCapabilities; \ | |
| 501 | + __u16 wWidth; \ | |
| 502 | + __u16 wHeight; \ | |
| 503 | + __u32 dwMinBitRate; \ | |
| 504 | + __u32 dwMaxBitRate; \ | |
| 505 | + __u32 dwMaxVideoFrameBufferSize; \ | |
| 506 | + __u32 dwDefaultFrameInterval; \ | |
| 507 | + __u8 bFrameIntervalType; \ | |
| 508 | + __u32 dwFrameInterval[n]; \ | |
| 509 | +} __attribute__ ((packed)) | |
| 510 | + | |
| 511 | +/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */ | |
| 512 | +struct uvc_format_mjpeg { | |
| 513 | + __u8 bLength; | |
| 514 | + __u8 bDescriptorType; | |
| 515 | + __u8 bDescriptorSubType; | |
| 516 | + __u8 bFormatIndex; | |
| 517 | + __u8 bNumFrameDescriptors; | |
| 518 | + __u8 bmFlags; | |
| 519 | + __u8 bDefaultFrameIndex; | |
| 520 | + __u8 bAspectRatioX; | |
| 521 | + __u8 bAspectRatioY; | |
| 522 | + __u8 bmInterfaceFlags; | |
| 523 | + __u8 bCopyProtect; | |
| 524 | +} __attribute__((__packed__)); | |
| 525 | + | |
| 526 | +#define UVC_DT_FORMAT_MJPEG_SIZE 11 | |
| 527 | + | |
| 528 | +/* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */ | |
| 529 | +struct uvc_frame_mjpeg { | |
| 530 | + __u8 bLength; | |
| 531 | + __u8 bDescriptorType; | |
| 532 | + __u8 bDescriptorSubType; | |
| 533 | + __u8 bFrameIndex; | |
| 534 | + __u8 bmCapabilities; | |
| 535 | + __u16 wWidth; | |
| 536 | + __u16 wHeight; | |
| 537 | + __u32 dwMinBitRate; | |
| 538 | + __u32 dwMaxBitRate; | |
| 539 | + __u32 dwMaxVideoFrameBufferSize; | |
| 540 | + __u32 dwDefaultFrameInterval; | |
| 541 | + __u8 bFrameIntervalType; | |
| 542 | + __u32 dwFrameInterval[]; | |
| 543 | +} __attribute__((__packed__)); | |
| 544 | + | |
| 545 | +#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n)) | |
| 546 | + | |
| 547 | +#define UVC_FRAME_MJPEG(n) \ | |
| 548 | + uvc_frame_mjpeg_##n | |
| 549 | + | |
| 550 | +#define DECLARE_UVC_FRAME_MJPEG(n) \ | |
| 551 | +struct UVC_FRAME_MJPEG(n) { \ | |
| 552 | + __u8 bLength; \ | |
| 553 | + __u8 bDescriptorType; \ | |
| 554 | + __u8 bDescriptorSubType; \ | |
| 555 | + __u8 bFrameIndex; \ | |
| 556 | + __u8 bmCapabilities; \ | |
| 557 | + __u16 wWidth; \ | |
| 558 | + __u16 wHeight; \ | |
| 559 | + __u32 dwMinBitRate; \ | |
| 560 | + __u32 dwMaxBitRate; \ | |
| 561 | + __u32 dwMaxVideoFrameBufferSize; \ | |
| 562 | + __u32 dwDefaultFrameInterval; \ | |
| 563 | + __u8 bFrameIntervalType; \ | |
| 564 | + __u32 dwFrameInterval[n]; \ | |
| 565 | +} __attribute__ ((packed)) | |
| 566 | + | |
| 567 | +#endif /* __LINUX_USB_VIDEO_H */ | |
| 568 | + | |