Define rotation property for camera sensors
Subsystems (2)
v2 cover Define rotation property for camera sensors
Hi,
Here's an update on my previous patchset adding an "upside-down" property. Instead of dropping the first patch entirely as I first thought, I decided to add documentation for the rotation property for sensors as well. The updates to the patches are related to that.
Sakari Ailus (2):
dt-bindings: media: Define "rotation" property for sensors
smiapp: Support the "upside-down" property
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ .../devicetree/bindings/media/video-interfaces.txt | 4 ++++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+)
Signature · 1 line
2.11.0
PATCH v2 1/2 dt-bindings: media: Define "rotation" property for sensors
Sensors are occasionally mounted upside down to systems such as mobile phones or tablets. In order to use such a sensor without having to turn every image upside down, most camera sensors support reversing the readout order by setting both horizontal and vertical flipping.
This patch documents the "rotation" property for camera sensors, mirroring what is defined for displays in Documentation/devicetree/bindings/display/panel/panel.txt .
--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/media/video-interfaces.txt +4 -0
@@ -85,6 +85,10 @@ Optional properties - lens-focus: A phandle to the node of the focus lens controller. +- rotation: The device, typically an image sensor, is not mounted upright, + but a number of degrees counter clockwise. Typical values are 0 and 180 + (upside down). + Optional endpoint properties ----------------------------
Signature · 1 line
2.11.0
PATCH v2 2/2 smiapp: Support the "upside-down" property
In reply to Sakari AilusUse the "upside-down" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
--- .../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2 -0
@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory properties
drivers/media/i2c/smiapp/smiapp-core.c +16 -0
@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;
@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"upside-down" , &rotation); +if (!rval) { +switch (rotation) { +case 180 : + hwcfg->module_board_orient = +SMIAPP_MODULE_BOARD_ORIENT_180 ; +/* Fall through */ +case 0 : +break ; +default : +dev_err (dev,"invalid rotation %u\n" , rotation); + goto out_err; + } + } +/* NVM size is not mandatory */ fwnode_property_read_u32 (fwnode,"nokia,nvm-size" , &hwcfg->nvm_size);
Signature · 1 line
2.11.0
PATCH v2 2/2 smiapp: Support the "rotation" property
Use the "rotation" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
---
since v2:
- Fix the property name in the commit message
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2 -0
@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory properties
drivers/media/i2c/smiapp/smiapp-core.c +16 -0
@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;
@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"upside-down" , &rotation); +if (!rval) { +switch (rotation) { +case 180 : + hwcfg->module_board_orient = +SMIAPP_MODULE_BOARD_ORIENT_180 ; +/* Fall through */ +case 0 : +break ; +default : +dev_err (dev,"invalid rotation %u\n" , rotation); + goto out_err; + } + } +/* NVM size is not mandatory */ fwnode_property_read_u32 (fwnode,"nokia,nvm-size" , &hwcfg->nvm_size);
Signature · 1 line
2.11.0
Re: [PATCH v2 2/2] smiapp: Support the "upside-down" property
In reply to Sakari AilusHi,
Quoted 6 lines · Sakari Ailus
Use the "upside-down" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
Signed-off-by Sakari Ailus <[email protected]>---
Patch subject and description should be s/"upside-down"/"rotation"/g ?
Quoted 30 lines
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2
-0@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory propertiesdrivers/media/i2c/smiapp/smiapp-core.c +1
-0@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;
drivers/media/i2c/smiapp/smiapp-core.c static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) · line 2804
Quoted 4 lines
drivers/media/i2c/smiapp/smiapp-core.c +1
-0@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"upside-down" , &rotation);
"rotation"
Quoted 6 lines
drivers/media/i2c/smiapp/smiapp-core.c +6
-0+if (!rval) { +switch (rotation) { +case 180 : + hwcfg->module_board_orient = +SMIAPP_MODULE_BOARD_ORIENT_180 ; +/* Fall through */
drivers/media/i2c/smiapp/smiapp-core.c static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) · line 2820
Quoted 10 lines
drivers/media/i2c/smiapp/smiapp-core.c +8
-0+case 0 : +break ; +default : +dev_err (dev,"invalid rotation %u\n" , rotation); + goto out_err; + } + } +/* NVM size is not mandatory */ fwnode_property_read_u32 (fwnode,"nokia,nvm-size" , &hwcfg->nvm_size);
-- Sebastian
PATCH v2 2/2 smiapp: Support the "rotation" property
In reply to Sakari AilusUse the "rotation" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
---
since v2.2:
- Fix property name in code.
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2 -0
@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory properties
drivers/media/i2c/smiapp/smiapp-core.c +16 -0
@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;
@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"rotation" , &rotation); +if (!rval) { +switch (rotation) { +case 180 : + hwcfg->module_board_orient = +SMIAPP_MODULE_BOARD_ORIENT_180 ; +/* Fall through */ +case 0 : +break ; +default : +dev_err (dev,"invalid rotation %u\n" , rotation); + goto out_err; + } + } +/* NVM size is not mandatory */ fwnode_property_read_u32 (fwnode,"nokia,nvm-size" , &hwcfg->nvm_size);
Signature · 1 line
2.11.0
Re: [PATCH v2 2/2] smiapp: Support the "upside-down" property
In reply to Sebastian ReichelQuoted 41 lines · Sebastian Reichel
Hi,
Quoted 6 lines · Sakari Ailus
Use the "upside-down" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
Signed-off-by Sakari Ailus <[email protected]>---
Patch subject and description should be s/"upside-down"/"rotation"/g ?
Quoted 29 lines
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2
-0@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory propertiesdrivers/media/i2c/smiapp/smiapp-core.c +1
-0@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;
Quoted 7 lines
drivers/media/i2c/smiapp/smiapp-core.c static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) · line 2804
Quoted 5 lines
drivers/media/i2c/smiapp/smiapp-core.c +1
-0@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"upside-down" , &rotation);"rotation"
Thanks. Both fixed in v2.2.
Signature · 2 lines
Sakari Ailus e-mail: [email protected]
Re: [PATCH v2 1/2] dt-bindings: media: Define "rotation" property for sensors
In reply to Sakari AilusHi,
Quoted 11 lines · Sakari Ailus
Sensors are occasionally mounted upside down to systems such as mobile phones or tablets. In order to use such a sensor without having to turn every image upside down, most camera sensors support reversing the readout order by setting both horizontal and vertical flipping.
This patch documents the "rotation" property for camera sensors, mirroring what is defined for displays in
Documentation/devicetree/bindings/display/panel/panel.txt.Signed-off-by Sakari Ailus <[email protected]>---
-- Sebastian
Quoted 21 lines
Documentation/devicetree/bindings/media/video-interfaces.txt | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/media/video-interfaces.txt +4
-0@@ -85,6 +85,10 @@ Optional properties - lens-focus: A phandle to the node of the focus lens controller. +- rotation: The device, typically an image sensor, is not mounted upright, + but a number of degrees counter clockwise. Typical values are 0 and 180 + (upside down). + Optional endpoint properties ----------------------------Signature · 1 line
2.11.0
Re: [PATCH v2.2 2/2] smiapp: Support the "rotation" property
In reply to Sakari AilusHi,
Quoted 6 lines · Sakari Ailus
Use the "rotation" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
Signed-off-by Sakari Ailus <[email protected]>---
-- Sebastian
Quoted 58 lines
since v2.2:
- Fix property name in code.
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++ drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)Documentation/devicetree/bindings/media/i2c/nokia,smia.txt +2
-0@@ -29,6 +29,8 @@ Optional properties - reset-gpios: XSHUTDOWN GPIO - flash-leds: See ../video-interfaces.txt - lens-focus: See ../video-interfaces.txt +- rotation: Integer property; valid values are 0 (sensor mounted upright) + and 180 (sensor mounted upside down). Endpoint node mandatory propertiesdrivers/media/i2c/smiapp/smiapp-core.c +16
-0@@ -2764,6 +2764,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)struct v4l2_fwnode_endpoint *bus_cfg;struct fwnode_handle *ep;struct fwnode_handle *fwnode =dev_fwnode (dev); +u32 rotation;int i;int rval;@@ -2800,6 +2801,21 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes); + rval =fwnode_property_read_u32 (fwnode,"rotation" , &rotation); +if (!rval) { +switch (rotation) { +case 180 : + hwcfg->module_board_orient = +SMIAPP_MODULE_BOARD_ORIENT_180 ; +/* Fall through */ +case 0 : +break ; +default : +dev_err (dev,"invalid rotation %u\n" , rotation); + goto out_err; + } + } +/* NVM size is not mandatory */ fwnode_property_read_u32 (fwnode,"nokia,nvm-size" , &hwcfg->nvm_size);Signature · 1 line
2.11.0
Re: [PATCH v2.2 2/2] smiapp: Support the "rotation" property
Quoted 11 lines · Sebastian Reichel
Hi,
Quoted 6 lines · Sakari Ailus
Use the "rotation" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
Signed-off-by Sakari Ailus <[email protected]>---
Reviewed-by Sebastian Reichel <[email protected]>
Danke sch�n!
Signature · 2 lines
Sakari Ailus [email protected]
Re: [PATCH v2 1/2] dt-bindings: media: Define "rotation" property for sensors
In reply to Sakari AilusQuoted 5 lines · Sakari Ailus
Sensors are occasionally mounted upside down to systems such as mobile phones or tablets. In order to use such a sensor without having to turn every image upside down, most camera sensors support reversing the readout order by setting both horizontal and vertical flipping.
Quoted 8 lines
This patch documents the "rotation" property for camera sensors, mirroring what is defined for displays in
Documentation/devicetree/bindings/display/panel/panel.txt.Signed-off-by Sakari Ailus <[email protected]>--- Documentation/devicetree/bindings/media/video-interfaces.txt | 4 ++++ 1 file changed, 4 insertions(+)
Re: [PATCH v2.2 2/2] smiapp: Support the "rotation" property
In reply to Sakari AilusQuoted 11 lines · Sakari Ailus
Use the "rotation" property to tell that the sensor is mounted upside down. This reverses the behaviour of the VFLIP and HFLIP controls as well as the pixel order.
Signed-off-by Sakari Ailus <[email protected]>---
since v2.2:- Fix property name in code.
.../devicetree/bindings/media/i2c/nokia,smia.txt | 2 ++
Quoted 2 lines
drivers/media/i2c/smiapp/smiapp-core.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)