Skip to contentSkip to conversation

media: i2c: Introduce driver for the TW9900 video decoder

PATCH Superseded Mehdi Djait 4 participants 12 messages Oct 6, 2023 – Oct 14, 2023

Subsystems (3)

v6 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Mehdi Djait

author maintainer
#0 lore raw

v6 cover media: i2c: Introduce driver for the TW9900 video decoder

Hello everyone,

This series is based on the fifth iteration of the series introducing the tw9900 driver: sent 29 Dec 2020 [1]

This is the version 6 of the series adding support for the Techwell TW9900 multi standard decoder. It's a pretty simple decoder compared to the TW9910, since it doesn't have a built-in scaler/crop engine.

Changes v5 => v6:
- dropped .skip_top and .field in the supported_modes
- added error handling for the i2c writes/reads
- added the colorimetry information to fill_fmt
- removed pm_runtime
- added the g_input_status callback
- dropped SECAM
- dropped the non-standard PAL/NTSC variants

Any feedback is appreciated,

Mehdi Djait

media_tree, base-commit: 2c1bae27df787c9535e48cc27bbd11c3c3e0a235

[1] https://lore.kernel.org/linux-media/[email protected]/

Mehdi Djait (3):
dt-bindings: vendor-prefixes: Add techwell vendor prefix
media: dt-bindings: media: i2c: Add bindings for TW9900
media: i2c: Introduce a driver for the Techwell TW9900 decoder

 .../bindings/media/i2c/techwell,tw9900.yaml   |  61 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   6 +
 drivers/media/i2c/Kconfig                     |  12 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/tw9900.c                    | 651 ++++++++++++++++++
 6 files changed, 733 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
 create mode 100644 drivers/media/i2c/tw9900.c
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH v6 1/3 dt-bindings: vendor-prefixes: Add techwell vendor prefix

Add prefix for Techwell, Inc.

---
V5->V6:
- This commit had a "Acked-by: Rob Herring <[email protected]>" Tag but decided not to collect it because the last Iteration was more than 2 years ago

 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 573578db9509..08b74f725142 100644
@@ -1357,6 +1357,8 @@ patternProperties:
     description: Technologic Systems
   "^techstar,.*":
     description: Shenzhen Techstar Electronics Co., Ltd.
+  "^techwell,.*":
+    description: Techwell, Inc.
   "^teejet,.*":
     description: TeeJet
   "^teltonika,.*":
Signature · 1 line
2.41.0
author maintainer
#3 lore raw

PATCH v6 2/3 media: dt-bindings: media: i2c: Add bindings for TW9900

In reply to Mehdi Djait

The Techwell TW9900 is a video decoder supporting multiple input standards, such as PAL and NTSC, and outputs a BT.656 video signal.

It's designed to be low-power, posesses some features such as a programmable comb-filter, and automatic input standard detection

---
V5->V6:
- This commit had a "Reviewed-by: Rob Herring <[email protected]>" Tag but decided not to collect it because the last Iteration was more than 2 years ago
- removed SECAM from the mentioned standards
- changed maintainer

V4->V5:
- renamed the file to match the compatible string, and referenced the graph.yaml schema

V3->V4:
- add the missing reset-gpios node to the binding

V2->V3:
- fix the example not compiling due to a typo in the reset-gpios node.

 .../bindings/media/i2c/techwell,tw9900.yaml   | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +61 -0
new file mode 100644
index 000000000000..24bbbff5cc01
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/techwell,tw9900.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Techwell TW9900 NTSC/PAL video decoder
+
+maintainers:
+  - Mehdi Djait <[email protected]>
+
+description:
+  The tw9900 is a multi-standard video decoder, supporting NTSC, PAL standards
+  with auto-detection features.
+
+properties:
+  compatible:
+    const: techwell,tw9900
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: VDD power supply
+
+  reset-gpios:
+    description: GPIO descriptor for the RESET input pin
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/properties/port
+    description:
+      Video port for the decoder output.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            tw9900: tw9900@44 {
+                    compatible = "techwell,tw9900";
+                    reg = <0x44>;
+
+                    vdd-supply = <&tw9900_supply>;
+                    reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
+
+                    port {
+                            tw9900_out: endpoint {
+                                    remote-endpoint = <&vip_in>;
+                            };
+                    };
+            };
+    };
Signature · 1 line
2.41.0
#4 lore raw

Re: [PATCH v6 2/3] media: dt-bindings: media: i2c: Add bindings for TW9900

Quoted 9 lines · Mehdi Djait

The Techwell TW9900 is a video decoder supporting multiple input standards, such as PAL and NTSC, and outputs a BT.656 video signal.

It's designed to be low-power, posesses some features such as a programmable comb-filter, and automatic input standard detection

---

Thank you for your patch. There is something to discuss/improve.

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +10 -0
+properties:
+  compatible:
+    const: techwell,tw9900
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: VDD power supply
+

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 35

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +10 -0
+  reset-gpios:
+    description: GPIO descriptor for the RESET input pin
+    maxItems: 1
+
+  port:
+    $ref: /schemas/graph.yaml#/properties/port
+    description:
+      Video port for the decoder output.
+
+additionalProperties: false

This goes after required: block

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 46

Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +11 -0
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;

Use 4 spaces for example indentation.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+            tw9900: tw9900@44 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Also, drop unused labels

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 61

Quoted 13 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +13 -0
+                    compatible = "techwell,tw9900";
+                    reg = <0x44>;
+
+                    vdd-supply = <&tw9900_supply>;
+                    reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
+
+                    port {
+                            tw9900_out: endpoint {
+                                    remote-endpoint = <&vip_in>;
+                            };
+                    };
+            };
+    };

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v6 2/3] media: dt-bindings: media: i2c: Add bindings for TW9900

In reply to Mehdi Djait

Hi Mehdi,

Thank you for the patch.

Quoted 55 lines · Mehdi Djait

The Techwell TW9900 is a video decoder supporting multiple input standards, such as PAL and NTSC, and outputs a BT.656 video signal.

It's designed to be low-power, posesses some features such as a programmable comb-filter, and automatic input standard detection

---
V5->V6:
- This commit had a "Reviewed-by: Rob Herring <[email protected]>" Tag but decided not to collect it because the last Iteration was more than 2 years ago
- removed SECAM from the mentioned standards
- changed maintainer

V4->V5:
- renamed the file to match the compatible string, and referenced the graph.yaml schema

V3->V4:
- add the missing reset-gpios node to the binding

V2->V3:
- fix the example not compiling due to a typo in the reset-gpios node.

 .../bindings/media/i2c/techwell,tw9900.yaml   | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +18 -0
new file mode 100644
index 000000000000..24bbbff5cc01
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/techwell,tw9900.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Techwell TW9900 NTSC/PAL video decoder
+
+maintainers:
+  - Mehdi Djait <[email protected]>
+
+description:
+  The tw9900 is a multi-standard video decoder, supporting NTSC, PAL standards
+  with auto-detection features.
+
+properties:
+  compatible:
+    const: techwell,tw9900

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: VDD power supply
+
+  reset-gpios:
+    description: GPIO descriptor for the RESET input pin
+    maxItems: 1

How about the power down GPIO ?

The chip requires a clock, which is provided by a crystal oscillator in the block diagram I found. Does it also support an external clock ? If so the bindings should support it, although this could be added later.

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 33

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +5 -0
+
+  port:
+    $ref: /schemas/graph.yaml#/properties/port
+    description:
+      Video port for the decoder output.

How about input ports, connected to nodes that model the connector(s) ?

Quoted 28 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +28 -0
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            tw9900: tw9900@44 {
+                    compatible = "techwell,tw9900";
+                    reg = <0x44>;
+
+                    vdd-supply = <&tw9900_supply>;
+                    reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
+
+                    port {
+                            tw9900_out: endpoint {
+                                    remote-endpoint = <&vip_in>;
+                            };
+                    };
+            };
+    };
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#6 lore raw

Re: [PATCH v6 2/3] media: dt-bindings: media: i2c: Add bindings for TW9900

Hi laurent,

Thank you for the review.

Quoted 64 lines · Laurent Pinchart

Hi Mehdi,

Thank you for the patch.

Quoted 59 lines · Mehdi Djait

The Techwell TW9900 is a video decoder supporting multiple input standards, such as PAL and NTSC, and outputs a BT.656 video signal.

It's designed to be low-power, posesses some features such as a programmable comb-filter, and automatic input standard detection

---
V5->V6:
- This commit had a "Reviewed-by: Rob Herring <[email protected]>" Tag but decided not to collect it because the last Iteration was more than 2 years ago
- removed SECAM from the mentioned standards
- changed maintainer

V4->V5:
- renamed the file to match the compatible string, and referenced the graph.yaml schema

V3->V4:
- add the missing reset-gpios node to the binding

V2->V3:
- fix the example not compiling due to a typo in the reset-gpios node.

 .../bindings/media/i2c/techwell,tw9900.yaml   | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +22 -0
new file mode 100644
index 000000000000..24bbbff5cc01
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/techwell,tw9900.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Techwell TW9900 NTSC/PAL video decoder
+
+maintainers:
+  - Mehdi Djait <[email protected]>
+
+description:
+  The tw9900 is a multi-standard video decoder, supporting NTSC, PAL standards
+  with auto-detection features.
+
+properties:
+  compatible:
+    const: techwell,tw9900
+
+  reg:
+    maxItems: 1
+
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +6 -0
+  vdd-supply:
+    description: VDD power supply
+
+  reset-gpios:
+    description: GPIO descriptor for the RESET input pin
+    maxItems: 1

How about the power down GPIO ?

I will add the power-down GPIO.

Quoted 5 lines

The chip requires a clock, which is provided by a crystal oscillator in the block diagram I found. Does it also support an external clock ? If so the bindings should support it, although this could be added later.

Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml line 33

Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml new file +5 -0
+
+  port:
+    $ref: /schemas/graph.yaml#/properties/port
+    description:
+      Video port for the decoder output.

How about input ports, connected to nodes that model the connector(s) ?

Could this be added later. Tbh I am not familiar with this. But if it must be added now: Would this be a correct binding:

ports:
$ref: /schemas/graph.yaml#/properties/ports

patternProperties:
"^port@[0-1]$":
$ref: /schemas/graph.yaml#/properties/port
description: Input port nodes for analog inputs.

properties:
port@2:
$ref: /schemas/graph.yaml#/properties/port
description: Video port for the decoder output.

and in the example:
...

            ports {
                #address-cells = <1>;
                #size-cells = <0>;

                port@2 {
                    reg = <2>;

                    endpoint {
                        remote-endpoint = <&vip_in>;
                    };
                };
            };

...

--
Kind Regards
Mehdi Djait

author maintainer
#7 lore raw

PATCH v6 3/3 media: i2c: Introduce a driver for the Techwell TW9900 decoder

In reply to Mehdi Djait

The Techwell video decoder supports PAL, NTSC input formats, and outputs a BT.656 signal.

This commit adds support for this device, with basic support for NTSC and PAL, along with brightness and contrast controls.

The TW9900 is capable of doing automatic standard detection, this is implemented with support for PAL and NTSC autodetection.

---
V5->V6:
- dropped .skip_top and .field in the supported_modes
- added error handling for the i2c writes/reads
- added the colorimetry information to fill_fmt
- removed pm_runtime
- added the g_input_status callback
- dropped SECAM
- dropped the non-standard PAL/NTSC variants

V4->V5:
- Added .querystd() and .g_tvnorms(), dropped the .open() and unified the g_fmt() / s_fmt().

V3->V4:
- Fix a warning about an uninitialized ret variable in probe()

V2->V3:
- Fix coding-style issues, and remove the use of the bulk API for regulators. Make the driver select the media-controller and V4L2-subdev APIs.

V1->V2:
- Set the media entity type to decoder, and implement the s_std/g_std ops

 MAINTAINERS                |   6 +
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/tw9900.c | 651 +++++++++++++++++++++++++++++++++++++
 4 files changed, 670 insertions(+)
 create mode 100644 drivers/media/i2c/tw9900.c
MAINTAINERS +6 -0
index 90f13281d297..164dfb016f18 100644
@@ -21121,6 +21121,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/media/rc/ttusbir.c
 
+TECHWELL TW9900 VIDEO DECODER
+M:	Mehdi Djait <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/i2c/tw9900.c
+
 TECHWELL TW9910 VIDEO DECODER
 L:	[email protected]
 S:	Orphan
drivers/media/i2c/Kconfig +12 -0
index 74ff833ff48c..1bd412d90cee 100644
@@ -1175,6 +1175,18 @@ config VIDEO_TW2804
 	  To compile this driver as a module, choose M here: the
 	  module will be called tw2804.
 
+config VIDEO_TW9900
+	tristate "Techwell TW9900 video decoder"
+	depends on VIDEO_DEV && I2C
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	help
+	  Support for the Techwell tw9900 multi-standard video decoder.
+	  It supports NTSC, PAL standards with auto-detection features.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tw9900.
+
 config VIDEO_TW9903
 	tristate "Techwell TW9903 video decoder"
 	depends on VIDEO_DEV && I2C
drivers/media/i2c/Makefile +1 -0
index 80b00d39b48f..ec318e1fb0c3 100644
@@ -135,6 +135,7 @@ obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
 obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
 obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o
 obj-$(CONFIG_VIDEO_TW2804) += tw2804.o
+obj-$(CONFIG_VIDEO_TW9900) += tw9900.o
 obj-$(CONFIG_VIDEO_TW9903) += tw9903.o
 obj-$(CONFIG_VIDEO_TW9906) += tw9906.o
 obj-$(CONFIG_VIDEO_TW9910) += tw9910.o
drivers/media/i2c/tw9900.c new file +651 -0

651 lines not on this page · raw message

Signature · 1 line
2.41.0
#8 lore raw

Re: [PATCH v6 3/3] media: i2c: Introduce a driver for the Techwell TW9900 decoder

Quoted 10 lines · Mehdi Djait

The Techwell video decoder supports PAL, NTSC input formats, and outputs a BT.656 signal.

This commit adds support for this device, with basic support for NTSC and PAL, along with brightness and contrast controls.

The TW9900 is capable of doing automatic standard detection, this is implemented with support for PAL and NTSC autodetection.

...

Quoted 7 lines
drivers/media/i2c/tw9900.c new file +7 -0
+
+static int tw9900_check_id(struct tw9900 *tw9900,
+			   struct i2c_client *client)
+{
+	struct device *dev = &tw9900->client->dev;
+	int ret;
+

drivers/media/i2c/tw9900.c line 534

Quoted 10 lines
drivers/media/i2c/tw9900.c new file +10 -0
+	ret = tw9900_read_reg(client, TW9900_CHIP_ID);
+	if (ret < 0)
+		return ret;
+
+	if (ret != TW9900_CHIP_ID) {
+		dev_err(dev, "Unexpected decoder id(0x%x)\n", ret);
+		return -EINVAL;
+	}
+
+	dev_info(dev, "Detected TW9900 (0x%x) decoder\n", TW9900_CHIP_ID);

dev_dbg
Do not spam log with simple success messages.

Why do you always print 0x0 (TW9900_CHIP_ID) here? It does not make sense, drop.

Quoted 15 lines
drivers/media/i2c/tw9900.c new file +15 -0
+
+	return 0;
+}
+
+static int tw9900_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct v4l2_ctrl_handler *hdl;
+	struct tw9900 *tw9900;
+	int ret = 0;
+
+	tw9900 = devm_kzalloc(dev, sizeof(*tw9900), GFP_KERNEL);
+	if (!tw9900)
+		return -ENOMEM;
+

drivers/media/i2c/tw9900.c line 559

Quoted 10 lines
drivers/media/i2c/tw9900.c new file +10 -0
+	tw9900->client = client;
+	tw9900->cur_mode = &supported_modes[0];
+
+	tw9900->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(tw9900->reset_gpio))
+		tw9900->reset_gpio = NULL;
+
+	tw9900->regulator = devm_regulator_get(&tw9900->client->dev, "vdd");
+	if (IS_ERR(tw9900->regulator)) {
+		dev_err(dev, "Failed to get power regulator\n");

return dev_err_probe()

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v6 3/3] media: i2c: Introduce a driver for the Techwell TW9900 decoder

In reply to Mehdi Djait
kernel test robot noticed the following build errors:

Hi Mehdi,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on robh/for-next linus/master v6.6-rc5 next-20231013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mehdi-Djait/dt-bindings-vendor-prefixes-Add-techwell-vendor-prefix/20231007-002623
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/857baa8073f0b8051720959ef8fb1d49a6161d36.1696608809.git.mehdi.djait%40bootlin.com
patch subject: [PATCH v6 3/3] media: i2c: Introduce a driver for the Techwell TW9900 decoder
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231015/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231015/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/media/i2c/tw9900.c: In function 'tw9900_get_stream_std':

>> drivers/media/i2c/tw9900.c:359:15: error: implicit declaration of function 'FIELD_GET' [-Werror=implicit-function-declaration]
     359 |         std = FIELD_GET(TW9900_STDNOW_MASK, ret);
         |               ^~~~~~~~~

cc1: some warnings being treated as errors

vim +/FIELD_GET +359 drivers/media/i2c/tw9900.c

347
348 static int tw9900_get_stream_std(struct tw9900 *tw9900,
349 v4l2_std_id *std_id)
350 {
351 int std, ret;
352
353 ret = tw9900_read_reg(tw9900->client, TW9900_REG_STD_SEL);
354 if (ret < 0) {
355 *std_id = V4L2_STD_UNKNOWN;
356 return ret;
357 }
358

 > 359		std = FIELD_GET(TW9900_STDNOW_MASK, ret);

360
361 switch (std) {
362 case TW9900_STD_NTSC_M:
363 *std_id = V4L2_STD_NTSC;
364 break;
365 case TW9900_STD_PAL_BDGHI:
366 *std_id = V4L2_STD_PAL;
367 break;
368 case TW9900_STD_AUTO:
369 *std_id = V4L2_STD_UNKNOWN;
370 break;
371 default:
372 *std_id = V4L2_STD_UNKNOWN;
373 break;
374 }
375
376 return 0;
377 }
378

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw
In reply to Mehdi Djait
Quoted 9 lines · Mehdi Djait

Hello everyone,

This series is based on the fifth iteration of the series introducing the tw9900 driver: sent 29 Dec 2020 [1]

This is the version 6 of the series adding support for the Techwell TW9900 multi standard decoder. It's a pretty simple decoder compared to the TW9910, since it doesn't have a built-in scaler/crop engine.

Quoted 5 lines

Changes v5 => v6:
- dropped .skip_top and .field in the supported_modes
- added error handling for the i2c writes/reads
- added the colorimetry information to fill_fmt
- removed pm_runtime

It's not very nice to keep the chip powered up all the time :-(

Quoted 26 lines

- added the g_input_status callback
- dropped SECAM
- dropped the non-standard PAL/NTSC variants

Any feedback is appreciated,

Mehdi Djait

media_tree, base-commit: 2c1bae27df787c9535e48cc27bbd11c3c3e0a235

[1] https://lore.kernel.org/linux-media/[email protected]/

Mehdi Djait (3):
dt-bindings: vendor-prefixes: Add techwell vendor prefix
media: dt-bindings: media: i2c: Add bindings for TW9900
media: i2c: Introduce a driver for the Techwell TW9900 decoder

 .../bindings/media/i2c/techwell,tw9900.yaml   |  61 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   6 +
 drivers/media/i2c/Kconfig                     |  12 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/tw9900.c                    | 651 ++++++++++++++++++
 6 files changed, 733 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
 create mode 100644 drivers/media/i2c/tw9900.c
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#11 lore raw

Hi Laurent,

Quoted 10 lines · Laurent Pinchart
Quoted 9 lines · Mehdi Djait

Hello everyone,

This series is based on the fifth iteration of the series introducing the tw9900 driver: sent 29 Dec 2020 [1]

This is the version 6 of the series adding support for the Techwell TW9900 multi standard decoder. It's a pretty simple decoder compared to the TW9910, since it doesn't have a built-in scaler/crop engine.

Quoted 8 lines
Quoted 5 lines

Changes v5 => v6:
- dropped .skip_top and .field in the supported_modes
- added error handling for the i2c writes/reads
- added the colorimetry information to fill_fmt
- removed pm_runtime

It's not very nice to keep the chip powered up all the time :-(

I agree 100% I tried to make it work with pm_runtime but I faced many issues. I don't know if this is due to my lack of experience but here is the situation when I enable pm_runtime:

I get most of the time wrong values when calling g_input_status to check if I have a signal or not.

To do that I read the 0x01 – Chip Status Register I (STATUS1) and check the BIT(6): HLOCK:
- 1 = Horizontal sync PLL is locked to the incoming video source.
- 0 = Horizontal sync PLL is not locked.

To make the g_input_status work with pm_runtime I had to add a 300 msleep after power ON! Which is a huge delay.

I also face issues with the standard detection... So I decided to drop it for this first version of the driver.

--
Kind Regards
Mehdi Djait