Skip to contentSkip to conversation

trivial: uapi: replace bitshifts with BIT macro

PATCH In review Garrit Franke 3 participants 4 messages Jul 24, 2020 – Jul 25, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trivial: uapi: replace bitshifts with BIT macro

---
 include/uapi/linux/media.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/media.h +10 -10
index 383ac7b7d8..5710ba0c83 100644
@@ -142,8 +142,8 @@ struct media_device_info {
 #define MEDIA_ENT_F_DV_ENCODER			(MEDIA_ENT_F_BASE + 0x6002)
 
 /* Entity flags */
-#define MEDIA_ENT_FL_DEFAULT			(1 << 0)
-#define MEDIA_ENT_FL_CONNECTOR			(1 << 1)
+#define MEDIA_ENT_FL_DEFAULT			BIT(0)
+#define MEDIA_ENT_FL_CONNECTOR			BIT(1)
 
 /* OR with the entity id value to find the next entity */
 #define MEDIA_ENT_ID_FLAG_NEXT			(1U << 31)
@@ -207,9 +207,9 @@ struct media_entity_desc {
 	};
 };
 
-#define MEDIA_PAD_FL_SINK			(1 << 0)
-#define MEDIA_PAD_FL_SOURCE			(1 << 1)
-#define MEDIA_PAD_FL_MUST_CONNECT		(1 << 2)
+#define MEDIA_PAD_FL_SINK				BIT(0)
+#define MEDIA_PAD_FL_SOURCE				BIT(1)
+#define MEDIA_PAD_FL_MUST_CONNECT		BIT(2)
 
 struct media_pad_desc {
 	__u32 entity;		/* entity ID */
@@ -218,13 +218,13 @@ struct media_pad_desc {
 	__u32 reserved[2];
 };
 
-#define MEDIA_LNK_FL_ENABLED			(1 << 0)
-#define MEDIA_LNK_FL_IMMUTABLE			(1 << 1)
-#define MEDIA_LNK_FL_DYNAMIC			(1 << 2)
+#define MEDIA_LNK_FL_ENABLED			BIT(0)
+#define MEDIA_LNK_FL_IMMUTABLE			BIT(1)
+#define MEDIA_LNK_FL_DYNAMIC			BIT(2)
 
 #define MEDIA_LNK_FL_LINK_TYPE			(0xf << 28)
 #  define MEDIA_LNK_FL_DATA_LINK		(0 << 28)
-#  define MEDIA_LNK_FL_INTERFACE_LINK		(1 << 28)
+#  define MEDIA_LNK_FL_INTERFACE_LINK		BIT(28)
 
 struct media_link_desc {
 	struct media_pad_desc source;
@@ -433,7 +433,7 @@ struct media_v2_topology {
 #define MEDIA_INTF_T_ALSA_TIMER                (MEDIA_INTF_T_ALSA_BASE + 7)
 
 /* Obsolete symbol for media_version, no longer used in the kernel */
-#define MEDIA_API_VERSION			((0 << 16) | (1 << 8) | 0)
+#define MEDIA_API_VERSION			((0 << 16) | BIT(8) | 0)
 
 #endif
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Hi Garrit,

Thank you for the patch.

On Fri, Jul 24, 2020 at 09:01:18PM +0200, Garrit Franke wrote:

A commit message would be nice.

Quoted 10 lines
---
 include/uapi/linux/media.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/media.h +0 -0
index 383ac7b7d8..5710ba0c83 100644

include/uapi/linux/media.h struct media_device_info { · line 146

Quoted 7 lines
include/uapi/linux/media.h +2 -2
@@ -142,8 +142,8 @@ struct media_device_info {
 #define MEDIA_ENT_F_DV_ENCODER			(MEDIA_ENT_F_BASE + 0x6002)
 
 /* Entity flags */
-#define MEDIA_ENT_FL_DEFAULT			(1 << 0)
-#define MEDIA_ENT_FL_CONNECTOR			(1 << 1)
+#define MEDIA_ENT_FL_DEFAULT			BIT(0)
+#define MEDIA_ENT_FL_CONNECTOR			BIT(1)

The BIT() macro isn't available in the uapi headers.

Quoted 21 lines
include/uapi/linux/media.h +3 -4
 /* OR with the entity id value to find the next entity */
 #define MEDIA_ENT_ID_FLAG_NEXT			(1U << 31)
@@ -207,9 +207,9 @@ struct media_entity_desc {
 	};
 };
 
-#define MEDIA_PAD_FL_SINK			(1 << 0)
-#define MEDIA_PAD_FL_SOURCE			(1 << 1)
-#define MEDIA_PAD_FL_MUST_CONNECT		(1 << 2)
+#define MEDIA_PAD_FL_SINK				BIT(0)
+#define MEDIA_PAD_FL_SOURCE				BIT(1)
+#define MEDIA_PAD_FL_MUST_CONNECT		BIT(2)
 
 struct media_pad_desc {
 	__u32 entity;		/* entity ID */
@@ -218,13 +218,13 @@ struct media_pad_desc {
 	__u32 reserved[2];
 };
 
-#define MEDIA_LNK_FL_ENABLED			(1 << 0)

include/uapi/linux/media.h struct media_pad_desc { · line 227

Quoted 10 lines
include/uapi/linux/media.h +4 -3
-#define MEDIA_LNK_FL_IMMUTABLE			(1 << 1)
-#define MEDIA_LNK_FL_DYNAMIC			(1 << 2)
+#define MEDIA_LNK_FL_ENABLED			BIT(0)
+#define MEDIA_LNK_FL_IMMUTABLE			BIT(1)
+#define MEDIA_LNK_FL_DYNAMIC			BIT(2)
 
 #define MEDIA_LNK_FL_LINK_TYPE			(0xf << 28)
 #  define MEDIA_LNK_FL_DATA_LINK		(0 << 28)
-#  define MEDIA_LNK_FL_INTERFACE_LINK		(1 << 28)
+#  define MEDIA_LNK_FL_INTERFACE_LINK		BIT(28)

This is wrong, BIT() should only be used for fields that are 1-bit wide. If you look at MEDIA_LNK_FL_LINK_TYPE you can see the field is 4-bits wide, it stores a value between 0 and 15. MEDIA_LNK_FL_INTERFACE_LINK happens to match the (1 << n) pattern, but it doesn't mean it's a single bit field.

include/uapi/linux/media.h struct media_v2_topology { · line 436

Quoted 9 lines
include/uapi/linux/media.h +1 -1
 struct media_link_desc {
 	struct media_pad_desc source;
@@ -433,7 +433,7 @@ struct media_v2_topology {
 #define MEDIA_INTF_T_ALSA_TIMER                (MEDIA_INTF_T_ALSA_BASE + 7)
 
 /* Obsolete symbol for media_version, no longer used in the kernel */
-#define MEDIA_API_VERSION			((0 << 16) | (1 << 8) | 0)
+#define MEDIA_API_VERSION			((0 << 16) | BIT(8) | 0)

Even worse here, this is clearly not a bitfield.

Quoted 3 lines
include/uapi/linux/media.h +0 -0
 #endif
 
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
In reply to Garrit Franke
Thank you for the patch! Perhaps something to improve:

Hi Garrit,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.8-rc6 next-20200724]
[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]

url:    https://github.com/0day-ci/linux/commits/Garrit-Franke/trivial-uapi-replace-bitshifts-with-BIT-macro/20200725-030550
base:   git://linuxtv.org/media_tree.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:404,
from include/linux/kernel.h:15,
from include/linux/list.h:9,
from include/linux/module.h:12,
from drivers/media/platform/video-mux.c:10:
drivers/media/platform/video-mux.c: In function 'video_mux_link_setup':

>> drivers/media/platform/video-mux.c:67:19: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat=]
      67 |  dev_dbg(sd->dev, "link setup '%s':%d->'%s':%d[%d]",
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
     125 |   func(&id, ##__VA_ARGS__);  \
         |               ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
     157 |  _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
         |  ^~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:115:2: note: in expansion of macro 'dynamic_dev_dbg'
     115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |  ^~~~~~~~~~~~~~~
   include/linux/dev_printk.h:115:23: note: in expansion of macro 'dev_fmt'
     115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                       ^~~~~~~
   drivers/media/platform/video-mux.c:67:2: note: in expansion of macro 'dev_dbg'
      67 |  dev_dbg(sd->dev, "link setup '%s':%d->'%s':%d[%d]",
         |  ^~~~~~~
   drivers/media/platform/video-mux.c:67:49: note: format string is defined here
      67 |  dev_dbg(sd->dev, "link setup '%s':%d->'%s':%d[%d]",
         |                                                ~^
         |                                                 |
         |                                                 int
         |                                                %ld

vim +67 drivers/media/platform/video-mux.c

68803ad4522f5de Philipp Zabel 2017-06-07   50  
68803ad4522f5de Philipp Zabel 2017-06-07   51  static int video_mux_link_setup(struct media_entity *entity,
68803ad4522f5de Philipp Zabel 2017-06-07   52  				const struct media_pad *local,
68803ad4522f5de Philipp Zabel 2017-06-07   53  				const struct media_pad *remote, u32 flags)
68803ad4522f5de Philipp Zabel 2017-06-07   54  {
68803ad4522f5de Philipp Zabel 2017-06-07   55  	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
68803ad4522f5de Philipp Zabel 2017-06-07   56  	struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
fd32d5349653139 Chris Lesiak  2018-04-03   57  	u16 source_pad = entity->num_pads - 1;
68803ad4522f5de Philipp Zabel 2017-06-07   58  	int ret = 0;
68803ad4522f5de Philipp Zabel 2017-06-07   59  
68803ad4522f5de Philipp Zabel 2017-06-07   60  	/*
68803ad4522f5de Philipp Zabel 2017-06-07   61  	 * The mux state is determined by the enabled sink pad link.
68803ad4522f5de Philipp Zabel 2017-06-07   62  	 * Enabling or disabling the source pad link has no effect.
68803ad4522f5de Philipp Zabel 2017-06-07   63  	 */
68803ad4522f5de Philipp Zabel 2017-06-07   64  	if (local->flags & MEDIA_PAD_FL_SOURCE)
68803ad4522f5de Philipp Zabel 2017-06-07   65  		return 0;
68803ad4522f5de Philipp Zabel 2017-06-07   66  
68803ad4522f5de Philipp Zabel 2017-06-07  @67  	dev_dbg(sd->dev, "link setup '%s':%d->'%s':%d[%d]",
68803ad4522f5de Philipp Zabel 2017-06-07   68  		remote->entity->name, remote->index, local->entity->name,
68803ad4522f5de Philipp Zabel 2017-06-07   69  		local->index, flags & MEDIA_LNK_FL_ENABLED);
68803ad4522f5de Philipp Zabel 2017-06-07   70  
68803ad4522f5de Philipp Zabel 2017-06-07   71  	mutex_lock(&vmux->lock);
68803ad4522f5de Philipp Zabel 2017-06-07   72  
68803ad4522f5de Philipp Zabel 2017-06-07   73  	if (flags & MEDIA_LNK_FL_ENABLED) {
68803ad4522f5de Philipp Zabel 2017-06-07   74  		if (vmux->active == local->index)
68803ad4522f5de Philipp Zabel 2017-06-07   75  			goto out;
68803ad4522f5de Philipp Zabel 2017-06-07   76  
68803ad4522f5de Philipp Zabel 2017-06-07   77  		if (vmux->active >= 0) {
68803ad4522f5de Philipp Zabel 2017-06-07   78  			ret = -EBUSY;
68803ad4522f5de Philipp Zabel 2017-06-07   79  			goto out;
68803ad4522f5de Philipp Zabel 2017-06-07   80  		}
68803ad4522f5de Philipp Zabel 2017-06-07   81  
68803ad4522f5de Philipp Zabel 2017-06-07   82  		dev_dbg(sd->dev, "setting %d active\n", local->index);
435945e08551ef0 Philipp Zabel 2017-07-18   83  		ret = mux_control_try_select(vmux->mux, local->index);
68803ad4522f5de Philipp Zabel 2017-06-07   84  		if (ret < 0)
68803ad4522f5de Philipp Zabel 2017-06-07   85  			goto out;
68803ad4522f5de Philipp Zabel 2017-06-07   86  		vmux->active = local->index;
fd32d5349653139 Chris Lesiak  2018-04-03   87  
fd32d5349653139 Chris Lesiak  2018-04-03   88  		/* Propagate the active format to the source */
fd32d5349653139 Chris Lesiak  2018-04-03   89  		vmux->format_mbus[source_pad] = vmux->format_mbus[vmux->active];
68803ad4522f5de Philipp Zabel 2017-06-07   90  	} else {
68803ad4522f5de Philipp Zabel 2017-06-07   91  		if (vmux->active != local->index)
68803ad4522f5de Philipp Zabel 2017-06-07   92  			goto out;
68803ad4522f5de Philipp Zabel 2017-06-07   93  
68803ad4522f5de Philipp Zabel 2017-06-07   94  		dev_dbg(sd->dev, "going inactive\n");
435945e08551ef0 Philipp Zabel 2017-07-18   95  		mux_control_deselect(vmux->mux);
68803ad4522f5de Philipp Zabel 2017-06-07   96  		vmux->active = -1;
68803ad4522f5de Philipp Zabel 2017-06-07   97  	}
68803ad4522f5de Philipp Zabel 2017-06-07   98  
68803ad4522f5de Philipp Zabel 2017-06-07   99  out:
68803ad4522f5de Philipp Zabel 2017-06-07  100  	mutex_unlock(&vmux->lock);
68803ad4522f5de Philipp Zabel 2017-06-07  101  	return ret;
68803ad4522f5de Philipp Zabel 2017-06-07  102  }
68803ad4522f5de Philipp Zabel 2017-06-07  103  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw
In reply to Garrit Franke
Thank you for the patch! Perhaps something to improve:

Hi Garrit,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.8-rc6 next-20200724]
[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]

url:    https://github.com/0day-ci/linux/commits/Garrit-Franke/trivial-uapi-replace-bitshifts-with-BIT-macro/20200725-030550
base:   git://linuxtv.org/media_tree.git master
config: x86_64-fedora-25 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/media/v4l2-subdev.h:15,

                    from include/media/v4l2-device.h:13,
                    from drivers/media/i2c/tvp5150.c:19:
   drivers/media/i2c/tvp5150.c: In function 'tvp5150_link_setup':
>> drivers/media/i2c/tvp5150.c:1329:33: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat=]
    1329 |  dev_dbg_lvl(sd->dev, 1, debug, "link setup '%s':%d->'%s':%d[%d]",
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/media/v4l2-common.h:51:34: note: in definition of macro 'dev_dbg_lvl'
      51 |    dev_printk(KERN_DEBUG, __dev, __fmt, ##__arg); \
         |                                  ^~~~~
   drivers/media/i2c/tvp5150.c:1329:63: note: format string is defined here
    1329 |  dev_dbg_lvl(sd->dev, 1, debug, "link setup '%s':%d->'%s':%d[%d]",
         |                                                              ~^
         |                                                               |
         |                                                               int
         |                                                              %ld
   In file included from include/media/v4l2-subdev.h:15,
                    from include/media/v4l2-device.h:13,
                    from drivers/media/i2c/tvp5150.c:19:
   drivers/media/i2c/tvp5150.c:1335:8: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat=]
    1335 |        "link setup '%s':%d->'%s':%d[%d]",
         |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/media/v4l2-common.h:51:34: note: in definition of macro 'dev_dbg_lvl'
      51 |    dev_printk(KERN_DEBUG, __dev, __fmt, ##__arg); \
         |                                  ^~~~~
   drivers/media/i2c/tvp5150.c:1335:38: note: format string is defined here
    1335 |        "link setup '%s':%d->'%s':%d[%d]",
         |                                     ~^
         |                                      |
         |                                      int
         |                                     %ld

vim +1329 drivers/media/i2c/tvp5150.c

0556f1d580d4c1d Marco Felsch 2020-03-12  1296  
0556f1d580d4c1d Marco Felsch 2020-03-12  1297  static int tvp5150_s_routing(struct v4l2_subdev *sd, u32 input, u32 output,
0556f1d580d4c1d Marco Felsch 2020-03-12  1298  			     u32 config);
0556f1d580d4c1d Marco Felsch 2020-03-12  1299  
0556f1d580d4c1d Marco Felsch 2020-03-12  1300  static int tvp5150_link_setup(struct media_entity *entity,
0556f1d580d4c1d Marco Felsch 2020-03-12  1301  			      const struct media_pad *tvp5150_pad,
0556f1d580d4c1d Marco Felsch 2020-03-12  1302  			      const struct media_pad *remote, u32 flags)
0556f1d580d4c1d Marco Felsch 2020-03-12  1303  {
0556f1d580d4c1d Marco Felsch 2020-03-12  1304  	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
0556f1d580d4c1d Marco Felsch 2020-03-12  1305  	struct tvp5150 *decoder = to_tvp5150(sd);
0556f1d580d4c1d Marco Felsch 2020-03-12  1306  	struct media_pad *other_tvp5150_pad =
0556f1d580d4c1d Marco Felsch 2020-03-12  1307  		&decoder->pads[tvp5150_pad->index ^ 1];
0556f1d580d4c1d Marco Felsch 2020-03-12  1308  	struct v4l2_fwnode_connector *v4l2c;
0556f1d580d4c1d Marco Felsch 2020-03-12  1309  	bool is_svideo = false;
0556f1d580d4c1d Marco Felsch 2020-03-12  1310  	unsigned int i;
0556f1d580d4c1d Marco Felsch 2020-03-12  1311  	int err;
0556f1d580d4c1d Marco Felsch 2020-03-12  1312  
0556f1d580d4c1d Marco Felsch 2020-03-12  1313  	/*
0556f1d580d4c1d Marco Felsch 2020-03-12  1314  	 * The TVP5150 state is determined by the enabled sink pad link(s).
0556f1d580d4c1d Marco Felsch 2020-03-12  1315  	 * Enabling or disabling the source pad link has no effect.
0556f1d580d4c1d Marco Felsch 2020-03-12  1316  	 */
0556f1d580d4c1d Marco Felsch 2020-03-12  1317  	if (tvp5150_pad->flags & MEDIA_PAD_FL_SOURCE)
0556f1d580d4c1d Marco Felsch 2020-03-12  1318  		return 0;
0556f1d580d4c1d Marco Felsch 2020-03-12  1319  
0556f1d580d4c1d Marco Felsch 2020-03-12  1320  	/* Check if the svideo connector should be enabled */
0556f1d580d4c1d Marco Felsch 2020-03-12  1321  	for (i = 0; i < decoder->connectors_num; i++) {
0556f1d580d4c1d Marco Felsch 2020-03-12  1322  		if (remote->entity == &decoder->connectors[i].ent) {
0556f1d580d4c1d Marco Felsch 2020-03-12  1323  			v4l2c = &decoder->connectors[i].base;
0556f1d580d4c1d Marco Felsch 2020-03-12  1324  			is_svideo = v4l2c->type == V4L2_CONN_SVIDEO;
0556f1d580d4c1d Marco Felsch 2020-03-12  1325  			break;
0556f1d580d4c1d Marco Felsch 2020-03-12  1326  		}
0556f1d580d4c1d Marco Felsch 2020-03-12  1327  	}
0556f1d580d4c1d Marco Felsch 2020-03-12  1328  
0556f1d580d4c1d Marco Felsch 2020-03-12 @1329  	dev_dbg_lvl(sd->dev, 1, debug, "link setup '%s':%d->'%s':%d[%d]",
0556f1d580d4c1d Marco Felsch 2020-03-12  1330  		    remote->entity->name, remote->index,
0556f1d580d4c1d Marco Felsch 2020-03-12  1331  		    tvp5150_pad->entity->name, tvp5150_pad->index,
0556f1d580d4c1d Marco Felsch 2020-03-12  1332  		    flags & MEDIA_LNK_FL_ENABLED);
0556f1d580d4c1d Marco Felsch 2020-03-12  1333  	if (is_svideo)
0556f1d580d4c1d Marco Felsch 2020-03-12  1334  		dev_dbg_lvl(sd->dev, 1, debug,
0556f1d580d4c1d Marco Felsch 2020-03-12  1335  			    "link setup '%s':%d->'%s':%d[%d]",
0556f1d580d4c1d Marco Felsch 2020-03-12  1336  			    remote->entity->name, remote->index,
0556f1d580d4c1d Marco Felsch 2020-03-12  1337  			    other_tvp5150_pad->entity->name,
0556f1d580d4c1d Marco Felsch 2020-03-12  1338  			    other_tvp5150_pad->index,
0556f1d580d4c1d Marco Felsch 2020-03-12  1339  			    flags & MEDIA_LNK_FL_ENABLED);
0556f1d580d4c1d Marco Felsch 2020-03-12  1340  
0556f1d580d4c1d Marco Felsch 2020-03-12  1341  	/*
0556f1d580d4c1d Marco Felsch 2020-03-12  1342  	 * The TVP5150 has an internal mux which allows the following setup:
0556f1d580d4c1d Marco Felsch 2020-03-12  1343  	 *
0556f1d580d4c1d Marco Felsch 2020-03-12  1344  	 * comp-connector1  --\
0556f1d580d4c1d Marco Felsch 2020-03-12  1345  	 *		       |---> AIP1A
0556f1d580d4c1d Marco Felsch 2020-03-12  1346  	 *		      /
0556f1d580d4c1d Marco Felsch 2020-03-12  1347  	 * svideo-connector -|
0556f1d580d4c1d Marco Felsch 2020-03-12  1348  	 *		      \
0556f1d580d4c1d Marco Felsch 2020-03-12  1349  	 *		       |---> AIP1B
0556f1d580d4c1d Marco Felsch 2020-03-12  1350  	 * comp-connector2  --/
0556f1d580d4c1d Marco Felsch 2020-03-12  1351  	 *
0556f1d580d4c1d Marco Felsch 2020-03-12  1352  	 * We can't rely on user space that the current connector gets disabled
0556f1d580d4c1d Marco Felsch 2020-03-12  1353  	 * first before enabling the new connector. Disable all active
0556f1d580d4c1d Marco Felsch 2020-03-12  1354  	 * connector links to be on the safe side.
0556f1d580d4c1d Marco Felsch 2020-03-12  1355  	 */
0556f1d580d4c1d Marco Felsch 2020-03-12  1356  	err = tvp5150_disable_all_input_links(decoder);
0556f1d580d4c1d Marco Felsch 2020-03-12  1357  	if (err)
0556f1d580d4c1d Marco Felsch 2020-03-12  1358  		return err;
0556f1d580d4c1d Marco Felsch 2020-03-12  1359  
0556f1d580d4c1d Marco Felsch 2020-03-12  1360  	tvp5150_s_routing(sd, is_svideo ? TVP5150_SVIDEO : tvp5150_pad->index,
0556f1d580d4c1d Marco Felsch 2020-03-12  1361  			  flags & MEDIA_LNK_FL_ENABLED ? TVP5150_NORMAL :
0556f1d580d4c1d Marco Felsch 2020-03-12  1362  			  TVP5150_BLACK_SCREEN, 0);
0556f1d580d4c1d Marco Felsch 2020-03-12  1363  
0556f1d580d4c1d Marco Felsch 2020-03-12  1364  	if (flags & MEDIA_LNK_FL_ENABLED) {
baf178219478c21 Marco Felsch 2020-03-12  1365  		struct v4l2_fwnode_connector_analog *v4l2ca;
baf178219478c21 Marco Felsch 2020-03-12  1366  		u32 new_norm;
baf178219478c21 Marco Felsch 2020-03-12  1367  
0556f1d580d4c1d Marco Felsch 2020-03-12  1368  		/*
0556f1d580d4c1d Marco Felsch 2020-03-12  1369  		 * S-Video connector is conneted to both ports AIP1A and AIP1B.
0556f1d580d4c1d Marco Felsch 2020-03-12  1370  		 * Both links must be enabled in one-shot regardless which link
0556f1d580d4c1d Marco Felsch 2020-03-12  1371  		 * the user requests.
0556f1d580d4c1d Marco Felsch 2020-03-12  1372  		 */
0556f1d580d4c1d Marco Felsch 2020-03-12  1373  		if (is_svideo) {
0556f1d580d4c1d Marco Felsch 2020-03-12  1374  			err = tvp5150_set_link((struct media_pad *)remote,
0556f1d580d4c1d Marco Felsch 2020-03-12  1375  					       other_tvp5150_pad, flags);
0556f1d580d4c1d Marco Felsch 2020-03-12  1376  			if (err)
0556f1d580d4c1d Marco Felsch 2020-03-12  1377  				return err;
0556f1d580d4c1d Marco Felsch 2020-03-12  1378  		}
baf178219478c21 Marco Felsch 2020-03-12  1379  
baf178219478c21 Marco Felsch 2020-03-12  1380  		if (!decoder->connectors_num)
baf178219478c21 Marco Felsch 2020-03-12  1381  			return 0;
baf178219478c21 Marco Felsch 2020-03-12  1382  
baf178219478c21 Marco Felsch 2020-03-12  1383  		/* Update the current connector */
baf178219478c21 Marco Felsch 2020-03-12  1384  		decoder->cur_connector =
baf178219478c21 Marco Felsch 2020-03-12  1385  			container_of(remote, struct tvp5150_connector, pad);
baf178219478c21 Marco Felsch 2020-03-12  1386  
baf178219478c21 Marco Felsch 2020-03-12  1387  		/*
baf178219478c21 Marco Felsch 2020-03-12  1388  		 * Do nothing if the new connector supports the same tv-norms as
baf178219478c21 Marco Felsch 2020-03-12  1389  		 * the old one.
baf178219478c21 Marco Felsch 2020-03-12  1390  		 */
baf178219478c21 Marco Felsch 2020-03-12  1391  		v4l2ca = &decoder->cur_connector->base.connector.analog;
baf178219478c21 Marco Felsch 2020-03-12  1392  		new_norm = decoder->norm & v4l2ca->sdtv_stds;
baf178219478c21 Marco Felsch 2020-03-12  1393  		if (decoder->norm == new_norm)
baf178219478c21 Marco Felsch 2020-03-12  1394  			return 0;
baf178219478c21 Marco Felsch 2020-03-12  1395  
baf178219478c21 Marco Felsch 2020-03-12  1396  		/*
baf178219478c21 Marco Felsch 2020-03-12  1397  		 * Fallback to the new connector tv-norms if we can't find any
baf178219478c21 Marco Felsch 2020-03-12  1398  		 * common between the current tv-norm and the new one.
baf178219478c21 Marco Felsch 2020-03-12  1399  		 */
baf178219478c21 Marco Felsch 2020-03-12  1400  		tvp5150_s_std(sd, new_norm ? new_norm : v4l2ca->sdtv_stds);
0556f1d580d4c1d Marco Felsch 2020-03-12  1401  	}
0556f1d580d4c1d Marco Felsch 2020-03-12  1402  
0556f1d580d4c1d Marco Felsch 2020-03-12  1403  	return 0;
0556f1d580d4c1d Marco Felsch 2020-03-12  1404  }
0556f1d580d4c1d Marco Felsch 2020-03-12  1405  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org