2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* IEEE 1394 for Linux
|
|
|
|
*
|
|
|
|
* kernel ISO transmission/reception
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Maas Digital LLC
|
|
|
|
*
|
|
|
|
* This code is licensed under the GPL. See the file COPYING in the root
|
|
|
|
* directory of the kernel sources for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IEEE1394_ISO_H
|
|
|
|
#define IEEE1394_ISO_H
|
|
|
|
|
2006-07-03 12:02:29 -04:00
|
|
|
#include <linux/spinlock_types.h>
|
firesat: copyrights, rename to firedtv, API conversions, fix remote control input
Combination of the following changes:
Tue, 26 Aug 2008 00:17:30 +0200 (CEST)
firedtv: fix remote control input
and update the scancode-to-keycode mapping to a current model. Per
default, various media key keycodes are emitted which closely match what
is printed on the remote. Userland can modify the mapping by means of
evdev ioctls. (Not tested.)
The old scancode-to-keycode mapping is left in the driver but cannot be
modified by ioctls. This preserves status quo for old remotes.
Tue, 26 Aug 2008 00:11:28 +0200 (CEST)
firedtv: replace tasklet by workqueue job
Non-atomic context is a lot nicer to work with.
Sun, 24 Aug 2008 23:30:00 +0200 (CEST)
firedtv: move some code back to ieee1394 core
Partially reverts "ieee1394: remove unused code" of Linux 2.6.25.
Sun, 24 Aug 2008 23:29:30 +0200 (CEST)
firedtv: replace semaphore by mutex
firesat->avc_sem and ->demux_sem have been used exactly like a mutex.
The only exception is the schedule_remotecontrol tasklet which did a
down_trylock in atomic context. This is not possible with
mutex_trylock; however the whole remote control related code is
non-functional anyway at the moment. This should be fixed eventually,
probably by turning the tasklet into a worqueue job.
Convert everything else from semaphore to mutex.
Also rewrite a few of the affected functions to unlock the mutex at a
single exit point, instead of in several branches.
Sun, 24 Aug 2008 23:28:45 +0200 (CEST)
firedtv: some header cleanups
Unify #ifndef/#define/#endif guards against multiple inclusion.
Drop extern keyword from function declarations.
Remove #include's into header files where struct declarations suffice.
Remove unused ohci1394 interface and related unused ieee1394 interfaces.
Add a few missing #include's and remove a few apparently obsolete ones.
Sort them alphabetically.
Sun, 24 Aug 2008 23:27:45 +0200 (CEST)
firedtv: nicer registration message and some initialization fixes
Print the correct name in dvb_register_adapter().
While we are at it, replace two switch cascades by one for loop, remove
a superfluous member of struct firesat and of two unused arguments of
AVCIdentifySubunit(), and fix bogus kfree's in firesat_dvbdev_init().
Tue, 26 Aug 2008 14:24:17 +0200 (CEST)
firesat: rename to firedtv
Suggested by Andreas Monitzer. Besides DVB-S/-S2 receivers, the driver
also supports DVB-C and DVB-T receivers, hence the previous project name
is too narrow now.
Not yet done: Rename source directory, files, types, variables...
Sun, 24 Aug 2008 23:26:23 +0200 (CEST)
firesat: add missing copyright notes
Reported by Andreas Monitzer and Christian Dolzer.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2008-08-25 18:17:30 -04:00
|
|
|
#include <linux/wait.h>
|
2006-07-03 12:02:29 -04:00
|
|
|
#include <asm/atomic.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#include "dma.h"
|
|
|
|
|
2006-07-03 12:02:29 -04:00
|
|
|
struct hpsb_host;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/* high-level ISO interface */
|
|
|
|
|
2006-07-03 12:02:28 -04:00
|
|
|
/*
|
|
|
|
* This API sends and receives isochronous packets on a large,
|
|
|
|
* virtually-contiguous kernel memory buffer. The buffer may be mapped
|
|
|
|
* into a user-space process for zero-copy transmission and reception.
|
|
|
|
*
|
|
|
|
* There are no explicit boundaries between packets in the buffer. A
|
|
|
|
* packet may be transmitted or received at any location. However,
|
|
|
|
* low-level drivers may impose certain restrictions on alignment or
|
|
|
|
* size of packets. (e.g. in OHCI no packet may cross a page boundary,
|
|
|
|
* and packets should be quadlet-aligned)
|
|
|
|
*/
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Packet descriptor - the API maintains a ring buffer of these packet
|
2006-07-03 12:02:28 -04:00
|
|
|
* descriptors in kernel memory (hpsb_iso.infos[]). */
|
2005-04-16 18:20:36 -04:00
|
|
|
struct hpsb_iso_packet_info {
|
|
|
|
/* offset of data payload relative to the first byte of the buffer */
|
|
|
|
__u32 offset;
|
|
|
|
|
2006-07-03 12:02:28 -04:00
|
|
|
/* length of the data payload, in bytes (not including the isochronous
|
|
|
|
* header) */
|
2005-04-16 18:20:36 -04:00
|
|
|
__u16 len;
|
|
|
|
|
2006-07-03 12:02:28 -04:00
|
|
|
/* (recv only) the cycle number (mod 8000) on which the packet was
|
|
|
|
* received */
|
2005-04-16 18:20:36 -04:00
|
|
|
__u16 cycle;
|
|
|
|
|
|
|
|
/* (recv only) channel on which the packet was received */
|
|
|
|
__u8 channel;
|
|
|
|
|
|
|
|
/* 2-bit 'tag' and 4-bit 'sy' fields of the isochronous header */
|
|
|
|
__u8 tag;
|
|
|
|
__u8 sy;
|
2005-07-09 20:01:23 -04:00
|
|
|
|
2006-07-03 12:02:28 -04:00
|
|
|
/* length in bytes of the packet including header/trailer.
|
|
|
|
* MUST be at structure end, since the first part of this structure is
|
|
|
|
* also defined in raw1394.h (i.e. struct raw1394_iso_packet_info), is
|
|
|
|
* copied to userspace and is accessed there through libraw1394. */
|
2005-07-09 20:01:23 -04:00
|
|
|
__u16 total_len;
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum hpsb_iso_type { HPSB_ISO_RECV = 0, HPSB_ISO_XMIT = 1 };
|
|
|
|
|
|
|
|
/* The mode of the dma when receiving iso data. Must be supported by chip */
|
|
|
|
enum raw1394_iso_dma_recv_mode {
|
|
|
|
HPSB_ISO_DMA_DEFAULT = -1,
|
|
|
|
HPSB_ISO_DMA_OLD_ABI = 0,
|
|
|
|
HPSB_ISO_DMA_BUFFERFILL = 1,
|
|
|
|
HPSB_ISO_DMA_PACKET_PER_BUFFER = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hpsb_iso {
|
|
|
|
enum hpsb_iso_type type;
|
|
|
|
|
|
|
|
/* pointer to low-level driver and its private data */
|
|
|
|
struct hpsb_host *host;
|
|
|
|
void *hostdata;
|
|
|
|
|
|
|
|
/* a function to be called (from interrupt context) after
|
2006-07-03 12:02:28 -04:00
|
|
|
* outgoing packets have been sent, or incoming packets have
|
|
|
|
* arrived */
|
2005-04-16 18:20:36 -04:00
|
|
|
void (*callback)(struct hpsb_iso*);
|
|
|
|
|
|
|
|
/* wait for buffer space */
|
|
|
|
wait_queue_head_t waitq;
|
|
|
|
|
|
|
|
int speed; /* IEEE1394_SPEED_100, 200, or 400 */
|
|
|
|
int channel; /* -1 if multichannel */
|
|
|
|
int dma_mode; /* dma receive mode */
|
|
|
|
|
|
|
|
|
|
|
|
/* greatest # of packets between interrupts - controls
|
2006-07-03 12:02:28 -04:00
|
|
|
* the maximum latency of the buffer */
|
2005-04-16 18:20:36 -04:00
|
|
|
int irq_interval;
|
|
|
|
|
|
|
|
/* the buffer for packet data payloads */
|
|
|
|
struct dma_region data_buf;
|
|
|
|
|
|
|
|
/* size of data_buf, in bytes (always a multiple of PAGE_SIZE) */
|
|
|
|
unsigned int buf_size;
|
|
|
|
|
|
|
|
/* # of packets in the ringbuffer */
|
|
|
|
unsigned int buf_packets;
|
|
|
|
|
|
|
|
/* protects packet cursors */
|
|
|
|
spinlock_t lock;
|
|
|
|
|
|
|
|
/* the index of the next packet that will be produced
|
|
|
|
or consumed by the user */
|
|
|
|
int first_packet;
|
|
|
|
|
|
|
|
/* the index of the next packet that will be transmitted
|
|
|
|
or received by the 1394 hardware */
|
|
|
|
int pkt_dma;
|
|
|
|
|
|
|
|
/* how many packets, starting at first_packet:
|
2006-07-03 12:02:28 -04:00
|
|
|
* (transmit) are ready to be filled with data
|
|
|
|
* (receive) contain received data */
|
2005-04-16 18:20:36 -04:00
|
|
|
int n_ready_packets;
|
|
|
|
|
|
|
|
/* how many times the buffer has overflowed or underflowed */
|
|
|
|
atomic_t overflows;
|
2008-03-19 17:10:59 -04:00
|
|
|
/* how many cycles were skipped for a given context */
|
|
|
|
atomic_t skips;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-07-09 20:01:23 -04:00
|
|
|
/* Current number of bytes lost in discarded packets */
|
|
|
|
int bytes_discarded;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/* private flags to track initialization progress */
|
|
|
|
#define HPSB_ISO_DRIVER_INIT (1<<0)
|
|
|
|
#define HPSB_ISO_DRIVER_STARTED (1<<1)
|
|
|
|
unsigned int flags;
|
|
|
|
|
|
|
|
/* # of packets left to prebuffer (xmit only) */
|
|
|
|
int prebuffer;
|
|
|
|
|
|
|
|
/* starting cycle for DMA (xmit only) */
|
|
|
|
int start_cycle;
|
|
|
|
|
|
|
|
/* cycle at which next packet will be transmitted,
|
2006-07-03 12:02:28 -04:00
|
|
|
* -1 if not known */
|
2005-04-16 18:20:36 -04:00
|
|
|
int xmit_cycle;
|
|
|
|
|
|
|
|
/* ringbuffer of packet descriptors in regular kernel memory
|
|
|
|
* XXX Keep this last, since we use over-allocated memory from
|
|
|
|
* this entry to fill this field. */
|
|
|
|
struct hpsb_iso_packet_info *infos;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* functions available to high-level drivers (e.g. raw1394) */
|
|
|
|
|
|
|
|
struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
|
|
|
|
unsigned int data_buf_size,
|
|
|
|
unsigned int buf_packets,
|
|
|
|
int channel,
|
|
|
|
int speed,
|
|
|
|
int irq_interval,
|
|
|
|
void (*callback)(struct hpsb_iso*));
|
|
|
|
struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
|
|
|
|
unsigned int data_buf_size,
|
|
|
|
unsigned int buf_packets,
|
|
|
|
int channel,
|
|
|
|
int dma_mode,
|
|
|
|
int irq_interval,
|
|
|
|
void (*callback)(struct hpsb_iso*));
|
|
|
|
int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel);
|
|
|
|
int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel);
|
|
|
|
int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask);
|
2006-07-03 12:02:28 -04:00
|
|
|
int hpsb_iso_xmit_start(struct hpsb_iso *iso, int start_on_cycle,
|
|
|
|
int prebuffer);
|
|
|
|
int hpsb_iso_recv_start(struct hpsb_iso *iso, int start_on_cycle,
|
|
|
|
int tag_mask, int sync);
|
2005-04-16 18:20:36 -04:00
|
|
|
void hpsb_iso_stop(struct hpsb_iso *iso);
|
|
|
|
void hpsb_iso_shutdown(struct hpsb_iso *iso);
|
2006-07-03 12:02:28 -04:00
|
|
|
int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len,
|
|
|
|
u8 tag, u8 sy);
|
2005-04-16 18:20:36 -04:00
|
|
|
int hpsb_iso_xmit_sync(struct hpsb_iso *iso);
|
2007-03-04 21:06:23 -05:00
|
|
|
int hpsb_iso_recv_release_packets(struct hpsb_iso *recv,
|
|
|
|
unsigned int n_packets);
|
2005-04-16 18:20:36 -04:00
|
|
|
int hpsb_iso_recv_flush(struct hpsb_iso *iso);
|
|
|
|
int hpsb_iso_n_ready(struct hpsb_iso *iso);
|
|
|
|
|
|
|
|
/* the following are callbacks available to low-level drivers */
|
|
|
|
|
|
|
|
void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error);
|
|
|
|
void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
|
2006-07-03 12:02:28 -04:00
|
|
|
u16 total_len, u16 cycle, u8 channel, u8 tag,
|
|
|
|
u8 sy);
|
2005-04-16 18:20:36 -04:00
|
|
|
void hpsb_iso_wake(struct hpsb_iso *iso);
|
|
|
|
|
|
|
|
#endif /* IEEE1394_ISO_H */
|