1d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* 2d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 3d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 4d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * Copyright (C) 2005 Mike Isely <isely@pobox.com> 5d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 6d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * This program is free software; you can redistribute it and/or modify 7d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * it under the terms of the GNU General Public License as published by 8d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * the Free Software Foundation; either version 2 of the License 9d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 10d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * This program is distributed in the hope that it will be useful, 11d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * but WITHOUT ANY WARRANTY; without even the implied warranty of 12d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * GNU General Public License for more details. 14d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 15d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * You should have received a copy of the GNU General Public License 16d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * along with this program; if not, write to the Free Software 17d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely * 19d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely */ 20d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#ifndef __PVRUSB2_HDW_H 21d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define __PVRUSB2_HDW_H 22d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 23d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#include <linux/usb.h> 24d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#include <linux/videodev2.h> 25d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#include "pvrusb2-io.h" 26d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#include "pvrusb2-ctrl.h" 27d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 28d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 29d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Private internal control ids, look these up with 30d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely pvr2_hdw_get_ctrl_by_id() - these are NOT visible in V4L */ 31d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_STDENUM 1 32d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_STDCUR 2 33d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_STDAVAIL 3 34d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_INPUT 4 35d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_AUDIOMODE 5 36d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_FREQUENCY 6 37d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_HRES 7 38d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CID_VRES 8 39e784bfb93c155ba4b354452c69ac02a29d336d97vdb#define PVR2_CID_CROPL 9 40e784bfb93c155ba4b354452c69ac02a29d336d97vdb#define PVR2_CID_CROPT 10 41e784bfb93c155ba4b354452c69ac02a29d336d97vdb#define PVR2_CID_CROPW 11 42e784bfb93c155ba4b354452c69ac02a29d336d97vdb#define PVR2_CID_CROPH 12 43432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPPAN 13 44432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPPAD 14 45432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPBL 15 46432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPBT 16 47432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPBW 17 48432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely#define PVR2_CID_CROPCAPBH 18 49d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 50d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Legal values for the INPUT state variable */ 51d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#define PVR2_CVAL_INPUT_TV 0 5229bf5b1d754a9a64f68c37938e1a0b7b63b724baMike Isely#define PVR2_CVAL_INPUT_DTV 1 53dbc40a0e582a88d2561d13d1fea4f3496bff9650Mike Isely#define PVR2_CVAL_INPUT_COMPOSITE 2 54dbc40a0e582a88d2561d13d1fea4f3496bff9650Mike Isely#define PVR2_CVAL_INPUT_SVIDEO 3 5529bf5b1d754a9a64f68c37938e1a0b7b63b724baMike Isely#define PVR2_CVAL_INPUT_RADIO 4 56d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 57d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyenum pvr2_config { 5816eb40d37d5dd4dba85245899388d2d44eb0bc2aMike Isely pvr2_config_empty, /* No configuration */ 5916eb40d37d5dd4dba85245899388d2d44eb0bc2aMike Isely pvr2_config_mpeg, /* Encoded / compressed video */ 6016eb40d37d5dd4dba85245899388d2d44eb0bc2aMike Isely pvr2_config_vbi, /* Standard vbi info */ 6116eb40d37d5dd4dba85245899388d2d44eb0bc2aMike Isely pvr2_config_pcm, /* Audio raw pcm stream */ 6216eb40d37d5dd4dba85245899388d2d44eb0bc2aMike Isely pvr2_config_rawvideo, /* Video raw frames */ 63d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely}; 64d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 658079384eeb1c490d0ad679cef061205e1b5a1c8aMike Iselyenum pvr2_v4l_type { 668079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely pvr2_v4l_type_video, 678079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely pvr2_v4l_type_vbi, 688079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely pvr2_v4l_type_radio, 698079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely}; 708079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely 71681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Major states that we can be in: 72681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 73681c739944018d80dbcf7f19997eba97676c7116Mike Isely * DEAD - Device is in an unusable state and cannot be recovered. This 74681c739944018d80dbcf7f19997eba97676c7116Mike Isely * can happen if we completely lose the ability to communicate with it 75681c739944018d80dbcf7f19997eba97676c7116Mike Isely * (but it might still on the bus). In this state there's nothing we can 76681c739944018d80dbcf7f19997eba97676c7116Mike Isely * do; it must be replugged in order to recover. 77681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 7825985edcedea6396277003854657b5f3cb31a628Lucas De Marchi * COLD - Device is in an unusable state, needs microcontroller firmware. 79681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 80681c739944018d80dbcf7f19997eba97676c7116Mike Isely * WARM - We can communicate with the device and the proper 81681c739944018d80dbcf7f19997eba97676c7116Mike Isely * microcontroller firmware is running, but other device initialization is 82681c739944018d80dbcf7f19997eba97676c7116Mike Isely * still needed (e.g. encoder firmware). 83681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 84681c739944018d80dbcf7f19997eba97676c7116Mike Isely * ERROR - A problem prevents capture operation (e.g. encoder firmware 85681c739944018d80dbcf7f19997eba97676c7116Mike Isely * missing). 86681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 87681c739944018d80dbcf7f19997eba97676c7116Mike Isely * READY - Device is operational, but not streaming. 88681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 89681c739944018d80dbcf7f19997eba97676c7116Mike Isely * RUN - Device is streaming. 90681c739944018d80dbcf7f19997eba97676c7116Mike Isely * 91681c739944018d80dbcf7f19997eba97676c7116Mike Isely */ 92681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_NONE 0 93681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_DEAD 1 94681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_COLD 2 95681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_WARM 3 96681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_ERROR 4 97681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_READY 5 98681c739944018d80dbcf7f19997eba97676c7116Mike Isely#define PVR2_STATE_RUN 6 99681c739944018d80dbcf7f19997eba97676c7116Mike Isely 100681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Translate configuration enum to a string label */ 101d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyconst char *pvr2_config_get_name(enum pvr2_config); 102d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 103d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_hdw; 104d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 105d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Create and return a structure for interacting with the underlying 106d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely hardware */ 107d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, 108d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely const struct usb_device_id *devid); 109d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 110c4a8828ddbf5fb445d2679ab006d5743540fc41aMike Isely/* Perform second stage initialization, passing in a notification callback 111c4a8828ddbf5fb445d2679ab006d5743540fc41aMike Isely for when the master state changes. */ 112794b16072e00d0a40a8c773dd4319fb1e460a632Mike Iselyint pvr2_hdw_initialize(struct pvr2_hdw *, 113794b16072e00d0a40a8c773dd4319fb1e460a632Mike Isely void (*callback_func)(void *), 114794b16072e00d0a40a8c773dd4319fb1e460a632Mike Isely void *callback_data); 115c4a8828ddbf5fb445d2679ab006d5743540fc41aMike Isely 116d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Destroy hardware interaction structure */ 117d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_destroy(struct pvr2_hdw *); 118d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 119d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Return true if in the ready (normal) state */ 120d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_dev_ok(struct pvr2_hdw *); 121d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 122d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Return small integer number [1..N] for logical instance number of this 123d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely device. This is useful for indexing array-valued module parameters. */ 124d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_get_unit_number(struct pvr2_hdw *); 125d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 126d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Get pointer to underlying USB device */ 127d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *); 128d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 129d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Retrieve serial number of device */ 130d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyunsigned long pvr2_hdw_get_sn(struct pvr2_hdw *); 131d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 13231a1854706707dc3b67eb0d3bf0f51c67d91c82eMike Isely/* Retrieve bus location info of device */ 13331a1854706707dc3b67eb0d3bf0f51c67d91c82eMike Iselyconst char *pvr2_hdw_get_bus_info(struct pvr2_hdw *); 13431a1854706707dc3b67eb0d3bf0f51c67d91c82eMike Isely 13513a887971b6c97751fce62ab803ee93a42a23c5dMike Isely/* Retrieve per-instance string identifier for this specific device */ 13613a887971b6c97751fce62ab803ee93a42a23c5dMike Iselyconst char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *); 13713a887971b6c97751fce62ab803ee93a42a23c5dMike Isely 138d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Called when hardware has been unplugged */ 139d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_disconnect(struct pvr2_hdw *); 140d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 141d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Get the number of defined controls */ 142d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyunsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *); 143d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 144d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Retrieve a control handle given its index (0..count-1) */ 145d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *,unsigned int); 146d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 147d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Retrieve a control handle given its internal ID (if any) */ 148d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *,unsigned int); 149d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 150d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Retrieve a control handle given its V4L ID (if any) */ 151d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *,unsigned int ctl_id); 152d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 153a761f4311b3e31008c7d168c3a8c254a9c7e35acMike Isely/* Retrieve a control handle given its immediate predecessor V4L ID (if any) */ 154a761f4311b3e31008c7d168c3a8c254a9c7e35acMike Iselystruct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *, 155a761f4311b3e31008c7d168c3a8c254a9c7e35acMike Isely unsigned int ctl_id); 156a761f4311b3e31008c7d168c3a8c254a9c7e35acMike Isely 157d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Commit all control changes made up to this point */ 158d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_commit_ctl(struct pvr2_hdw *); 159d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 1607fb20fa38caaf5c9d1b1d60b181c99ca30122520Mike Isely/* Return a bit mask of valid input selections for this device. Mask bits 1617fb20fa38caaf5c9d1b1d60b181c99ca30122520Mike Isely * will be according to PVR_CVAL_INPUT_xxxx definitions. */ 1627fb20fa38caaf5c9d1b1d60b181c99ca30122520Mike Iselyunsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *); 1637fb20fa38caaf5c9d1b1d60b181c99ca30122520Mike Isely 1641cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely/* Return a bit mask of allowed input selections for this device. Mask bits 1651cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely * will be according to PVR_CVAL_INPUT_xxxx definitions. */ 1661cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Iselyunsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *); 1671cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely 1681cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely/* Change the set of allowed input selections for this device. Both 1691cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely change_mask and change_valu are mask bits according to 1701cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely PVR_CVAL_INPUT_xxxx definitions. The change_mask parameter indicate 1711cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely which settings are being changed and the change_val parameter indicates 1721cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely whether corresponding settings are being set or cleared. */ 1731cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Iselyint pvr2_hdw_set_input_allowed(struct pvr2_hdw *, 1741cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely unsigned int change_mask, 1751cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely unsigned int change_val); 1761cb03b76d09d20accfa5c1664c16ba6566f539a0Mike Isely 177d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Return name for this driver instance */ 178d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyconst char *pvr2_hdw_get_driver_name(struct pvr2_hdw *); 179d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 18018103c57b0168ebc0401702d483fe131f0aecc7aMike Isely/* Mark tuner status stale so that it will be re-fetched */ 18118103c57b0168ebc0401702d483fe131f0aecc7aMike Iselyvoid pvr2_hdw_execute_tuner_poll(struct pvr2_hdw *); 18218103c57b0168ebc0401702d483fe131f0aecc7aMike Isely 18318103c57b0168ebc0401702d483fe131f0aecc7aMike Isely/* Return information about the tuner */ 18418103c57b0168ebc0401702d483fe131f0aecc7aMike Iselyint pvr2_hdw_get_tuner_status(struct pvr2_hdw *,struct v4l2_tuner *); 185d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 186432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely/* Return information about cropping capabilities */ 187432907f750b27aa2b41e1bf398e6eb711ead448fMike Iselyint pvr2_hdw_get_cropcap(struct pvr2_hdw *, struct v4l2_cropcap *); 188432907f750b27aa2b41e1bf398e6eb711ead448fMike Isely 189d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Query device and see if it thinks it is on a high-speed USB link */ 190d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_is_hsm(struct pvr2_hdw *); 191d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 19278a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Isely/* Return a string token representative of the hardware type */ 19378a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Iselyconst char *pvr2_hdw_get_type(struct pvr2_hdw *); 19478a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Isely 19578a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Isely/* Return a single line description of the hardware type */ 19678a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Iselyconst char *pvr2_hdw_get_desc(struct pvr2_hdw *); 19778a47101ac0ac75019a740d62c70ccb16ff7c7c1Mike Isely 198d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Turn streaming on/off */ 199d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_set_streaming(struct pvr2_hdw *,int); 200d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 201d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Find out if streaming is on */ 202d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_get_streaming(struct pvr2_hdw *); 203d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 204681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Retrieve driver overall state */ 205681c739944018d80dbcf7f19997eba97676c7116Mike Iselyint pvr2_hdw_get_state(struct pvr2_hdw *); 206681c739944018d80dbcf7f19997eba97676c7116Mike Isely 207d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Configure the type of stream to generate */ 208d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_set_stream_type(struct pvr2_hdw *, enum pvr2_config); 209d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 210d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Get handle to video output stream */ 211d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *); 212d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 213d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Emit a video standard struct */ 214d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std, 215d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely unsigned int idx); 216d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 2177383a47395fd5c5ae564b754ca14f6ae25dedecdMauro Carvalho Chehab/* Get the detected video standard */ 2187383a47395fd5c5ae564b754ca14f6ae25dedecdMauro Carvalho Chehabint pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw, v4l2_std_id *std); 2197383a47395fd5c5ae564b754ca14f6ae25dedecdMauro Carvalho Chehab 2204db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Isely/* Enable / disable retrieval of CPU firmware or prom contents. This must 2214db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Isely be enabled before pvr2_hdw_cpufw_get() will function. Note that doing 2224db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Isely this may prevent the device from running (and leaving this mode may 2234db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Isely imply a device reset). */ 2244db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Iselyvoid pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *, 225568efaa2f704f72eef9b70ac0f895e9b961f15a6Mike Isely int mode, /* 0=8KB FX2, 1=16KB FX2, 2=PROM */ 2264db666cc3d199a8b837174bb0ad00d6b8f6115d6Mike Isely int enable_flag); 227d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 228d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Return true if we're in a mode for retrieval CPU firmware */ 229d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *); 230d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 231d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Retrieve a piece of the CPU's firmware at the given offset. Return 232d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely value is the number of bytes retrieved or zero if we're past the end or 233d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely an error otherwise (e.g. if firmware retrieval is not enabled). */ 234d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs, 235d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely char *buf,unsigned int cnt); 236d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 2372fdf3d9c94f7f752dacbebb75bbecda3c1b082a0Pantelis Koukousoulas/* Retrieve a previously stored v4l minor device number */ 2388079384eeb1c490d0ad679cef061205e1b5a1c8aMike Iselyint pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,enum pvr2_v4l_type index); 239d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 2402fdf3d9c94f7f752dacbebb75bbecda3c1b082a0Pantelis Koukousoulas/* Store a v4l minor device number */ 241fd5a75fe00ec13311289928c2cb17d8676f8db45Mike Iselyvoid pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *, 2428079384eeb1c490d0ad679cef061205e1b5a1c8aMike Isely enum pvr2_v4l_type index,int); 243d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 24432ffa9ae03c529df4208b63b4b17c6d84141faa3Mike Isely/* Direct read/write access to chip's registers: 245be4f4aecf8df39444535c9d9be2b74a8f34649b2Mike Isely match - specify criteria to identify target chip (this is a v4l dbg struct) 24632ffa9ae03c529df4208b63b4b17c6d84141faa3Mike Isely reg_id - register number to access 24732ffa9ae03c529df4208b63b4b17c6d84141faa3Mike Isely setFl - true to set the register, false to read it 24832ffa9ae03c529df4208b63b4b17c6d84141faa3Mike Isely val_ptr - storage location for source / result. */ 24932ffa9ae03c529df4208b63b4b17c6d84141faa3Mike Iselyint pvr2_hdw_register_access(struct pvr2_hdw *, 250aecde8b53b8ee1330a5a8206200f0d6b8845a6e0Hans Verkuil struct v4l2_dbg_match *match, u64 reg_id, 251aecde8b53b8ee1330a5a8206200f0d6b8845a6e0Hans Verkuil int setFl, u64 *val_ptr); 252d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 253d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* The following entry points are all lower level things you normally don't 254d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely want to worry about. */ 255d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 256d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Issue a command and get a response from the device. LOTS of higher 257d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely level stuff is built on this. */ 258d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_send_request(struct pvr2_hdw *, 259d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely void *write_ptr,unsigned int write_len, 260d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely void *read_ptr,unsigned int read_len); 261d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 262d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Slightly higher level device communication functions. */ 263d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_write_register(struct pvr2_hdw *, u16, u32); 264d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 265d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Call if for any reason we can't talk to the hardware anymore - this will 266d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely cause the driver to stop flailing on the device. */ 267d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_render_useless(struct pvr2_hdw *); 268d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 269d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Set / clear 8051's reset bit */ 270d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int); 271d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 272d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Execute a USB-commanded device reset */ 273d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_device_reset(struct pvr2_hdw *); 274d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 275681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Reset worker's error trapping circuit breaker */ 276681c739944018d80dbcf7f19997eba97676c7116Mike Iselyint pvr2_hdw_untrip(struct pvr2_hdw *); 277681c739944018d80dbcf7f19997eba97676c7116Mike Isely 278d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Execute hard reset command (after this point it's likely that the 279d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely encoder will have to be reconfigured). This also clears the "useless" 280d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely state. */ 281d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *); 282d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 283d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Execute simple reset command */ 284d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_cmd_powerup(struct pvr2_hdw *); 285d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 286e1edb19a001b25c0ce2e52a669cba6b6eb31883cMichael Krufky/* suspend */ 287e1edb19a001b25c0ce2e52a669cba6b6eb31883cMichael Krufkyint pvr2_hdw_cmd_powerdown(struct pvr2_hdw *); 288e1edb19a001b25c0ce2e52a669cba6b6eb31883cMichael Krufky 289d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Order decoder to reset */ 290d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); 291d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 292d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Direct manipulation of GPIO bits */ 293d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *); 294d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *); 295d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *); 296d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val); 297d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val); 298d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 299d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* This data structure is specifically for the next function... */ 300d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselystruct pvr2_hdw_debug_info { 301d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int big_lock_held; 302d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int ctl_lock_held; 303d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int flag_disconnected; 304d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int flag_init_ok; 305681c739944018d80dbcf7f19997eba97676c7116Mike Isely int flag_ok; 306681c739944018d80dbcf7f19997eba97676c7116Mike Isely int fw1_state; 307681c739944018d80dbcf7f19997eba97676c7116Mike Isely int flag_decoder_missed; 308681c739944018d80dbcf7f19997eba97676c7116Mike Isely int flag_tripped; 309681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_encoder_ok; 310681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_encoder_run; 311681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_decoder_run; 3126e9313755aacdb9fd4eec58cbd9653212e2e2cdcMike Isely int state_decoder_ready; 313681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_usbstream_run; 314681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_decoder_quiescent; 315681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_pipeline_config; 316681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_pipeline_req; 317681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_pipeline_pause; 318681c739944018d80dbcf7f19997eba97676c7116Mike Isely int state_pipeline_idle; 319d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_state; 320d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_write_len; 321d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_read_len; 322d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_write_pend; 323d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_read_pend; 324d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_timeout; 325d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_rstatus; 326d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely int cmd_debug_wstatus; 327d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely unsigned char cmd_code; 328d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely}; 329d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 330d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Non-intrusively retrieve internal state info - this is useful for 331d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely diagnosing lockups. Note that this operation is completed without any 332d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely kind of locking and so it is not atomic and may yield inconsistent 333d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely results. This is *purely* a debugging aid. */ 334681c739944018d80dbcf7f19997eba97676c7116Mike Iselyvoid pvr2_hdw_get_debug_info_unlocked(const struct pvr2_hdw *hdw, 335681c739944018d80dbcf7f19997eba97676c7116Mike Isely struct pvr2_hdw_debug_info *); 336681c739944018d80dbcf7f19997eba97676c7116Mike Isely 337681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Intrusively retrieve internal state info - this is useful for 338681c739944018d80dbcf7f19997eba97676c7116Mike Isely diagnosing overall driver state. This operation synchronizes against 339681c739944018d80dbcf7f19997eba97676c7116Mike Isely the overall driver mutex - so if there are locking problems this will 340681c739944018d80dbcf7f19997eba97676c7116Mike Isely likely hang! This is *purely* a debugging aid. */ 341681c739944018d80dbcf7f19997eba97676c7116Mike Iselyvoid pvr2_hdw_get_debug_info_locked(struct pvr2_hdw *hdw, 342681c739944018d80dbcf7f19997eba97676c7116Mike Isely struct pvr2_hdw_debug_info *); 343681c739944018d80dbcf7f19997eba97676c7116Mike Isely 344681c739944018d80dbcf7f19997eba97676c7116Mike Isely/* Report out several lines of text that describes driver internal state. 345681c739944018d80dbcf7f19997eba97676c7116Mike Isely Results are written into the passed-in buffer. */ 346681c739944018d80dbcf7f19997eba97676c7116Mike Iselyunsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw, 347681c739944018d80dbcf7f19997eba97676c7116Mike Isely char *buf_ptr,unsigned int buf_size); 348d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 349d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Cause modules to log their state once */ 350d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyvoid pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw); 351d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 352d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* Cause encoder firmware to be uploaded into the device. This is normally 353d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely done autonomously, but the interface is exported here because it is also 354d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely a debugging aid. */ 355d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Iselyint pvr2_upload_firmware2(struct pvr2_hdw *hdw); 356d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 357d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely#endif /* __PVRUSB2_HDW_H */ 358d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely 359d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely/* 360d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely Stuff for Emacs to see, in order to encourage consistent editing style: 361d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** Local Variables: *** 362d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** mode: c *** 363d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** fill-column: 75 *** 364d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** tab-width: 8 *** 365d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** c-basic-offset: 8 *** 366d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely *** End: *** 367d855497edbfbf9e19a17f4a1154bca69cb4bd9baMike Isely */ 368