mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-06 13:15:25 -05:00
Original commit credit to Amaury Pouly, Moshe Piekarski Pushed across the finish line by Dana Conrad To enable, see setting under General Settings --> System --> USB-DAC. On devices with few endpoints, this may not work while HID and/or mass storage is enabled. Adds new dedicated mixer channel. setting usb-dac can have values: - never (0) - always (1) - while_charge_only (2) - while_mass_storage (3) Relevant devices are DWC2 and ARC usb controller devices. That being: x1000 Native targets (m3k, erosqnative, q1, others...?), sansac200, creativezenxfi2, vibe500, ipodmini2g, ipod4g, creativezenxfi, creativezenxfi3, sansaview, ipodcolor, creativezenxfistyle, samsungypz5, sansafuzeplus, iriverh10_5gb, tatungtpj1022, gigabeats, faketarget, samsungyh820, gogearhdd1630, samsungyh925, ipodmini1g, ipodvideo, creativezenmozaic, sonynwze370, creativezen, gogearsa9200, gogearhdd6330, sonynwze360, sansae200, mrobe100, iriverh10, creativezenv, ipodnano1g, samsungyh920 USB Driver-wise, it should be noted that this patch requires some slight changes: - proper blocking on control OUT transfers, to make sure the data is received *before* using it, the usb_core should probably use that too - drivers can now support interface alternate settings - drivers can be notified of completion by a new fast handler, which is called directly from the driver; this is is necessary for isochronous transfers because going through the usb queue is way too slow Designware changes: - enable for USBOTG_DESIGNWARE - set maxpacketsize to 1023 for ISO endpoints Change-Id: I570871884a4e4820b4312b203b07701f06ecacc6
223 lines
5.5 KiB
C
223 lines
5.5 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id: $
|
|
*
|
|
* Copyright (C) 2014 by Amaury Pouly
|
|
*
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#ifndef USB_AUDIO_H
|
|
#define USB_AUDIO_H
|
|
|
|
#include "usb_ch9.h"
|
|
|
|
/*
|
|
* usb_audio_request_endpoints():
|
|
*
|
|
* Calls usb_core_request_endpoint() to request one IN and one OUT
|
|
* isochronous endpoint.
|
|
*
|
|
* Called by allocate_interfaces_and_endpoints().
|
|
*
|
|
* Returns -1 if either request fails, returns 0 if success.
|
|
*
|
|
* Also requests buffer allocations. If allocation fails,
|
|
* returns -1 so that the driver will be disabled by the USB core.
|
|
*/
|
|
int usb_audio_request_endpoints(struct usb_class_driver *);
|
|
|
|
/*
|
|
* usb_audio_set_first_interface():
|
|
*
|
|
* Required function for the class driver.
|
|
*
|
|
* Called by allocate_interfaces_and_endpoints() to
|
|
* tell the class driver what its first interface number is.
|
|
* Returns the number of the interface available for the next
|
|
* class driver to use.
|
|
*
|
|
* We need 2 interfaces, AudioControl and AudioStreaming.
|
|
* Return interface+2.
|
|
*/
|
|
int usb_audio_set_first_interface(int interface);
|
|
|
|
/*
|
|
* usb_audio_get_config_descriptor():
|
|
*
|
|
* Required function for the class driver.
|
|
*
|
|
* Called by request_handler_device_get_descriptor(), which expects
|
|
* this function to fill *dest with the configuration descriptor for this
|
|
* class driver.
|
|
*
|
|
* Return the size of this descriptor in bytes.
|
|
*/
|
|
int usb_audio_get_config_descriptor(unsigned char *dest,int max_packet_size);
|
|
|
|
/*
|
|
* usb_audio_init_connection():
|
|
*
|
|
* Called by usb_core_do_set_config() when the
|
|
* connection is ready to be used. Currently just sets
|
|
* the audio sample rate to default.
|
|
*/
|
|
void usb_audio_init_connection(void);
|
|
|
|
/*
|
|
* usb_audio_init():
|
|
*
|
|
* Initialize the driver. Called by usb_core_init().
|
|
* Currently initializes the sampling frequency values available
|
|
* to the AudioStreaming interface.
|
|
*/
|
|
void usb_audio_init(void);
|
|
|
|
/*
|
|
* usb_audio_disconnect():
|
|
*
|
|
* Called by usb_core_exit() AND usb_core_do_set_config().
|
|
*
|
|
* Indicates to the Class driver that the connection is no
|
|
* longer active. Currently just calls usb_audio_stop_playback().
|
|
*/
|
|
void usb_audio_disconnect(void);
|
|
|
|
/*
|
|
* usb_audio_get_playing():
|
|
*
|
|
* Returns playing/not playing status of usbaudio.
|
|
*/
|
|
bool usb_audio_get_playing(void);
|
|
|
|
/*
|
|
* usb_audio_get_alloc_failed():
|
|
*
|
|
* Return whether the buffer allocation succeeded (0)
|
|
* or failed (1).
|
|
*/
|
|
bool usb_audio_get_alloc_failed(void);
|
|
|
|
/*
|
|
* usb_audio_transfer_complete():
|
|
*
|
|
* Dummy function.
|
|
*
|
|
* The fast_transfer_complete() function needs to be used instead.
|
|
*/
|
|
void usb_audio_transfer_complete(int ep,int dir, int status, int length);
|
|
|
|
/*
|
|
* usb_audio_fast_transfer_complete():
|
|
*
|
|
* Called by usb_core_transfer_complete().
|
|
* The normal transfer complete handler system is too slow to deal with
|
|
* ISO data at the rate required, so this is required.
|
|
*
|
|
* Return true if the transfer is handled, false otherwise.
|
|
*/
|
|
bool usb_audio_fast_transfer_complete(int ep,int dir, int status, int length);
|
|
|
|
/*
|
|
* usb_audio_control_request():
|
|
*
|
|
* Called by control_request_handler_drivers().
|
|
* Pass control requests down to the appropriate functions.
|
|
*
|
|
* Return true if this driver handles the request, false otherwise.
|
|
*/
|
|
bool usb_audio_control_request(struct usb_ctrlrequest* req, void* reqdata, unsigned char* dest);
|
|
|
|
/*
|
|
* usb_audio_set_interface():
|
|
*
|
|
* Called by control_request_handler_drivers().
|
|
* Deal with changing the interface between control and streaming.
|
|
*
|
|
* Return 0 for success, -1 otherwise.
|
|
*/
|
|
int usb_audio_set_interface(int intf, int alt);
|
|
|
|
/*
|
|
* usb_audio_get_interface():
|
|
*
|
|
* Called by control_request_handler_drivers().
|
|
* Get the alternate of the given interface.
|
|
*
|
|
* Return the alternate of the given interface, -1 if unknown.
|
|
*/
|
|
int usb_audio_get_interface(int intf);
|
|
|
|
/*
|
|
* usb_audio_get_playback_sampling_frequency():
|
|
*
|
|
* Return the sample rate currently set.
|
|
*/
|
|
unsigned long usb_audio_get_playback_sampling_frequency(void);
|
|
|
|
/*
|
|
* usb_audio_get_main_intf():
|
|
*
|
|
* Return the main usb interface
|
|
*/
|
|
int usb_audio_get_main_intf(void);
|
|
|
|
/*
|
|
* usb_audio_get_alt_intf():
|
|
*
|
|
* Return the alternate usb interface
|
|
*/
|
|
int usb_audio_get_alt_intf(void);
|
|
|
|
/*
|
|
* usb_audio_get_out_ep():
|
|
*
|
|
* Return the out (to device) endpoint
|
|
*/
|
|
unsigned int usb_audio_get_out_ep(void);
|
|
|
|
/*
|
|
* usb_audio_get_in_ep():
|
|
*
|
|
* Return the in (to host) endpoint
|
|
*/
|
|
unsigned int usb_audio_get_in_ep(void);
|
|
|
|
/*
|
|
* usb_audio_get_prebuffering():
|
|
*
|
|
* Return number of buffers filled ahead of playback
|
|
*/
|
|
int usb_audio_get_prebuffering(void);
|
|
|
|
/*
|
|
* usb_audio_get_underflow():
|
|
*
|
|
* Return whether playback is in "underflow" state
|
|
*/
|
|
bool usb_audio_get_underflow(void);
|
|
|
|
/*
|
|
* usb_audio_get_overflow():
|
|
*
|
|
* Return whether usb is in "overflow" state
|
|
*/
|
|
bool usb_audio_get_overflow(void);
|
|
|
|
/*
|
|
* usb_audio_get_cur_volume():
|
|
*
|
|
* Return current audio volume in db
|
|
*/
|
|
int usb_audio_get_cur_volume(void);
|
|
|
|
#endif
|