* Re: ALPS Trackpoint & pressure
From: Peter Hutterer @ 2018-02-06 0:29 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Pali Rohár, Masaki Ota, linux-input, linux-kernel
In-Reply-To: <20180205224955.GB46524@dtor-ws>
On Mon, Feb 05, 2018 at 02:49:55PM -0800, Dmitry Torokhov wrote:
> On Sun, Feb 04, 2018 at 04:08:39PM +0100, Pali Rohár wrote:
> > Hi! Now playing again with trackpoint connected to ALPS rushmore
> > touchpad and I'm seeking a nice feature. Via ALPS PS/2 protocol it
> > reports pressure of trackpoint. Parser for it is already implemented in
> > alps.c and value is assigned to variable "z". When I just move
> > trackpoint z is zero, when I push trackpoint while moving, then z is
> > number higher, maximally 32. Variable "z" is set, but unused.
> >
> > Do we have some input interface which can be used to report this
> > pressure of trackpoint to userspace? I can use this feature e.g. as
> > additional button...
>
> We could either do the conversion in kernel and emit BTN_LEFT, or
> report ABS_PRESSURE and see if userspace will be able to handle
> REL_X/REL_Y/ABS_PRESSURE device.
>
> Adding Peter.
judging by trackpoint history, I'd leave the pressure->click conversion to
userspace because every trackpoint may need a different threshold setting.
"easier" to have this in userspace with dmi matches etc. plus, converting to
BTN_LEFT in the kernel means we cannot use it as a separate interaction
anymore.
That aside, I think exporting ABS_PRESSURE is fine, that's what it's there
for. Nothing will use it for now though, tbh not sure yet how that would be
exported from libinput. but worth filing a bug for, please assign it to me.
Cheers,
Peter
^ permalink raw reply
* Re: [PATCH 1/2] input: touchscreen: ar1021_i2c: enable touch mode during open
From: Dmitry Torokhov @ 2018-02-06 1:20 UTC (permalink / raw)
To: Christian Gmeiner; +Cc: Martin Kepplinger, linux-input, LKML
In-Reply-To: <CAH9NwWeom2H89D5hUixxSL28YgDna_WS26boayzUBAPyVFUvTA@mail.gmail.com>
On Mon, Feb 05, 2018 at 11:07:08AM +0100, Christian Gmeiner wrote:
> Hi all.
>
> 2017-04-27 14:22 GMT+02:00 Martin Kepplinger <martin.kepplinger@ginzinger.com>:
> > The device could as well be in command mode, in which this driver cannot
> > handle the device. When opening the device, let's make sure the device
> > will be in the mode we expect it to be for this driver.
> >
>
> I run into issues caused by this change. It turns out that the device
> is non-functional
> after some warm-reboots and as a result I am not able to use xorg's
> evdev driver.
> So I have some questions about this change:
>
> * Should we enable irq before calling i2c_master_send(..) as the chip raises an
> irq if the command was processed?
Well, we do not care about the response... However, what is your
interrupt trigger settings? Are you using edge by chance? If so, please
try switching to level.
>
> * Would it be enough to send this command only once during driver
> lifetime? I can
> see that on my system open gets called 3 times during boot-up.
>
> * What are the circumstances the touch device would be in an other state? In the
> official kernel driver the userspace can send commands via sysfs.
> Also the driver
> does set the touch enable mode as this patch does.
What is "the official kernel driver"?
Thanks.
--
Dmitry
^ permalink raw reply
* Re: Software evolution around “checkpatch.pl”?
From: SF Markus Elfring @ 2018-02-06 8:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, linux-input
Cc: Jonathan Cameron, Hartmut Knaack, Jiri Kosina, Lars-Peter Clausen,
Peter Meerwald-Stadler, Srinivas Pandruvada, LKML,
kernel-janitors
In-Reply-To: <87DF341A-1356-4B1B-8D25-14D5B0AAB01D@jic23.retrosnub.co.uk>
> Check patch is dumb and often gives false positives.
Would you like to improve this software situation anyhow?
Regards,
Markus
^ permalink raw reply
* Re: [PATCH 5/5] add default control values as module parameters
From: Florian Echtler @ 2018-02-06 9:18 UTC (permalink / raw)
To: Hans Verkuil, linux-media; +Cc: linux-input, modin
In-Reply-To: <0be7b0ae-e0e0-7b25-fd76-8cf6387a4dd6@xs4all.nl>
[-- Attachment #1.1: Type: text/plain, Size: 1107 bytes --]
On 05.02.2018 15:56, Hans Verkuil wrote:
> Please add a change log when you make a patch.
> I for one would like to know why this has to be supplied as a module option.
The idea here was that each individual SUR40 device will likely have slightly
different "ideal" settings for the parameters, and by using the module options,
you can set them right away at startup.
I'm aware that the usual way to do this would be from userspace using v4l2-ctl,
but the SUR40 is sort of a special case: the video settings will also influence
the internal touch detection, and in the worst case, starting the driver with
the default parameters from flash will immediately cause so many false-positive
touch points to be detected that the graphical shell becomes unusable. This has
actually happened several times during testing, so we considered a module option
to be the easiest way for dealing with this.
> Some documentation in the code would be helpful as well (e.g. I have no idea
> what a 'vsvideo' is).
Right - will do that, too.
Best regards, Florian
--
SENT FROM MY DEC VT50 TERMINAL
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply
* [PATCH 0/3] HID-Logitech: Adjustments for two function implementations
From: SF Markus Elfring @ 2018-02-06 14:43 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 15:38:30 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in lg_probe()
Improve a size determination in lg_probe()
Delete an error message for a failed memory allocation in lg4ff_init()
drivers/hid/hid-lg.c | 7 +++----
drivers/hid/hid-lg4ff.c | 4 +---
2 files changed, 4 insertions(+), 7 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe()
From: SF Markus Elfring @ 2018-02-06 14:45 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <5c76a767-b1cb-2486-f24d-0d5a220b8985@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 14:25:32 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lg.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 596227ddb6e0..f4439dc64497 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -728,10 +728,9 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
- if (!drv_data) {
- hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
+ if (!drv_data)
return -ENOMEM;
- }
+
drv_data->quirks = id->driver_data;
hid_set_drvdata(hdev, (void *)drv_data);
--
2.16.1
^ permalink raw reply related
* [PATCH 2/3] hid-lg: Improve a size determination in lg_probe()
From: SF Markus Elfring @ 2018-02-06 14:46 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <5c76a767-b1cb-2486-f24d-0d5a220b8985@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 14:54:14 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index f4439dc64497..358b4c6f856d 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -727,7 +727,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
return -ENODEV;
}
- drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
+ drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
--
2.16.1
^ permalink raw reply related
* [PATCH 3/3] hid-lg4ff: Delete an error message for a failed memory allocation in lg4ff_init()
From: SF Markus Elfring @ 2018-02-06 14:47 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <5c76a767-b1cb-2486-f24d-0d5a220b8985@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 15:26:06 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lg4ff.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 512d67e1aae3..ec6b94bb3fd8 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -1401,10 +1401,8 @@ int lg4ff_init(struct hid_device *hid)
for (j = 0; j < 5; j++) {
led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
- if (!led) {
- hid_err(hid, "can't allocate memory for LED %d\n", j);
+ if (!led)
goto err_leds;
- }
name = (void *)(&led[1]);
snprintf(name, name_sz, "%s::RPM%d", dev_name(&hid->dev), j+1);
--
2.16.1
^ permalink raw reply related
* [PATCH 0/3] HID-Lenovo: Adjustments for three function implementations
From: SF Markus Elfring @ 2018-02-06 16:14 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:12:34 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in two functions
Improve a size determination in lenovo_probe_tpkbd()
Adjust four checks for null pointers
drivers/hid/hid-lenovo.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/3] HID: lenovo: Delete an error message for a failed memory allocation in two functions
From: SF Markus Elfring @ 2018-02-06 16:16 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <06e2d590-f980-0022-c476-6b999239ff9f@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:48:52 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lenovo.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 1ac4ff4d57a6..549b84d01b46 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -688,7 +688,6 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
sizeof(struct lenovo_drvdata_tpkbd),
GFP_KERNEL);
if (data_pointer == NULL) {
- hid_err(hdev, "Could not allocate memory for driver data\n");
ret = -ENOMEM;
goto err;
}
@@ -746,10 +745,9 @@ static int lenovo_probe_cptkbd(struct hid_device *hdev)
cptkbd_data = devm_kzalloc(&hdev->dev,
sizeof(*cptkbd_data),
GFP_KERNEL);
- if (cptkbd_data == NULL) {
- hid_err(hdev, "can't alloc keyboard descriptor\n");
+ if (!cptkbd_data)
return -ENOMEM;
- }
+
hid_set_drvdata(hdev, cptkbd_data);
/*
--
2.16.1
^ permalink raw reply related
* [PATCH 2/3] HID: lenovo: Improve a size determination in lenovo_probe_tpkbd()
From: SF Markus Elfring @ 2018-02-06 16:17 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <06e2d590-f980-0022-c476-6b999239ff9f@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:52:58 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lenovo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 549b84d01b46..f863b94f3476 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -685,7 +685,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
hid_warn(hdev, "Could not create sysfs group: %d\n", ret);
data_pointer = devm_kzalloc(&hdev->dev,
- sizeof(struct lenovo_drvdata_tpkbd),
+ sizeof(*data_pointer),
GFP_KERNEL);
if (data_pointer == NULL) {
ret = -ENOMEM;
--
2.16.1
^ permalink raw reply related
* [PATCH 3/3] HID: lenovo: Adjust four checks for null pointers
From: SF Markus Elfring @ 2018-02-06 16:19 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <06e2d590-f980-0022-c476-6b999239ff9f@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:02:53 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lenovo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index f863b94f3476..ba128123466b 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -687,7 +687,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer = devm_kzalloc(&hdev->dev,
sizeof(*data_pointer),
GFP_KERNEL);
- if (data_pointer == NULL) {
+ if (!data_pointer) {
ret = -ENOMEM;
goto err;
}
@@ -698,7 +698,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
- if (name_mute == NULL || name_micmute == NULL) {
+ if (!name_mute || !name_micmute) {
hid_err(hdev, "Could not allocate memory for led data\n");
ret = -ENOMEM;
goto err;
@@ -823,7 +823,7 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev)
* Only the trackpoint half of the keyboard has drvdata and stuff that
* needs unregistering.
*/
- if (data_pointer == NULL)
+ if (!data_pointer)
return;
sysfs_remove_group(&hdev->dev.kobj,
--
2.16.1
^ permalink raw reply related
* [PATCH] HID: core: Delete an error message for a failed memory allocation in open_collection()
From: SF Markus Elfring @ 2018-02-06 16:47 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:40:51 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c2560aae5542..5ad5f52f6f9b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -133,10 +133,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
if (parser->device->maxcollection == parser->device->collection_size) {
collection = kmalloc(sizeof(struct hid_collection) *
parser->device->collection_size * 2, GFP_KERNEL);
- if (collection == NULL) {
- hid_err(parser->device, "failed to reallocate collection array\n");
+ if (!collection)
return -ENOMEM;
- }
+
memcpy(collection, parser->device->collection,
sizeof(struct hid_collection) *
parser->device->collection_size);
--
2.16.1
^ permalink raw reply related
* [PATCH 0/2] HID-Asus: Adjustments for two function implementations
From: SF Markus Elfring @ 2018-02-06 17:28 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 18:24:56 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in two functions
Return an error code only as a constant in asus_start_multitouch()
drivers/hid/hid-asus.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] HID: asus: Delete an error message for a failed memory allocation in two functions
From: SF Markus Elfring @ 2018-02-06 17:29 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <5289ace9-8927-9803-4692-c7c621ab0a8d@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 18:03:19 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-asus.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 6d2894b7d8e7..9573e0b41922 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -566,7 +566,6 @@ static int asus_start_multitouch(struct hid_device *hdev)
if (!dmabuf) {
ret = -ENOMEM;
- hid_err(hdev, "Asus failed to alloc dma buf: %d\n", ret);
return ret;
}
@@ -599,10 +598,8 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
struct asus_drvdata *drvdata;
drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
- if (drvdata == NULL) {
- hid_err(hdev, "Can't alloc Asus descriptor\n");
+ if (!drvdata)
return -ENOMEM;
- }
hid_set_drvdata(hdev, drvdata);
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] HID: asus: Return an error code only as a constant in asus_start_multitouch()
From: SF Markus Elfring @ 2018-02-06 17:30 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
In-Reply-To: <5289ace9-8927-9803-4692-c7c621ab0a8d@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 18:18:50 +0100
Return an error code without storing it in an intermediate variable.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-asus.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 9573e0b41922..5e143552dab9 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -564,10 +564,8 @@ static int asus_start_multitouch(struct hid_device *hdev)
const unsigned char buf[] = { FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00 };
unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
- if (!dmabuf) {
- ret = -ENOMEM;
- return ret;
- }
+ if (!dmabuf)
+ return -ENOMEM;
ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, sizeof(buf),
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
--
2.16.1
^ permalink raw reply related
* [PATCH] HID: apple: Delete an error message for a failed memory allocation in apple_probe()
From: SF Markus Elfring @ 2018-02-06 19:35 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 20:06:53 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-apple.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 25b7bd56ae11..d739dd3aa622 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -374,10 +374,8 @@ static int apple_probe(struct hid_device *hdev,
int ret;
asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
- if (asc == NULL) {
- hid_err(hdev, "can't alloc apple descriptor\n");
+ if (!asc)
return -ENOMEM;
- }
asc->quirks = quirks;
--
2.16.1
^ permalink raw reply related
* [PATCH] hid-a4tech: Delete an error message for a failed memory allocation in a4_probe()
From: SF Markus Elfring @ 2018-02-06 19:52 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 20:48:04 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-a4tech.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index 9428ea7cdf8a..7a364f17f39e 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -91,10 +91,8 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id)
int ret;
a4 = devm_kzalloc(&hdev->dev, sizeof(*a4), GFP_KERNEL);
- if (a4 == NULL) {
- hid_err(hdev, "can't alloc device descriptor\n");
+ if (!a4)
return -ENOMEM;
- }
a4->quirks = id->driver_data;
--
2.16.1
^ permalink raw reply related
* [PATCH 2/5] add control definitions
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin, Florian Echtler
In-Reply-To: <1517950905-5015-1-git-send-email-floe@butterbrot.org>
This patch adds parameter definitions for the four userspace controls that
the SUR40 can currently provide.
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
drivers/input/touchscreen/sur40.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 8375b06..3af63415 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -149,6 +149,23 @@ struct sur40_image_header {
#define SUR40_TOUCH 0x02
#define SUR40_TAG 0x04
+/* video controls */
+#define SUR40_BRIGHTNESS_MAX 0xFF
+#define SUR40_BRIGHTNESS_MIN 0x00
+#define SUR40_BRIGHTNESS_DEF 0xFF
+
+#define SUR40_CONTRAST_MAX 0x0F
+#define SUR40_CONTRAST_MIN 0x00
+#define SUR40_CONTRAST_DEF 0x0A
+
+#define SUR40_GAIN_MAX 0x09
+#define SUR40_GAIN_MIN 0x00
+#define SUR40_GAIN_DEF 0x08
+
+#define SUR40_BACKLIGHT_MAX 0x01
+#define SUR40_BACKLIGHT_MIN 0x00
+#define SUR40_BACKLIGHT_DEF 0x01
+
static const struct v4l2_pix_format sur40_pix_format[] = {
{
.pixelformat = V4L2_TCH_FMT_TU08,
--
2.7.4
^ permalink raw reply related
* [PATCH 3/5] add panel register access functions
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin, Florian Echtler
In-Reply-To: <1517950905-5015-1-git-send-email-floe@butterbrot.org>
These functions provide write access to the internal LCD panel registers
which also control the sensor. They can be used to disable the
preprocessor, set the illumination brightness, and adjust gain/contrast
(which are stored together in one register internally called "vsvideo").
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
drivers/input/touchscreen/sur40.c | 71 +++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 3af63415..7f6461d 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -240,6 +240,81 @@ static int sur40_command(struct sur40_state *dev,
0x00, index, buffer, size, 1000);
}
+/* poke a byte in the panel register space */
+static int sur40_poke(struct sur40_state *dev, u8 offset, u8 value)
+{
+ int result;
+ u8 index = 0x96; // 0xae for permanent write
+
+ result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+ SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ 0x32, index, NULL, 0, 1000);
+ if (result < 0)
+ goto error;
+ msleep(5);
+
+ result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+ SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ 0x72, offset, NULL, 0, 1000);
+ if (result < 0)
+ goto error;
+ msleep(5);
+
+ result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+ SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ 0xb2, value, NULL, 0, 1000);
+ if (result < 0)
+ goto error;
+ msleep(5);
+
+error:
+ return result;
+}
+
+static int sur40_set_preprocessor(struct sur40_state *dev, u8 value)
+{
+ u8 setting_07[2] = { 0x01, 0x00 };
+ u8 setting_17[2] = { 0x85, 0x80 };
+ int result;
+
+ if (value > 1)
+ return -ERANGE;
+
+ result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+ SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ 0x07, setting_07[value], NULL, 0, 1000);
+ if (result < 0)
+ goto error;
+ msleep(5);
+
+ result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+ SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ 0x17, setting_17[value], NULL, 0, 1000);
+ if (result < 0)
+ goto error;
+ msleep(5);
+
+error:
+ return result;
+}
+
+static void sur40_set_vsvideo(struct sur40_state *handle, u8 value)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ sur40_poke(handle, 0x1c+i, value);
+ handle->vsvideo = value;
+}
+
+static void sur40_set_irlevel(struct sur40_state *handle, u8 value)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ sur40_poke(handle, 0x08+(2*i), value);
+}
+
/* Initialization routine, called from sur40_open */
static int sur40_init(struct sur40_state *dev)
{
--
2.7.4
^ permalink raw reply related
* [PATCH 4/5] register control handlers using V4L2 control framework
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin, Florian Echtler
In-Reply-To: <1517950905-5015-1-git-send-email-floe@butterbrot.org>
This patch registers four standard control handlers using the corresponding
V4L2 framework.
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
drivers/input/touchscreen/sur40.c | 51 +++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 7f6461d..66ef7e6 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -38,6 +38,7 @@
#include <media/v4l2-device.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-ioctl.h>
+#include <media/v4l2-ctrls.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-dma-sg.h>
@@ -198,6 +199,7 @@ struct sur40_state {
struct video_device vdev;
struct mutex lock;
struct v4l2_pix_format pix_fmt;
+ struct v4l2_ctrl_handler ctrls;
struct vb2_queue queue;
struct list_head buf_list;
@@ -207,6 +209,7 @@ struct sur40_state {
struct sur40_data *bulk_in_buffer;
size_t bulk_in_size;
u8 bulk_in_epaddr;
+ u8 vsvideo;
char phys[64];
};
@@ -220,6 +223,11 @@ struct sur40_buffer {
static const struct video_device sur40_video_device;
static const struct vb2_queue sur40_queue;
static void sur40_process_video(struct sur40_state *sur40);
+static int sur40_s_ctrl(struct v4l2_ctrl *ctrl);
+
+static const struct v4l2_ctrl_ops sur40_ctrl_ops = {
+ .s_ctrl = sur40_s_ctrl,
+};
/*
* Note: an earlier, non-public version of this driver used USB_RECIP_ENDPOINT
@@ -722,6 +730,23 @@ static int sur40_probe(struct usb_interface *interface,
sur40->vdev.queue = &sur40->queue;
video_set_drvdata(&sur40->vdev, sur40);
+ /* initialize the control handler for 4 controls */
+ v4l2_ctrl_handler_init(&sur40->ctrls, 4);
+ sur40->v4l2.ctrl_handler = &sur40->ctrls;
+
+ v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_BRIGHTNESS,
+ SUR40_BRIGHTNESS_MIN, SUR40_BRIGHTNESS_MAX, 1, SUR40_BRIGHTNESS_DEF);
+
+ v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_CONTRAST,
+ SUR40_CONTRAST_MIN, SUR40_CONTRAST_MAX, 1, SUR40_CONTRAST_DEF);
+
+ v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_GAIN,
+ SUR40_GAIN_MIN, SUR40_GAIN_MAX, 1, SUR40_GAIN_DEF);
+
+ v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops,
+ V4L2_CID_BACKLIGHT_COMPENSATION, SUR40_BACKLIGHT_MIN,
+ SUR40_BACKLIGHT_MAX, 1, SUR40_BACKLIGHT_DEF);
+
error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1);
if (error) {
dev_err(&interface->dev,
@@ -754,6 +779,7 @@ static void sur40_disconnect(struct usb_interface *interface)
{
struct sur40_state *sur40 = usb_get_intfdata(interface);
+ v4l2_ctrl_handler_free(&sur40->ctrls);
video_unregister_device(&sur40->vdev);
v4l2_device_unregister(&sur40->v4l2);
@@ -947,6 +973,31 @@ static int sur40_vidioc_g_fmt(struct file *file, void *priv,
return 0;
}
+static int sur40_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+ struct sur40_state *sur40 = container_of(ctrl->handler,
+ struct sur40_state, ctrls);
+ u8 value = sur40->vsvideo;
+
+ switch (ctrl->id) {
+ case V4L2_CID_BRIGHTNESS:
+ sur40_set_irlevel(sur40, ctrl->val);
+ break;
+ case V4L2_CID_CONTRAST:
+ value = (value & 0x0F) | (ctrl->val << 4);
+ sur40_set_vsvideo(sur40, value);
+ break;
+ case V4L2_CID_GAIN:
+ value = (value & 0xF0) | (ctrl->val);
+ sur40_set_vsvideo(sur40, value);
+ break;
+ case V4L2_CID_BACKLIGHT_COMPENSATION:
+ sur40_set_preprocessor(sur40, ctrl->val);
+ break;
+ }
+ return 0;
+}
+
static int sur40_ioctl_parm(struct file *file, void *priv,
struct v4l2_streamparm *p)
{
--
2.7.4
^ permalink raw reply related
* [PATCH 5/5] add module parameters for default values
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin, Florian Echtler
In-Reply-To: <1517950905-5015-1-git-send-email-floe@butterbrot.org>
To allow setting custom parameters for the sensor directly at startup, the
three primary controls are exposed as module parameters in this patch.
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
drivers/input/touchscreen/sur40.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 66ef7e6..d1fcb95 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -167,6 +167,17 @@ struct sur40_image_header {
#define SUR40_BACKLIGHT_MIN 0x00
#define SUR40_BACKLIGHT_DEF 0x01
+/* module parameters */
+static uint brightness = SUR40_BRIGHTNESS_DEF;
+module_param(brightness, uint, 0644);
+MODULE_PARM_DESC(brightness, "set default brightness");
+static uint contrast = SUR40_CONTRAST_DEF;
+module_param(contrast, uint, 0644);
+MODULE_PARM_DESC(contrast, "set default contrast");
+static uint gain = SUR40_GAIN_DEF;
+module_param(gain, uint, 0644);
+MODULE_PARM_DESC(contrast, "set default gain");
+
static const struct v4l2_pix_format sur40_pix_format[] = {
{
.pixelformat = V4L2_TCH_FMT_TU08,
@@ -374,6 +385,11 @@ static void sur40_open(struct input_polled_dev *polldev)
dev_dbg(sur40->dev, "open\n");
sur40_init(sur40);
+
+ /* set default values */
+ sur40_set_irlevel(sur40, brightness & 0xFF);
+ sur40_set_vsvideo(sur40, ((contrast & 0x0F) << 4) | (gain & 0x0F));
+ sur40_set_preprocessor(sur40, SUR40_BACKLIGHT_DEF);
}
/* Disable device, polling has stopped. */
--
2.7.4
^ permalink raw reply related
* [PATCH v2] [RFC] add video controls for SUR40 driver
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin
As discussed previously, here's a second iteration of my patch to add
control functions for the SUR40 driver, now using the V4L2 control
framework.
^ permalink raw reply
* [PATCH 1/5] add missing blob structure field for tag id
From: Florian Echtler @ 2018-02-06 21:01 UTC (permalink / raw)
To: hverkuil, linux-media; +Cc: linux-input, modin, Florian Echtler
In-Reply-To: <1517950905-5015-1-git-send-email-floe@butterbrot.org>
The SUR40 can recognize specific printed patterns directly in hardware;
this information (i.e. the pattern id) is present but currently unused
in the blob structure.
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
drivers/input/touchscreen/sur40.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index f16f835..8375b06 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -81,7 +81,10 @@ struct sur40_blob {
__le32 area; /* size in pixels/pressure (?) */
- u8 padding[32];
+ u8 padding[24];
+
+ __le32 tag_id; /* valid when type == 0x04 (SUR40_TAG) */
+ __le32 unknown;
} __packed;
--
2.7.4
^ permalink raw reply related
* Re: [PATCH 1/5] add missing blob structure field for tag id
From: Hans Verkuil @ 2018-02-06 21:22 UTC (permalink / raw)
To: Florian Echtler, linux-media; +Cc: linux-input, modin
In-Reply-To: <1517950905-5015-2-git-send-email-floe@butterbrot.org>
On 02/06/2018 10:01 PM, Florian Echtler wrote:
> The SUR40 can recognize specific printed patterns directly in hardware;
> this information (i.e. the pattern id) is present but currently unused
> in the blob structure.
>
> Signed-off-by: Florian Echtler <floe@butterbrot.org>
> ---
> drivers/input/touchscreen/sur40.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
> index f16f835..8375b06 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -81,7 +81,10 @@ struct sur40_blob {
>
> __le32 area; /* size in pixels/pressure (?) */
>
> - u8 padding[32];
> + u8 padding[24];
> +
> + __le32 tag_id; /* valid when type == 0x04 (SUR40_TAG) */
> + __le32 unknown;
>
> } __packed;
>
>
Usually new fields are added before the padding, not after.
Unless there is a good reason for this I'd change this.
Regards,
Hans
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox