From 67f5198a17a583825013abecb03bb83fa9327429 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 11:49:07 +0100 Subject: [PATCH 01/10] facetimehd: add debug command definitions --- fthd_isp.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/fthd_isp.h b/fthd_isp.h index 5be97bf..22e580a 100644 --- a/fthd_isp.h +++ b/fthd_isp.h @@ -447,6 +447,37 @@ enum fthd_isp_cmds { CISP_CMD_APPLE_CH_DPC_STATIC_DEFECTS_TABLE_SET = 0xc50c, }; +enum isp_debug_cmds { + CISP_CMD_DEBUG_BANNER=0, + CISP_CMD_DEBUG_NOP1, + CISP_CMD_DEBUG_NOP2, + CISP_CMD_DEBUG_PS, + CISP_CMD_DEBUG_GET_ROOT_HANDLE, + CISP_CMD_DEBUG_GET_OBJECT_BY_NAME, + CISP_CMD_DEBUG_GET_NUMBER_OF_CHILDREN, + CISP_CMD_DEBUG_GET_CHILDREN_BY_INDEX, + CISP_CMD_DEBUG_SHOW_OBJECT_GRAPH, + CISP_CMD_DEBUG_DUMP_OBJECT, + CISP_CMD_DEBUG_DUMP_ALL_OBJECTS, + CISP_CMD_DEBUG_GET_DEBUG_LEVEL, + CISP_CMD_DEBUG_SET_DEBUG_LEVEL, + CISP_CMD_DEBUG_SET_DEBUG_LEVEL_RECURSIVE, + CISP_CMD_DEBUG_GET_FSM_COUNT, + CISP_CMD_DEBUG_GET_FSM_BY_INDEX, + CISP_CMD_DEBUG_GET_FSM_BY_NAME, + CISP_CMD_DEBUG_GET_FSM_DEBUG_LEVEL, + CISP_CMD_DEBUG_SET_FSM_DEBUG_LEVEL, + CISP_CMD_DEBUG_FSM_UNKNOWN, /* XXX: don't know what this cmd is doing yet */ + CISP_CMD_DEBUG_HEAP_STATISTICS, + CISP_CMD_DEBUG_IRQ_STATISTICS, + CISP_CMD_DEBUG_SHOW_SEMAPHORE_STATUS, + CISP_CMD_DEBUG_START_CPU_PERFORMANCE_COUNTER, + CISP_CMD_DEBUG_STOP_CPU_PERFORMANCE_COUNTER, + CISP_CMD_DEBUG_SHOW_WIRING_OPERATIONS, + CISP_CMD_DEBUG_SHOW_UNIT_TEST_STATUS, + CISP_CMD_DEBUG_GET_ENVIRONMENT, +}; + struct isp_mem_obj { struct resource base; unsigned int type; @@ -675,6 +706,11 @@ struct isp_cmd_channel_buffer_return { u32 channel; }; +struct fthd_isp_debug_cmd { + u32 show_errors; + u32 arg[64]; +}; + #define to_isp_mem_obj(x) container_of((x), struct isp_mem_obj, base) extern int isp_init(struct fthd_private *dev_priv); From cf1e7c2dfbe7b72bed3dddf36c5c674f72fea191 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 11:49:59 +0100 Subject: [PATCH 02/10] facetimehd: add function to send debug commands to the firmware --- fthd_isp.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fthd_isp.h | 3 +++ 2 files changed, 72 insertions(+) diff --git a/fthd_isp.c b/fthd_isp.c index e27c834..68c5cfe 100644 --- a/fthd_isp.c +++ b/fthd_isp.c @@ -338,6 +338,75 @@ out: return ret; } +int fthd_isp_debug_cmd(struct fthd_private *dev_priv, enum fthd_isp_cmds command, void *buf, + int request_len, int *response_len) +{ + struct isp_mem_obj *request; + struct isp_cmd_hdr cmd; + u32 address, request_size, response_size; + u32 entry; + int len, ret; + + memset(&cmd, 0, sizeof(cmd)); + + if (response_len) { + len = max(request_len, *response_len); + } else { + len = request_len; + } + len += sizeof(struct isp_cmd_hdr); + + pr_debug("sending debug cmd %d to firmware\n", command); + + request = isp_mem_create(dev_priv, FTHD_MEM_CMD, len); + if (!request) { + dev_err(&dev_priv->pdev->dev, "failed to allocate cmd memory object\n"); + return -ENOMEM; + } + + cmd.opcode = command; + + FTHD_S2_MEMCPY_TOIO(request->offset, &cmd, sizeof(struct isp_cmd_hdr)); + if (request_len) + FTHD_S2_MEMCPY_TOIO(request->offset + sizeof(struct isp_cmd_hdr), buf, request_len); + + ret = fthd_channel_ringbuf_send(dev_priv, dev_priv->channel_debug, + request->offset, request_len + 8, (response_len ? *response_len : 0) + 8, &entry); + if (ret) + goto out; + + if (entry == (u32)-1) { + ret = -EIO; + goto out; + } + + ret = fthd_channel_wait_ready(dev_priv, dev_priv->channel_debug, entry, 20000); + if (ret) { + if (response_len) + *response_len = 0; + goto out; + } + + FTHD_S2_MEMCPY_FROMIO(&cmd, request->offset, sizeof(struct isp_cmd_hdr)); + address = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS); + request_size = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_REQUEST_SIZE); + response_size = FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_RESPONSE_SIZE); + + /* XXX: response size in the ringbuf is zero after command completion, how is buffer size + verification done? */ + if (response_len && *response_len) + FTHD_S2_MEMCPY_FROMIO(buf, (address & ~3) + sizeof(struct isp_cmd_hdr), + *response_len); + + pr_info("status %04x, request_len %d response len %d address_flags %x\n", cmd.status, + request_size, response_size, address); + + ret = 0; +out: + isp_mem_destroy(request); + return ret; +} + int fthd_isp_cmd_start(struct fthd_private *dev_priv) diff --git a/fthd_isp.h b/fthd_isp.h index 22e580a..a7c5136 100644 --- a/fthd_isp.h +++ b/fthd_isp.h @@ -765,4 +765,7 @@ extern int fthd_isp_cmd_channel_hue_set(struct fthd_private *dev_priv, int chann extern int fthd_isp_cmd_channel_buffer_return(struct fthd_private *dev_priv, int channel); extern int fthd_start_channel(struct fthd_private *dev_priv, int channel); extern int fthd_stop_channel(struct fthd_private *dev_priv, int channel); +extern int fthd_isp_debug_cmd(struct fthd_private *dev_priv, enum fthd_isp_cmds command, void *buf, + int request_len, int *response_len); + #endif From 59c279a5f31a3278249b188d35ac3b985c42cc03 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 11:50:26 +0100 Subject: [PATCH 03/10] facetimehd: check command status in fthd_isp_cmd() --- fthd_isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fthd_isp.c b/fthd_isp.c index 68c5cfe..4c04a5a 100644 --- a/fthd_isp.c +++ b/fthd_isp.c @@ -332,7 +332,7 @@ static int fthd_isp_cmd(struct fthd_private *dev_priv, enum fthd_isp_cmds comman pr_debug("status %04x, request_len %d response len %d address_flags %x\n", cmd.status, request_size, response_size, address); - ret = 0; + ret = cmd.status ? -EIO : 0; out: isp_mem_destroy(request); return ret; From 5608b8b00fc85c4ad05a57aad46127bf67187dc6 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 11:51:39 +0100 Subject: [PATCH 04/10] facetimehd: add sysfs functions Introduce a new debug sysfs file, which accepts the following commands: ps - show task running in firmware banner - show startup banner get_root - get ROOT object heap - show heap statistics irq - show irq statistics semaphore - show semaphore status wiring - show wiring status get_object_by_name %s - get address for object get_fsm_by_name %s - get address for FSM dump_object %p - show information about object dump_objects - dump all objects (NOTE: will crash firmware) show_objects - show graph about all objects known get_debug_level - get debug level for object set_debug_level - set debug level for object set_debug_level_rec - set debug level recursive for all objects get_fsm_count - get count of FSM's get_fsm_by_index - get fsm address for index get_fsm_debug_level - get debug level for fsm set_fsm_debug_level - set debug level for fsm --- Makefile | 2 +- fthd_drv.c | 13 +++++- fthd_sysfs.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++ fthd_sysfs.h | 27 +++++++++++ 4 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 fthd_sysfs.c create mode 100644 fthd_sysfs.h diff --git a/Makefile b/Makefile index 150a31f..e3d7b86 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -facetimehd-objs := fthd_ddr.o fthd_hw.o fthd_drv.o fthd_ringbuf.o fthd_isp.o fthd_v4l2.o fthd_buffer.o +facetimehd-objs := fthd_ddr.o fthd_hw.o fthd_drv.o fthd_ringbuf.o fthd_isp.o fthd_v4l2.o fthd_buffer.o fthd_sysfs.o obj-m := facetimehd.o KVERSION := $(shell uname -r) diff --git a/fthd_drv.c b/fthd_drv.c index 1bc9ee0..331b6e4 100644 --- a/fthd_drv.c +++ b/fthd_drv.c @@ -34,6 +34,7 @@ #include "fthd_ringbuf.h" #include "fthd_buffer.h" #include "fthd_v4l2.h" +#include "fthd_sysfs.h" static int fthd_pci_reserve_mem(struct fthd_private *dev_priv) { @@ -207,8 +208,11 @@ static void fthd_handle_irq(struct fthd_private *dev_priv, struct fw_channel *ch return; } - if (chan == dev_priv->channel_debug) + if (chan == dev_priv->channel_debug) { + pr_debug("DEBUG channel ready\n"); + wake_up_interruptible(&chan->wq); return; + } while((entry = fthd_channel_ringbuf_receive(dev_priv, chan)) != (u32)-1) { pr_debug("channel %s: message available, address %08x\n", chan->name, FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS)); @@ -330,6 +334,8 @@ static void fthd_pci_remove(struct pci_dev *pdev) if (!dev_priv) goto out; + fthd_sysfs_exit(dev_priv); + fthd_v4l2_unregister(dev_priv); fthd_stop_firmware(dev_priv); @@ -485,7 +491,12 @@ static int fthd_pci_probe(struct pci_dev *pdev, if (ret) goto fail_firmware; + ret = fthd_sysfs_init(dev_priv); + if (ret) + goto fail_v4l2; return 0; +fail_v4l2: + fthd_v4l2_unregister(dev_priv); fail_firmware: fthd_stop_firmware(dev_priv); fail_hw: diff --git a/fthd_sysfs.c b/fthd_sysfs.c new file mode 100644 index 0000000..e73375b --- /dev/null +++ b/fthd_sysfs.c @@ -0,0 +1,125 @@ +/* + * FacetimeHD camera driver + * + * Copyright (C) 2015 Sven Schnelle + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fthd_drv.h" +#include "fthd_sysfs.h" +#include "fthd_isp.h" +#include "fthd_ringbuf.h" + +static ssize_t fthd_show_debug(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return -EINVAL; +} + +static ssize_t fthd_store_debug(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct fthd_isp_debug_cmd cmd; + struct fthd_private *dev_priv = dev_get_drvdata(dev); + int ret, opcode; + + if (count == 0) + return 0; + + if (count > 64) + return -EINVAL; + + memset(&cmd, 0, sizeof(cmd)); + + if (!strcmp(buf, "ps")) + opcode = CISP_CMD_DEBUG_PS; + else if (!strcmp(buf, "banner")) + opcode = CISP_CMD_DEBUG_BANNER; + else if (!strcmp(buf, "get_root")) + opcode = CISP_CMD_DEBUG_GET_ROOT_HANDLE; + else if (!strcmp(buf, "heap")) + opcode = CISP_CMD_DEBUG_HEAP_STATISTICS; + else if (!strcmp(buf, "irq")) + opcode = CISP_CMD_DEBUG_IRQ_STATISTICS; + else if (!strcmp(buf, "semaphore")) + opcode = CISP_CMD_DEBUG_SHOW_SEMAPHORE_STATUS; + else if (!strcmp(buf, "wiring")) + opcode = CISP_CMD_DEBUG_SHOW_WIRING_OPERATIONS; + else if (sscanf(buf, "get_object_by_name %s", (char *)&cmd.arg) == 1) + opcode = CISP_CMD_DEBUG_GET_OBJECT_BY_NAME; + else if (sscanf(buf, "dump_object %x", &cmd.arg[0]) == 1) + opcode = CISP_CMD_DEBUG_DUMP_OBJECT; + else if (!strcmp(buf, "dump_objects")) + opcode = CISP_CMD_DEBUG_DUMP_ALL_OBJECTS; + else if (!strcmp(buf, "show_objects")) + opcode = CISP_CMD_DEBUG_SHOW_OBJECT_GRAPH; + else if (sscanf(buf, "get_debug_level %i", &cmd.arg[0]) == 1) + opcode = CISP_CMD_DEBUG_GET_DEBUG_LEVEL; + else if (sscanf(buf, "set_debug_level %x %i", &cmd.arg[0], &cmd.arg[1]) == 2) + opcode = CISP_CMD_DEBUG_SET_DEBUG_LEVEL; + else if (sscanf(buf, "set_debug_level_rec %x %i", &cmd.arg[0], &cmd.arg[1]) == 2) + opcode = CISP_CMD_DEBUG_SET_DEBUG_LEVEL_RECURSIVE; + else if (!strcmp(buf, "get_fsm_count")) + opcode = CISP_CMD_DEBUG_GET_FSM_COUNT; + else if (sscanf(buf, "get_fsm_by_name %s", (char *)&cmd.arg[0]) == 1) + opcode = CISP_CMD_DEBUG_GET_FSM_BY_NAME; + else if (sscanf(buf, "get_fsm_by_index %i", &cmd.arg[0]) == 1) + opcode = CISP_CMD_DEBUG_GET_FSM_BY_INDEX; + else if (sscanf(buf, "get_fsm_debug_level %x", &cmd.arg[0]) == 1) + opcode = CISP_CMD_DEBUG_GET_FSM_DEBUG_LEVEL; + else if (sscanf(buf, "set_fsm_debug_level %x", &cmd.arg[0]) == 2) + opcode = CISP_CMD_DEBUG_SET_FSM_DEBUG_LEVEL; + + else if (sscanf(buf, "%i %i\n", &opcode, &cmd.arg[0]) != 2) + return -EINVAL; + cmd.show_errors = 1; + + ret = fthd_isp_debug_cmd(dev_priv, opcode, &cmd, sizeof(cmd), NULL); + if (ret) + return ret; + + return count; +} + +static DEVICE_ATTR(debug, S_IWUSR | S_IRUGO, fthd_show_debug, + fthd_store_debug); + +static struct attribute *fthd_attributes[] = { + &dev_attr_debug.attr, +}; + +static struct attribute_group fthd_attribute_group = { + .attrs = fthd_attributes, +}; + +int fthd_sysfs_init(struct fthd_private *dev_priv) +{ + return sysfs_create_group(&dev_priv->pdev->dev.kobj, &fthd_attribute_group); +} + +void fthd_sysfs_exit(struct fthd_private *dev_priv) +{ + sysfs_remove_group(&dev_priv->pdev->dev.kobj, &fthd_attribute_group); +} diff --git a/fthd_sysfs.h b/fthd_sysfs.h new file mode 100644 index 0000000..392ee04 --- /dev/null +++ b/fthd_sysfs.h @@ -0,0 +1,27 @@ +/* + * Broadcom PCIe 1570 webcam driver + * + * Copyright (C) 2015 Sven Schnelle + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation. + * + */ + +#ifndef _FTHD_SYSFS_H +#define _FTHD_SYSFS_H + +struct fthd_private; + +int fthd_sysfs_init(struct fthd_private *priv); +void fthd_sysfs_exit(struct fthd_private *priv); +#endif From 6242aaa624e5116e8ec288b8c64f02e49a5a0646 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 14:41:56 +0100 Subject: [PATCH 05/10] facetimehd: make get_entry_addr() public --- fthd_ringbuf.c | 2 +- fthd_ringbuf.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fthd_ringbuf.c b/fthd_ringbuf.c index 44933c7..2fbef97 100644 --- a/fthd_ringbuf.c +++ b/fthd_ringbuf.c @@ -27,7 +27,7 @@ #include "fthd_ringbuf.h" #include "fthd_isp.h" -static u32 get_entry_addr(struct fthd_private *dev_priv, +u32 get_entry_addr(struct fthd_private *dev_priv, struct fw_channel *chan, int num) { return chan->offset + num * FTHD_RINGBUF_ENTRY_SIZE; diff --git a/fthd_ringbuf.h b/fthd_ringbuf.h index 3b75610..1d98d19 100644 --- a/fthd_ringbuf.h +++ b/fthd_ringbuf.h @@ -49,4 +49,6 @@ extern u32 fthd_channel_ringbuf_receive(struct fthd_private *dev_priv, struct fw_channel *chan); extern int fthd_channel_wait_ready(struct fthd_private *dev_priv, struct fw_channel *chan, u32 entry, int timeout); +extern u32 get_entry_addr(struct fthd_private *dev_priv, + struct fw_channel *chan, int num); #endif From ced9f7805e0e492d3524e7afdb85ebd9b2ef5863 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 14:42:30 +0100 Subject: [PATCH 06/10] facetimehd: add support for dumping ringbuffer via sysfs --- fthd_sysfs.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 8 deletions(-) diff --git a/fthd_sysfs.c b/fthd_sysfs.c index e73375b..fe45f45 100644 --- a/fthd_sysfs.c +++ b/fthd_sysfs.c @@ -31,12 +31,7 @@ #include "fthd_sysfs.h" #include "fthd_isp.h" #include "fthd_ringbuf.h" - -static ssize_t fthd_show_debug(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return -EINVAL; -} +#include "fthd_hw.h" static ssize_t fthd_store_debug(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -103,11 +98,106 @@ static ssize_t fthd_store_debug(struct device *dev, struct device_attribute *att return count; } -static DEVICE_ATTR(debug, S_IWUSR | S_IRUGO, fthd_show_debug, - fthd_store_debug); + +static ssize_t fthd_dump_channel(struct device *dev, struct fw_channel *chan, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + int i; + char pos; + u32 entry; + ssize_t ret = 0, len; + spin_lock_irq(&chan->lock); + for( i = 0; i < chan->size; i++) { + if (chan->ringbuf.idx == i) + pos = '*'; + else + pos = ' '; + entry = get_entry_addr(dev_priv, chan, i); + len = sprintf(buf+ret, "%c%3.3d: ADDRESS %08x REQUEST_SIZE %08x RESPONSE_SIZE %08x\n", + pos, i, + FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS), + FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_REQUEST_SIZE), + FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_RESPONSE_SIZE)); + if (len < 0) { + ret = len; + break; + } else { + ret += len; + } + } + spin_unlock_irq(&chan->lock); + return ret; +} + +static ssize_t channel_terminal_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_io, buf); +} + +static ssize_t channel_sharedmalloc_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_shared_malloc, buf); +} + +static ssize_t channel_io_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_io, buf); +} + +static ssize_t channel_debug_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_debug, buf); +} + +static ssize_t channel_buf_h2t_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_buf_h2t, buf); +} + +static ssize_t channel_buf_t2h_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_buf_t2h, buf); +} + +static ssize_t channel_io_t2h_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fthd_private *dev_priv = dev_get_drvdata(dev); + return fthd_dump_channel(dev, dev_priv->channel_io_t2h, buf); +} + +static DEVICE_ATTR(debug, S_IWUSR | S_IRUGO, NULL, fthd_store_debug); +static DEVICE_ATTR_RO(channel_terminal); +static DEVICE_ATTR_RO(channel_sharedmalloc); +static DEVICE_ATTR_RO(channel_io); +static DEVICE_ATTR_RO(channel_debug); +static DEVICE_ATTR_RO(channel_buf_h2t); +static DEVICE_ATTR_RO(channel_buf_t2h); +static DEVICE_ATTR_RO(channel_io_t2h); static struct attribute *fthd_attributes[] = { &dev_attr_debug.attr, + &dev_attr_channel_terminal.attr, + &dev_attr_channel_sharedmalloc.attr, + &dev_attr_channel_io.attr, + &dev_attr_channel_debug.attr, + &dev_attr_channel_buf_h2t.attr, + &dev_attr_channel_buf_t2h.attr, + &dev_attr_channel_io_t2h.attr, + NULL, }; static struct attribute_group fthd_attribute_group = { From b9cf9afb3158f61e0de1dce3d796a795b9ee2b2e Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 18:23:44 +0100 Subject: [PATCH 07/10] facetimehd: remove explicit V4L2_CAPTURE capability --- fthd_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index c989954..3de77c4 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -379,7 +379,7 @@ static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv, snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(dev_priv->pdev)); - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | + cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_TIMEPERFRAME; cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; From a0118922b6cfab782407ab5afa087197ea23dbdd Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 18:26:34 +0100 Subject: [PATCH 08/10] Revert "facetimehd: remove explicit V4L2_CAPTURE capability" This reverts commit b9cf9afb3158f61e0de1dce3d796a795b9ee2b2e. --- fthd_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index 3de77c4..c989954 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -379,7 +379,7 @@ static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv, snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(dev_priv->pdev)); - cap->device_caps = + cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_TIMEPERFRAME; cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; From 4dd6f5459eb96c9d9b21b29dcf96ebf3290d54a0 Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 20:08:10 +0100 Subject: [PATCH 09/10] facetimehd: remove V4L2_CAP_TIMEPERFRAME --- fthd_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index c989954..dbed607 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -380,7 +380,7 @@ static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv, pci_name(dev_priv->pdev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | - V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_TIMEPERFRAME; + V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } From a8c327894858e2c49b513e85ba1e476b8c37fd6f Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Mon, 30 Nov 2015 20:26:31 +0100 Subject: [PATCH 10/10] facetimehd: don't report that we can do tv standards --- fthd_v4l2.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index dbed607..e1a7120 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -339,8 +339,10 @@ static int fthd_v4l2_ioctl_enum_input(struct file *filp, void *priv, if (input->index != 0) return -EINVAL; + memset(input, 0, sizeof(*input)); + strcpy(input->name, "Camera"); input->type = V4L2_INPUT_TYPE_CAMERA; - input->std = V4L2_STD_ALL; + strcpy(input->name, "Apple Facetime HD"); return 0; } @@ -358,17 +360,6 @@ static int fthd_v4l2_ioctl_s_input(struct file *filp, void *priv, unsigned int i return 0; } -static int fthd_v4l2_ioctl_s_std(struct file *filp, void *priv, v4l2_std_id std) -{ - return 0; -} - -static int fthd_v4l2_ioctl_g_std(struct file *filp, void *priv, v4l2_std_id *std) -{ - *std = V4L2_STD_NTSC_M; - return 0; -} - static int fthd_v4l2_ioctl_querycap(struct file *filp, void *priv, struct v4l2_capability *cap) { @@ -567,8 +558,6 @@ static struct v4l2_ioctl_ops fthd_ioctl_ops = { .vidioc_enum_input = fthd_v4l2_ioctl_enum_input, .vidioc_g_input = fthd_v4l2_ioctl_g_input, .vidioc_s_input = fthd_v4l2_ioctl_s_input, - .vidioc_s_std = fthd_v4l2_ioctl_s_std, - .vidioc_g_std = fthd_v4l2_ioctl_g_std, .vidioc_enum_fmt_vid_cap = fthd_v4l2_ioctl_enum_fmt_vid_cap, .vidioc_try_fmt_vid_cap = fthd_v4l2_ioctl_try_fmt_vid_cap,