mirror of https://gitee.com/openkylin/linux.git
[Bluetooth] Add support for TIOCOUTQ and TIOCINQ ioctls
Almost every protocol family supports the TIOCOUTQ and TIOCINQ ioctls and even Bluetooth could make use of them. When implementing audio streaming and integration with GStreamer or PulseAudio they will allow a better timing and synchronization. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
3241ad820d
commit
43cbeee9f9
|
@ -335,11 +335,34 @@ EXPORT_SYMBOL(bt_sock_poll);
|
||||||
int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
|
struct sk_buff *skb;
|
||||||
|
long amount;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg);
|
BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
case TIOCOUTQ:
|
||||||
|
if (sk->sk_state == BT_LISTEN)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
|
||||||
|
if (amount < 0)
|
||||||
|
amount = 0;
|
||||||
|
err = put_user(amount, (int __user *) arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TIOCINQ:
|
||||||
|
if (sk->sk_state == BT_LISTEN)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
lock_sock(sk);
|
||||||
|
skb = skb_peek(&sk->sk_receive_queue);
|
||||||
|
amount = skb ? skb->len : 0;
|
||||||
|
release_sock(sk);
|
||||||
|
err = put_user(amount, (int __user *) arg);
|
||||||
|
break;
|
||||||
|
|
||||||
case SIOCGSTAMP:
|
case SIOCGSTAMP:
|
||||||
err = sock_get_timestamp(sk, (struct timeval __user *) arg);
|
err = sock_get_timestamp(sk, (struct timeval __user *) arg);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue