Re: [RFC PATCH 09/15] PM / devfreq: exynos: Update documentation for bus devices using passive governor

2015-11-30 Thread Rob Herring
On Thu, Nov 26, 2015 at 10:47:33PM +0900, Chanwoo Choi wrote:
> This patch updates the documentation for passive bus devices and adds the
> detailed example of Exynos3250.
> 
> Signed-off-by: Chanwoo Choi 
> ---
>  .../devicetree/bindings/devfreq/exynos-bus.txt | 226 
> -
>  1 file changed, 223 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/devfreq/exynos-bus.txt 
> b/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
> index 5d90623bd173..c4a6fe30075e 100644
> --- a/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
> +++ b/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
> @@ -12,18 +12,23 @@ SoC has the different sub-blocks. So, this difference 
> should be specified
>  in devicetree file instead of each device driver. In result, this driver
>  is able to support the bus frequency for all Exynos SoCs.
>  
> -Required properties for bus device:
> +Required properties for all bus devices:
>  - compatible: Should be "samsung,exynos-bus".
>  - clock-names : the name of clock used by the bus, "bus".
>  - clocks : phandles for clock specified in "clock-names" property.
>  - #clock-cells: should be 1.
>  - operating-points-v2: the OPP table including frequency/voltage information
>to support DVFS (Dynamic Voltage/Frequency Scaling) feature.
> +
> +Required properties for only parent bus device:
>  - vdd-supply: the regulator to provide the buses with the voltage.
>  - devfreq-events: the devfreq-event device to monitor the curret utilization
>of buses.
>  
> -Optional properties for bus device:
> +Required properties for only passive bus device:
> +- devfreq: the parent bus device.
> +
> +Optional properties for only parent bus device:
>  - exynos,saturation-ratio: the percentage value which is used to calibrate
> the performance count againt total cycle count.
>  
> @@ -32,7 +37,19 @@ Example1:
>   power line (regulator). The MIF (Memory Interface) AXI bus is used to
>   transfer data between DRAM and CPU and uses the VDD_MIF regualtor.
>  
> - - power line(VDD_MIF) --> bus for DMC block (dmc clock)
> + - MIF (Memory Interface) block
> + : VDD_MIF |--- DMC
> +
> + - INT (Internal) block
> + : VDD_INT |--- LEFTBUS  |--- PERIL
> +   |(parent) |--- MFC
> +   | |--- G3D
> +   |
> +   |--- RIGHTBUS |--- FSYS
> + |--- LCD0
> + |--- PERIR
> + |--- ISP
> + |--- CAM

I would expect the DT to mirror this topology which doesn't seem to be 
the case in the example.


>   - MIF bus's frequency/voltage table
>   ---
> @@ -45,6 +62,20 @@ Example1:
>   |L5| 40 |875000   |
>   ---
>  
> + - INT bus's frequency/voltage table
> + ---
> + |Lv| Freq   | Voltage |
> + ---
> + |  |LEFTBUS|RIGHTBUS|LCD0   |FSYS   |MCUISP |ISP|PERIL  |VDD_INT  |
> + |  |*parent|passive |passive|passive|passive|passive|passive| |
> + ---
> + |L1|5  |5   |5  |5  |5  |5  |5  |90   |
> + |L2|8  |8   |8  |8  |8  |8  |8  |90   |
> + |L3|10 |10  |10 |10 |10 |10 |10 |100  |
> + |L4|133000 |133000  |133000 |133000 |20 |20 |   |100  |
> + |L5|20 |20  |20 |20 |40 |30 |   |100  |
> + ---

Do you really have 5 states? It look like there are 2 to me because the 
OPP tables only really need to have the max freq at each voltage point. 

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Mutharaju, Prasanna (P.)
Remove unneeded variable used to store return value.

Signed-off-by: Prasanna Karthik 

---
v3: Modified subject and changelog comments
---
---
 drivers/clk/samsung/clk-s3c2410-dclk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c 
b/drivers/clk/samsung/clk-s3c2410-dclk.c
index e9eb935..ec6fb14 100644
--- a/drivers/clk/samsung/clk-s3c2410-dclk.c
+++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
@@ -77,12 +77,11 @@ static u8 s3c24xx_clkout_get_parent(struct clk_hw *hw)
 static int s3c24xx_clkout_set_parent(struct clk_hw *hw, u8 index)
 {
struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw);
-   int ret = 0;
 
s3c2410_modify_misccr((clkout->mask << clkout->shift),
  (index << clkout->shift));
 
-   return ret;
+   return 0;
 }
 
 static const struct clk_ops s3c24xx_clkout_ops = {
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Mutharaju, Prasanna (P.)
On Mon, Nov 30, 2015 at 09:15:43AM +0100, Uwe Kleine-König wrote:
> On Mon, Nov 30, 2015 at 07:52:22AM +, Mutharaju, Prasanna (P.) wrote:
> > From: Prasanna Karthik 
> > 
> > Remove unneeded variable used to store return value.
> > ---
> > v3: Modified subject and changelog comments
> > ---
> > 
> > Signed-off-by: Prasanna Karthik 
> 
> Everything after the first triple-dash doesn't make it into the git
> history, so you are expected to write the S-o-b line above the list of
> things changed since a previous submission.

Thanks, I resent the patch again with S-o-b before changelog. 
> 
> Other than that the patch looks fine.
> 
> Uwe
> 
> -- 
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | http://www.pengutronix.de/  |--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Krzysztof Kozlowski
W dniu 30.11.2015 o 18:52, Mutharaju, Prasanna (P.) pisze:
> Remove unneeded variable used to store return value.
> 
> Signed-off-by: Prasanna Karthik 

Previous issues fixed, thanks! But now you changed the From field and it
does not match exactly the Signed-off-by (email matches but name does
not). Please fix this - signed-off-by should be the same as "From" (in
previous versions it was ok...).

Best regards,
Krzysztof

> 
> ---
> v3: Modified subject and changelog comments
> ---
> ---
>  drivers/clk/samsung/clk-s3c2410-dclk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c 
> b/drivers/clk/samsung/clk-s3c2410-dclk.c
> index e9eb935..ec6fb14 100644
> --- a/drivers/clk/samsung/clk-s3c2410-dclk.c
> +++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
> @@ -77,12 +77,11 @@ static u8 s3c24xx_clkout_get_parent(struct clk_hw *hw)
>  static int s3c24xx_clkout_set_parent(struct clk_hw *hw, u8 index)
>  {
>   struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw);
> - int ret = 0;
>  
>   s3c2410_modify_misccr((clkout->mask << clkout->shift),
> (index << clkout->shift));
>  
> - return ret;
> + return 0;
>  }
>  
>  static const struct clk_ops s3c24xx_clkout_ops = {
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Mutharaju, Prasanna (P.)
From: Prasanna Karthik 

Remove unneeded variable used to store return value.

Signed-off-by: Prasanna Karthik 

---
v3: Modified subject and changelog comments
---
---
 drivers/clk/samsung/clk-s3c2410-dclk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c 
b/drivers/clk/samsung/clk-s3c2410-dclk.c
index e9eb935..ec6fb14 100644
--- a/drivers/clk/samsung/clk-s3c2410-dclk.c
+++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
@@ -77,12 +77,11 @@ static u8 s3c24xx_clkout_get_parent(struct clk_hw *hw)
 static int s3c24xx_clkout_set_parent(struct clk_hw *hw, u8 index)
 {
struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw);
-   int ret = 0;
 
s3c2410_modify_misccr((clkout->mask << clkout->shift),
  (index << clkout->shift));
 
-   return ret;
+   return 0;
 }
 
 static const struct clk_ops s3c24xx_clkout_ops = {
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Krzysztof Kozlowski
2015-11-30 19:08 GMT+09:00 Mutharaju, Prasanna (P.) :
> From: Prasanna Karthik 
>
> Remove unneeded variable used to store return value.
>
> Signed-off-by: Prasanna Karthik 

Thanks,

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] arm: dts: Fix audio card detection on peach boards

2015-11-30 Thread Alim Akhtar
Hi Javier,

On Mon, Nov 30, 2015 at 7:31 PM, Javier Martinez Canillas
 wrote:
> Hello Alim,
>
> On 10/12/2015 09:37 AM, Alim Akhtar wrote:
>> Since commit 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards"),
>> sound card detection is broken on peach boards and gives below errors:
>>
>> [3.630457] max98090 7-0010: MAX98091 REVID=0x51
>> [3.634233] max98090 7-0010: use default 2.8v micbias
>> [3.640985] snow-audio sound: HiFi <-> 383.i2s mapping ok
>> [3.645307] max98090 7-0010: Invalid master clock frequency
>> [3.650824] snow-audio sound: ASoC: Peach-Pi-I2S-MAX98091 late_probe() 
>> failed: -22
>> [3.658914] snow-audio sound: snd_soc_register_card failed (-22)
>> [3.664366] snow-audio: probe of sound failed with error -22
>>
>> This patch adds missing assigned-clocks and assigned-clock-parents for
>> pmu_system_controller node which is used as "mclk" for audio codec.
>>
>> Signed-off-by: Alim Akhtar 
>> Fixes: 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards")
>
> I found that this patch is not enough to have proper audio working
> on an Exynos5800 Peach Pi. Even playing a simple wav does not work:
>
> $ time aplay -D sysdefault /usr/share/sounds/alsa/Front_Center.wav
> Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little 
> Endian, Rate 48000 Hz, Mono
>
> real0m1.138s
> user0m0.005s
> sys 0m0.005s
>
> This should be ~1.5 seconds so audio is processed faster than expected.
>
Did you tried playing any other file, like 128 KHz rate files etc..?
> So something else besides making the CLKOUT to provide a valid frequency
> for the codec's master clock is needed.
>
The $SUBJECT patch actually  fix the audio card detection issue, which
was failing because of the missing master clock.

> Do you know what's missing in mainline? For instance, I see that the
> sound/soc/samsung/snow.c ASoC machine driver doesn't have a hw_params
> but I'm not that familiar with ALSA to know if that makes sense or not.
>
I need to check this, currently I am out on a business travel, so
won't be able to check.
Probably we can go back to before "2fad972d45c4" and check that.

> Also, do you know if the "simple-audio-card" can be used instead for
> snow and peachs as it is used for other Exynos5 boards or a specific
> ASoC machine driver is really needed for these Chromebooks?
>
Not sure, AFAIR, I used machine driver on chromebooks (snow and peach).

> Best regards,
> --
> Javier Martinez Canillas
> Open Source Group
> Samsung Research America
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Regards,
Alim
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 14/22] drm/exynos: fimd: fix dma burst size setting for small plane size

2015-11-30 Thread Daniel Stone
Hi,

On 30 November 2015 at 13:53, Marek Szyprowski  wrote:
> This patch fixes trashed display of buffers cropped to very small width.
> Even if DMA is unstable and causes tearing when changing the burst size,
> it is still better than displaying a garbage.
>
> Signed-off-by: Marek Szyprowski 

Reviewed-by: Daniel Stone 

Cheers,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2] ARM: dts: use vmmc-supply of emmc/sd for exynos5422-odroidxu3

2015-11-30 Thread Anand Moon
Hi Krzysztof,

On 30 November 2015 at 11:12, Krzysztof Kozlowski
 wrote:
> On 27.11.2015 15:42, Anand Moon wrote:
>> hi Krzysztof,
>>
>> On 22 October 2015 at 18:34, Anand Moon  wrote:
>>> hi Krzysztof,
>>>
>>> On 22 October 2015 at 06:31, Krzysztof Kozlowski
>>>  wrote:
 On 20.10.2015 21:56, Anand Moon wrote:
> Changes need for host controller to detect UHS-I highspeed cards.
> Changes in VDDQ_MMC2 voltage range help scale
> the required voltage to detect and load the microSD cards.

 Thanks for updating description of commit.

>
> Signed-off-by: Anand Moon 
> ---
> Changes based on 
> git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git 
> v4.4-next/dt-samsung branch
>
> Changes:
> Drop the ranp_delay for LDO9.
>
> Thanks to : Krzysztof, Doug Anderson, Jaehoon Chung for helping
> me out figure out the mmc core requirement.
>
> Also drop the previous changes:
> use cd-gpio method to detect sd-card.
> Added UHS-I bus speed support.
>
> [4.713553] random: nonblocking pool is initialized
> [4.718423] 1453.hdmi supply hdmi-en not found, using dummy 
> regulator
> [4.726206] exynos-drm exynos-drm: bound 1440.fimd (ops 
> fimd_component_ops)
> [4.732555] exynos-drm exynos-drm: bound 1445.mixer (ops 
> mixer_component_ops)
> [4.740180] exynos-drm exynos-drm: bound 1453.hdmi (ops 
> hdmi_component_ops)
> [4.746936] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> [4.753428] [drm] No driver support for vblank timestamp query.
> [4.940794] Console: switching to colour frame buffer device 274x77
> [4.995344] exynos-drm exynos-drm: fb0:  frame buffer device
> [5.024573] [drm] Initialized exynos 1.0.0 20110530 on minor 0
> [5.031164] exynos-dwc3 usb@1200: no suspend clk specified
> [5.054571] usb 2-1: new full-speed USB device number 2 using 
> exynos-ohci
> [5.159527] dwmmc_exynos 1222.mmc: Busy; trying anyway
> [5.163705] mmc_host mmc1: Timeout sending command (cmd 0x202000 arg 
> 0x0 status 0x0)
> ---
>  arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi 
> b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
> index 1af5bdc..a4be3e0 100644
> --- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
> +++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
> @@ -182,9 +182,10 @@
>
>   ldo13_reg: LDO13 {
>   regulator-name = "vdd_ldo13";
> - regulator-min-microvolt = <280>;
> + regulator-min-microvolt = <180>;

 You did not convinced me in previous discussion about the change to
 1.8V. I said that:
> On the same diagram few lines below:
> VDDQ_MMC2: 2.8V 250mA

 You responded:
> You are correct.

 So I am confused. Are you sure that this SD card block can/should
 operate on 1.8V? Have you actually tried this?

>>>
>>> Look like I missed this point. Here is the link I would like to share.
>>>
>>> http://www.hjreggel.net/cardspeed/cs_sdxc.html
>>> Section: Summary of SD modes
>>>
>>> https://en.wikipedia.org/wiki/Secure_Digital
>>> Section: Power consumption
>>>
>>> Their different requirement for voltage requirement for UHS-I, the max
>>> value is around 3.3V
>>
>> Do you have any comment on this voltage selection for UHS-I card (1.8V).
>
> I asked whether you tried this, whether setting real 1.8V works fine.
> You did not respond. As you can see on Odroid schematics, the VDDQ for
> MMC[01] operates under 1.8V.
>
> The VDDQ for MMC2 - under 2.8V.
>
> In commit description you mentioned that this voltage "helps scale the
> required voltage to detect and load the microSD cards". What does it
> mean "help"? I would expect that detecting and loading of microSD cards
> either works or does not work. I am not sure how does it help.
>
> Best regards,
> Krzysztof

I will fix the commit message.

Earlier around v4.2 detection of UHS-I card was not working,but now it
seen to work in v4.4 kernel.
May be some driver issue which might have been fixed.

I am just trying to set the voltage range for LDO13 from 1.8V (min) to
2.8V (max).
If setting this is wrong according to datasheet then I will drop this setting.

-Anand Moon
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] arm: dts: Fix audio card detection on peach boards

2015-11-30 Thread Javier Martinez Canillas
Hi Alim,

On 11/30/2015 01:59 PM, Alim Akhtar wrote:
> Hi Javier,
> 
> On Mon, Nov 30, 2015 at 7:31 PM, Javier Martinez Canillas
>  wrote:
>> Hello Alim,
>>
>> On 10/12/2015 09:37 AM, Alim Akhtar wrote:
>>> Since commit 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards"),
>>> sound card detection is broken on peach boards and gives below errors:
>>>
>>> [3.630457] max98090 7-0010: MAX98091 REVID=0x51
>>> [3.634233] max98090 7-0010: use default 2.8v micbias
>>> [3.640985] snow-audio sound: HiFi <-> 383.i2s mapping ok
>>> [3.645307] max98090 7-0010: Invalid master clock frequency
>>> [3.650824] snow-audio sound: ASoC: Peach-Pi-I2S-MAX98091 late_probe() 
>>> failed: -22
>>> [3.658914] snow-audio sound: snd_soc_register_card failed (-22)
>>> [3.664366] snow-audio: probe of sound failed with error -22
>>>
>>> This patch adds missing assigned-clocks and assigned-clock-parents for
>>> pmu_system_controller node which is used as "mclk" for audio codec.
>>>
>>> Signed-off-by: Alim Akhtar 
>>> Fixes: 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards")
>>
>> I found that this patch is not enough to have proper audio working
>> on an Exynos5800 Peach Pi. Even playing a simple wav does not work:
>>
>> $ time aplay -D sysdefault /usr/share/sounds/alsa/Front_Center.wav
>> Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit 
>> Little Endian, Rate 48000 Hz, Mono
>>
>> real0m1.138s
>> user0m0.005s
>> sys 0m0.005s
>>
>> This should be ~1.5 seconds so audio is processed faster than expected.
>>
> Did you tried playing any other file, like 128 KHz rate files etc..?

Yes, I see the same problem with all the files I tested.

>> So something else besides making the CLKOUT to provide a valid frequency
>> for the codec's master clock is needed.
>>
> The $SUBJECT patch actually  fix the audio card detection issue, which
> was failing because of the missing master clock.
>

I thought the problem was not a missing master clock, but an invalid clock
frequency. Since the error message in the patch change log was:

"max98090 7-0010: Invalid master clock frequency"

But what I tried to ask was what else was missing to have playback working.

>> Do you know what's missing in mainline? For instance, I see that the
>> sound/soc/samsung/snow.c ASoC machine driver doesn't have a hw_params
>> but I'm not that familiar with ALSA to know if that makes sense or not.
>>
> I need to check this, currently I am out on a business travel, so
> won't be able to check.

No worries, I was asked in case you had more information. Audio is the
only thing that is missing to have all peripherals working correctly with
mainline.

> Probably we can go back to before "2fad972d45c4" and check that.
>

Do you mean to revert $SUBJECT and "2fad972d45c4" to see if the bootloader
sets this correctly? If I revert both patches then I have no audio at all.
 
>> Also, do you know if the "simple-audio-card" can be used instead for
>> snow and peachs as it is used for other Exynos5 boards or a specific
>> ASoC machine driver is really needed for these Chromebooks?
>>
> Not sure, AFAIR, I used machine driver on chromebooks (snow and peach).
>

Yes, the downstream 3.8 ChromiumOS tree has also a machine driver but I
don't see a simple-audio-card in that tree so it seems that predates it.

-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/10] ASoC: samsung/smartq: use dynamic registration

2015-11-30 Thread Krzysztof Kozlowski
On 26.11.2015 01:06, Arnd Bergmann wrote:
> As a prerequisite for moving s3c64xx into multiplatform configurations,
> we need to change the smartq audio driver to stop using hardcoded
> gpio numbers from the header file, and instead pass the gpio data
> through platform_data.
> 
> In order to do that, we also move the code to use module_platform_driver
> and register the platform device using platform_device_register_simple
> and register the gpios through the gpiod API.
> 
> Signed-off-by: Arnd Bergmann 
> Acked-by: Mark Brown 
> ---
>  arch/arm/mach-s3c64xx/mach-smartq.c | 13 +++
>  sound/soc/samsung/smartq_wm8987.c   | 77 
> +
>  2 files changed, 40 insertions(+), 50 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
> b/arch/arm/mach-s3c64xx/mach-smartq.c
> index acdfb5fac40f..96784e7f894a 100644
> --- a/arch/arm/mach-s3c64xx/mach-smartq.c
> +++ b/arch/arm/mach-s3c64xx/mach-smartq.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -383,6 +384,15 @@ void __init smartq_map_io(void)
>   smartq_lcd_mode_set();
>  }
>  
> +static struct gpiod_lookup_table smartq_audio_gpios = {
> + .dev_id = "smartq-audio",
> + .table = {
> + GPIO_LOOKUP("GPL", 12, "headphone detect", 0),
> + GPIO_LOOKUP("GPK", 12, "amplifiers shutdown", 0),
> + { },
> + },
> +};
> +
>  void __init smartq_machine_init(void)
>  {
>   s3c_i2c0_set_platdata(NULL);
> @@ -402,4 +412,7 @@ void __init smartq_machine_init(void)
>  
>   pwm_add_table(smartq_pwm_lookup, ARRAY_SIZE(smartq_pwm_lookup));
>   platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices));
> +
> + gpiod_add_lookup_table(_audio_gpios);
> + platform_device_register_simple("smartq-audio", -1, NULL, 0);
>  }
> diff --git a/sound/soc/samsung/smartq_wm8987.c 
> b/sound/soc/samsung/smartq_wm8987.c
> index a0fe37fbed9f..c6769b16eb19 100644
> --- a/sound/soc/samsung/smartq_wm8987.c
> +++ b/sound/soc/samsung/smartq_wm8987.c
> @@ -13,15 +13,12 @@
>   *
>   */
>  
> -#include 
> +#include 
>  #include 
>  
>  #include 
>  #include 
>  
> -#include 
> -#include 
> -
>  #include "i2s.h"
>  #include "../codecs/wm8750.h"
>  
> @@ -96,7 +93,7 @@ static struct snd_soc_jack_pin smartq_jack_pins[] = {
>  
>  static struct snd_soc_jack_gpio smartq_jack_gpios[] = {
>   {
> - .gpio   = S3C64XX_GPL(12),
> + .gpio   = -1,
>   .name   = "headphone detect",
>   .report = SND_JACK_HEADPHONE,
>   .debounce_time  = 200,
> @@ -113,7 +110,9 @@ static int smartq_speaker_event(struct 
> snd_soc_dapm_widget *w,
>   struct snd_kcontrol *k,
>   int event)
>  {
> - gpio_set_value(S3C64XX_GPK(12), SND_SOC_DAPM_EVENT_OFF(event));
> + struct gpio_desc *gpio = snd_soc_card_get_drvdata(_soc_smartq);
> +
> + gpiod_set_value(gpio, SND_SOC_DAPM_EVENT_OFF(event));
>  
>   return 0;
>  }
> @@ -199,62 +198,40 @@ static struct snd_soc_card snd_soc_smartq = {
>   .num_controls = ARRAY_SIZE(wm8987_smartq_controls),
>  };
>  
> -static struct platform_device *smartq_snd_device;
> -
> -static int __init smartq_init(void)
> +static int smartq_probe(struct platform_device *pdev)
>  {
> + struct gpio_desc *gpio;
>   int ret;
>  
> - if (!machine_is_smartq7() && !machine_is_smartq5()) {
> - pr_info("Only SmartQ is supported by this ASoC driver\n");
> - return -ENODEV;
> - }
> -
> - smartq_snd_device = platform_device_alloc("soc-audio", -1);
> - if (!smartq_snd_device)
> - return -ENOMEM;
> -
> - platform_set_drvdata(smartq_snd_device, _soc_smartq);
> -
> - ret = platform_device_add(smartq_snd_device);
> - if (ret) {
> - platform_device_put(smartq_snd_device);
> - return ret;
> - }
> + platform_set_drvdata(pdev, _soc_smartq);
>  
>   /* Initialise GPIOs used by amplifiers */
> - ret = gpio_request(S3C64XX_GPK(12), "amplifiers shutdown");
> - if (ret) {
> - dev_err(_snd_device->dev, "Failed to register GPK12\n");
> - goto err_unregister_device;
> + gpio = devm_gpiod_get(>dev, "amplifiers shutdown",
> +   GPIOD_OUT_HIGH);
> + if (IS_ERR(gpio)) {
> + dev_err(>dev, "Failed to register GPK12\n");
> + ret = PTR_ERR(gpio);
> + goto out;
>   }
> + snd_soc_card_set_drvdata(_soc_smartq, gpio);
>  
> - /* Disable amplifiers */
> - ret = gpio_direction_output(S3C64XX_GPK(12), 1);
> - if (ret) {
> - dev_err(_snd_device->dev, "Failed to configure GPK12\n");
> - goto err_free_gpio_amp_shut;
> - }
> -
> - return 0;
> -
> -err_free_gpio_amp_shut:
> - gpio_free(S3C64XX_GPK(12));
> 

Re: [PATCH 03/10] gpio: samsung: move gpio-samsung driver back to platform code

2015-11-30 Thread Krzysztof Kozlowski
On 26.11.2015 01:06, Arnd Bergmann wrote:
> The gpio-samsung driver is special in the sense that it
> interacts directly in multiple ways with the legacy platform
> code for the s3c24xx and s3c64xx platforms. In contrast,
> all devicetree based machines for Samsung, including the
> ones on those two SoC families use a different driver.
> 
> The header files that define the interface between the platform
> code and the gpio driver are not visible when building a
> kernel for ARCH_MULTIPLATFORM, which prevents us from
> turning on this option for s3c64xx.
> 
> To work around this, we now move the driver back into platform
> code, from where it was originally moved to as part of commit
> 1b39d5f2cc5c28 ("gpio/samsung: gpio-samsung.c to support
> Samsung GPIOs").
> 
> The long-term plan for this driver would be to remove it
> entirely, after all Samsung machines have been converted
> over to boot from DT, but there is currently no timeline
> for when that might happen.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm/plat-samsung/Kconfig  | 3 +++
>  arch/arm/plat-samsung/Makefile | 2 ++
>  {drivers/gpio => arch/arm/plat-samsung}/gpio-samsung.c | 0
>  drivers/gpio/Kconfig   | 7 ---
>  drivers/gpio/Makefile  | 1 -
>  5 files changed, 5 insertions(+), 8 deletions(-)
>  rename {drivers/gpio => arch/arm/plat-samsung}/gpio-samsung.c (100%)
> 
> diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
> index 57729b915003..83697414bfa0 100644
> --- a/arch/arm/plat-samsung/Kconfig
> +++ b/arch/arm/plat-samsung/Kconfig
> @@ -294,6 +294,9 @@ config SAMSUNG_WDT_RESET
> Compile support for system restart by triggering watchdog reset.
> Used on SoCs that do not provide dedicated reset control.
>  
> +config GPIO_SAMSUNG
> + def_bool SAMSUNG_ATAGS
> +

I think this should be put inside "if SAMSUNG_ATAGS" section, just
before SAMSUNG_PM_GPIO (with default=y?). It makes more consistent with
rest of the options depending on ATAGS.

Rest seems fine:
Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/10] ARM: s3c64xx: prepare initcalls for multiplatform

2015-11-30 Thread Krzysztof Kozlowski
On 26.11.2015 01:06, Arnd Bergmann wrote:
> In a multiplatform kernel, each initcall is run regardless
> of the platform it is meant for, so it must not attempt to
> access SoC-specific registers.
> 
> This adds 'if (soc_is_s3c64xx)' to all initcalls that are
> specific to the s3c64xx platform, to prevent them from breaking
> other platforms once we can build them into a combined kernel.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm/mach-s3c64xx/common.c   |  4 ++--
>  arch/arm/mach-s3c64xx/cpuidle.c  |  5 -
>  arch/arm/mach-s3c64xx/irq-pm.c   |  2 +-
>  arch/arm/mach-s3c64xx/mach-crag6410-module.c |  4 
>  arch/arm/mach-s3c64xx/pl080.c|  4 
>  arch/arm/mach-s3c64xx/pm.c   |  4 
>  arch/arm/mach-s3c64xx/s3c6400.c  |  2 +-
>  arch/arm/mach-s3c64xx/s3c6410.c  |  2 +-
>  arch/arm/plat-samsung/gpio-samsung.c | 11 +--
>  arch/arm/plat-samsung/init.c |  5 +
>  10 files changed, 31 insertions(+), 12 deletions(-)

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/10] Input: s3c2410_ts: fix S3C_ADC dependency

2015-11-30 Thread Krzysztof Kozlowski
On 26.11.2015 01:06, Arnd Bergmann wrote:
> S3C_ADC is only available on machines that don't do ARCH_MULTIPLATFORM,
> so changing the 'select' into 'depends on' here helps us move to
> ARCH_MULTIPLATFORM without introducing regressions.
> 
> Signed-off-by: Arnd Bergmann 
> Acked-by: Dmitry Torokhov 
> ---
>  drivers/input/touchscreen/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Krzysztof Kozlowski
On 30.11.2015 16:52, Mutharaju, Prasanna (P.) wrote:
> From: Prasanna Karthik 
> 
> Remove unneeded variable used to store return value.
> ---
> v3: Modified subject and changelog comments
> ---
> 
> Signed-off-by: Prasanna Karthik 

... and now download the patch and try to apply it with "git am". What
is missing? :)

Best regards,
Krzysztof

> ---
>  drivers/clk/samsung/clk-s3c2410-dclk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c 
> b/drivers/clk/samsung/clk-s3c2410-dclk.c
> index e9eb935..ec6fb14 100644
> --- a/drivers/clk/samsung/clk-s3c2410-dclk.c
> +++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
> @@ -77,12 +77,11 @@ static u8 s3c24xx_clkout_get_parent(struct clk_hw *hw)
>  static int s3c24xx_clkout_set_parent(struct clk_hw *hw, u8 index)
>  {
>   struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw);
> - int ret = 0;
>  
>   s3c2410_modify_misccr((clkout->mask << clkout->shift),
> (index << clkout->shift));
>  
> - return ret;
> + return 0;
>  }
>  
>  static const struct clk_ops s3c24xx_clkout_ops = {
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Mutharaju, Prasanna (P.)
On Mon, Nov 30, 2015 at 04:31:35PM +0900, Krzysztof Kozlowski wrote:
> On 30.11.2015 16:28, Mutharaju, Prasanna (P.) wrote:
> > From: Prasanna Karthik 
> > 
> > Remove unneeded variable used to store return value.
> > V2: Modified subject  
> 
> Changelog (v2) should go after '---' separator so it won't get included
> in the commit message.
> 

Done in v3. 

> Now I see that you Signed-off-by is okay - same email address... I got
> confused by the difference in name.

Yeah, my gitconfig and outlook account differ little. 

> Best regards,
> Krzysztof
> > 
> > Signed-off-by: Prasanna Karthik 
> > ---
> >  drivers/clk/samsung/clk-s3c2410-dclk.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/clk/samsung/clk-s3c2410-dclk.c 
> > b/drivers/clk/samsung/clk-s3c2410-dclk.c
> > index e9eb935..ec6fb14 100644
> > --- a/drivers/clk/samsung/clk-s3c2410-dclk.c
> > +++ b/drivers/clk/samsung/clk-s3c2410-dclk.c
> > @@ -77,12 +77,11 @@ static u8 s3c24xx_clkout_get_parent(struct clk_hw *hw)
> >  static int s3c24xx_clkout_set_parent(struct clk_hw *hw, u8 index)
> >  {
> > struct s3c24xx_clkout *clkout = to_s3c24xx_clkout(hw);
> > -   int ret = 0;
> >  
> > s3c2410_modify_misccr((clkout->mask << clkout->shift),
> >   (index << clkout->shift));
> >  
> > -   return ret;
> > +   return 0;
> >  }
> >  
> >  static const struct clk_ops s3c24xx_clkout_ops = {
> > 
> --
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: s3c2410: removed unneeded variable in s3c24xx_clkout_set_parent

2015-11-30 Thread Uwe Kleine-König
On Mon, Nov 30, 2015 at 07:52:22AM +, Mutharaju, Prasanna (P.) wrote:
> From: Prasanna Karthik 
> 
> Remove unneeded variable used to store return value.
> ---
> v3: Modified subject and changelog comments
> ---
> 
> Signed-off-by: Prasanna Karthik 

Everything after the first triple-dash doesn't make it into the git
history, so you are expected to write the S-o-b line above the list of
things changed since a previous submission.

Other than that the patch looks fine.

Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: exynos_defconfig: Set recommended options for systemd

2015-11-30 Thread Javier Martinez Canillas
Hello Krzysztof,

On 11/30/2015 03:31 AM, Krzysztof Kozlowski wrote:
> Set following options to recommended value by systemd (which also
> matches the multi_v7 deconfig):
> 1. Enable AUTOFS4_FS - for systemd.automount [0];
> 2. Enable BLK_DEV_BSG - SG v4 for recend udev [0][1];
> 3. Disable UEVENT_HELPER_PATH - legacy hook for hotplug, forked for each
>uevent, slows down booting [0];
> 
> [0] http://cgit.freedesktop.org/systemd/systemd/tree/README
> [1] http://patchwork.ozlabs.org/patch/47921/
> 
> Signed-off-by: Krzysztof Kozlowski 
> ---
>  arch/arm/configs/exynos_defconfig | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Reviewed-by: Javier Martinez Canillas 

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/22] drm/exynos: gsc: prepare and unprepare gsc clock

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

Ths patch changes the clk_enable and clk_disable call in gsc driver
into clk_prepare_enable and clk_disable_unprepare.

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 11b87d2a7913..72a9c84e06b6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -1215,10 +1215,10 @@ static int gsc_clk_ctrl(struct gsc_context *ctx, bool 
enable)
DRM_DEBUG_KMS("enable[%d]\n", enable);
 
if (enable) {
-   clk_enable(ctx->gsc_clk);
+   clk_prepare_enable(ctx->gsc_clk);
ctx->suspended = false;
} else {
-   clk_disable(ctx->gsc_clk);
+   clk_disable_unprepare(ctx->gsc_clk);
ctx->suspended = true;
}
 
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/22] drm/exynos: gsc: fix wrong pm_runtime state

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

At probe time, gsc clock is not enabled, so pm_runtime state should
be deactive. So this patch removes pm_runtime_set_active() from
gsc_probe().

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 72a9c84e06b6..ed55d37b6330 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -1713,7 +1713,6 @@ static int gsc_probe(struct platform_device *pdev)
mutex_init(>lock);
platform_set_drvdata(pdev, ctx);
 
-   pm_runtime_set_active(dev);
pm_runtime_enable(dev);
 
ret = exynos_drm_ippdrv_register(ippdrv);
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 14/22] drm/exynos: fimd: fix dma burst size setting for small plane size

2015-11-30 Thread Marek Szyprowski
This patch fixes trashed display of buffers cropped to very small width.
Even if DMA is unstable and causes tearing when changing the burst size,
it is still better than displaying a garbage.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 70cd2681e343..2e2247126581 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -487,7 +487,7 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)
 
 
 static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win,
-   struct drm_framebuffer *fb)
+   uint32_t pixel_format, int width)
 {
unsigned long val;
 
@@ -498,11 +498,11 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, 
unsigned int win,
 * So the request format is ARGB then change it to XRGB.
 */
if (ctx->driver_data->has_limited_fmt && !win) {
-   if (fb->pixel_format == DRM_FORMAT_ARGB)
-   fb->pixel_format = DRM_FORMAT_XRGB;
+   if (pixel_format == DRM_FORMAT_ARGB)
+   pixel_format = DRM_FORMAT_XRGB;
}
 
-   switch (fb->pixel_format) {
+   switch (pixel_format) {
case DRM_FORMAT_C8:
val |= WINCON0_BPPMODE_8BPP_PALETTE;
val |= WINCONx_BURSTLEN_8WORD;
@@ -538,17 +538,15 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, 
unsigned int win,
break;
}
 
-   DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);
-
/*
-* In case of exynos, setting dma-burst to 16Word causes permanent
-* tearing for very small buffers, e.g. cursor buffer. Burst Mode
-* switching which is based on plane size is not recommended as
-* plane size varies alot towards the end of the screen and rapid
-* movement causes unstable DMA which results into iommu crash/tear.
+* Setting dma-burst to 16Word causes permanent tearing for very small
+* buffers, e.g. cursor buffer. Burst Mode switching which based on
+* plane size is not recommended as plane size varies alot towards the
+* end of the screen and rapid movement causes unstable DMA, but it is
+* still better to change dma-burst than displaying garbage.
 */
 
-   if (fb->width < MIN_FB_WIDTH_FOR_16WORD_BURST) {
+   if (width < MIN_FB_WIDTH_FOR_16WORD_BURST) {
val &= ~WINCONx_BURSTLEN_MASK;
val |= WINCONx_BURSTLEN_4WORD;
}
@@ -723,7 +721,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val);
}
 
-   fimd_win_set_pixfmt(ctx, win, fb);
+   fimd_win_set_pixfmt(ctx, win, fb->pixel_format, state->src.w);
 
/* hardware window 0 doesn't support color key. */
if (win != 0)
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 21/22] drm/exynos: ipp: make framework context global

2015-11-30 Thread Marek Szyprowski
IPP framework stored global context in driver data of its platform device.
This patch moves it to global variable to simplify access. There exists
only one such framework, so there is no drawback of this change.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 50 ++---
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 0404e18d84cc..44a6689e0f4c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -42,7 +42,6 @@
  * 7. need to power_on implement power and sysmmu ctrl.
  */
 
-#define get_ipp_context(dev)   platform_get_drvdata(to_platform_device(dev))
 #define ipp_is_m2m_cmd(c)  (c == IPP_CMD_M2M)
 
 /*
@@ -95,6 +94,7 @@ struct ipp_context {
struct workqueue_struct *cmd_workq;
 };
 
+static struct ipp_context *ctx;
 static LIST_HEAD(exynos_drm_ippdrv_list);
 static DEFINE_MUTEX(exynos_drm_ippdrv_lock);
 static BLOCKING_NOTIFIER_HEAD(exynos_drm_ippnb_list);
@@ -226,9 +226,6 @@ static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 
prop_id)
 int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_prop_list *prop_list = data;
struct exynos_drm_ippdrv *ippdrv;
int count = 0;
@@ -320,9 +317,6 @@ static struct drm_exynos_ipp_event_work 
*ipp_create_event_work(void)
 int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_property *property = data;
struct exynos_drm_ippdrv *ippdrv;
struct drm_exynos_ipp_cmd_node *c_node;
@@ -803,22 +797,18 @@ static int ipp_set_mem_node(struct exynos_drm_ippdrv 
*ippdrv,
return ret;
 }
 
-static void ipp_handle_cmd_work(struct device *dev,
-   struct exynos_drm_ippdrv *ippdrv,
-   struct drm_exynos_ipp_cmd_work *cmd_work,
-   struct drm_exynos_ipp_cmd_node *c_node)
+static void ipp_handle_cmd_work(struct exynos_drm_ippdrv *ippdrv,
+   struct drm_exynos_ipp_cmd_work *cmd_work,
+   struct drm_exynos_ipp_cmd_node *c_node)
 {
-   struct ipp_context *ctx = get_ipp_context(dev);
-
cmd_work->ippdrv = ippdrv;
cmd_work->c_node = c_node;
queue_work(ctx->cmd_workq, _work->work);
 }
 
-static int ipp_queue_buf_with_run(struct device *dev,
-   struct drm_exynos_ipp_cmd_node *c_node,
-   struct drm_exynos_ipp_mem_node *m_node,
-   struct drm_exynos_ipp_queue_buf *qbuf)
+static int ipp_queue_buf_with_run(struct drm_exynos_ipp_cmd_node *c_node,
+ struct drm_exynos_ipp_mem_node *m_node,
+ struct drm_exynos_ipp_queue_buf *qbuf)
 {
struct exynos_drm_ippdrv *ippdrv;
struct drm_exynos_ipp_property *property;
@@ -859,7 +849,7 @@ static int ipp_queue_buf_with_run(struct device *dev,
struct drm_exynos_ipp_cmd_work *cmd_work = c_node->start_work;
 
cmd_work->ctrl = IPP_CTRL_PLAY;
-   ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+   ipp_handle_cmd_work(ippdrv, cmd_work, c_node);
} else {
ret = ipp_set_mem_node(ippdrv, c_node, m_node);
if (ret) {
@@ -893,9 +883,6 @@ static void ipp_clean_queue_buf(struct drm_device *drm_dev,
 int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_queue_buf *qbuf = data;
struct drm_exynos_ipp_cmd_node *c_node;
struct drm_exynos_ipp_mem_node *m_node;
@@ -950,7 +937,7 @@ int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, 
void *data,
 * M2M case run play control for streaming feature.
 * other case set address and waiting.
 */
-   ret = ipp_queue_buf_with_run(dev, c_node, m_node, qbuf);
+   ret = ipp_queue_buf_with_run(c_node, m_node, qbuf);
if (ret) {
DRM_ERROR("failed to run command.\n");
goto err_clean_node;
@@ -1024,10 +1011,7 @@ err_status:
 int 

[PATCH v2 18/22] drm/exynos: fix to calculate offset of each plane for ipp fimc

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

NV12 and YUV420 formats are need to calculate offset of each plane
for ipp fimc in a gem buffer. Without proper offset, only Y plane
can be processed, so result shows green frame.
This patch fixes to calculate offset for cbcr planes for NV12 and
YUV420 formats.

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_fimc.c | 106 +++
 drivers/gpu/drm/exynos/exynos_drm_ipp.c  |  15 -
 drivers/gpu/drm/exynos/exynos_drm_ipp.h  |   2 +
 3 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index c747824f3c98..72a7ca188be5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -403,6 +403,97 @@ static void fimc_handle_lastend(struct fimc_context *ctx, 
bool enable)
fimc_write(ctx, cfg, EXYNOS_CIOCTRL);
 }
 
+static int fimc_set_planar_addr(struct drm_exynos_ipp_buf_info *buf_info,
+   u32 fmt, struct drm_exynos_sz *sz)
+{
+   dma_addr_t *base[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t size[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t ofs[EXYNOS_DRM_PLANAR_MAX];
+   bool bypass = false;
+   uint64_t tsize = 0;
+   int i;
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+   ofs[i] = 0;
+   tsize += size[i];
+   }
+
+   if (!tsize) {
+   DRM_INFO("%s:failed to get buffer size.\n", __func__);
+   return 0;
+   }
+
+   switch (fmt) {
+   case DRM_FORMAT_NV12:
+   case DRM_FORMAT_NV21:
+   case DRM_FORMAT_NV16:
+   case DRM_FORMAT_NV61:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[0] >> 1;
+   if (*base[0] && *base[1]) {
+   if (size[0] + size[1] < ofs[0] + ofs[1])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_YUV410:
+   case DRM_FORMAT_YVU410:
+   case DRM_FORMAT_YUV411:
+   case DRM_FORMAT_YVU411:
+   case DRM_FORMAT_YUV420:
+   case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   case DRM_FORMAT_YUV444:
+   case DRM_FORMAT_YVU444:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[2] = ofs[0] >> 2;
+   if (*base[0] && *base[1] && *base[2]) {
+   if (size[0]+size[1]+size[2] < ofs[0]+ofs[1]+ofs[2])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_XRGB:
+   case DRM_FORMAT_ARGB:
+   ofs[0] = sz->hsize * sz->vsize << 2;
+   if (*base[0]) {
+   if (size[0] < ofs[0])
+   goto err_info;
+   }
+   bypass = true;
+   break;
+   default:
+   bypass = true;
+   break;
+   }
+
+   if (!bypass) {
+   *base[1] = *base[0] + ofs[0];
+   if (ofs[1] && ofs[2])
+   *base[2] = *base[1] + ofs[1];
+   }
+
+   DRM_DEBUG_KMS("%s:y[0x%x],cb[0x%x],cr[0x%x]\n", __func__,
+   *base[0], *base[1], *base[2]);
+
+   return 0;
+
+err_info:
+   DRM_ERROR("invalid size for fmt[0x%x]\n", fmt);
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+
+   DRM_ERROR("buf[%d] - base[0x%x] sz[%llu] ofs[%llu]\n",
+   i, *base[i], size[i], ofs[i]);
+   }
+
+   return -EINVAL;
+}
 
 static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
 {
@@ -689,6 +780,7 @@ static int fimc_src_set_addr(struct device *dev,
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
struct drm_exynos_ipp_property *property;
struct drm_exynos_ipp_config *config;
+   int ret;
 
if (!c_node) {
DRM_ERROR("failed to get c_node.\n");
@@ -709,6 +801,12 @@ static int fimc_src_set_addr(struct device *dev,
switch (buf_type) {
case IPP_BUF_ENQUEUE:
config = >config[EXYNOS_DRM_OPS_SRC];
+   ret = fimc_set_planar_addr(buf_info, config->fmt, >sz);
+   if (ret) {
+   dev_err(dev, "failed to set plane src addr.\n");
+   return ret;
+   }
+
fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
EXYNOS_CIIYSA0);
 
@@ -1148,6 +1246,7 @@ static int fimc_dst_set_addr(struct device *dev,
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;

[PATCH v2 20/22] drm/exynos: gem: simplify access to exynos gem object

2015-11-30 Thread Marek Szyprowski
Replace calls to exynos_drm_gem_get_{dma_addr,size}, by a simpler
function exynos_drm_gem_get(). This lets the caller to get access to
exynos_drm_gem object and extract any information about GEM object
without searching object tree for getting each parameter.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c | 48 +-
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 52 +
 drivers/gpu/drm/exynos/exynos_drm_gem.h | 23 +--
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 41 ++
 drivers/gpu/drm/exynos/exynos_drm_ipp.h |  2 +-
 5 files changed, 52 insertions(+), 114 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index c17efdb238a6..7c83e64f9f1c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -179,7 +179,7 @@ struct g2d_buf_desc {
 struct g2d_buf_info {
unsigned intmap_nr;
enum g2d_reg_type   reg_types[MAX_REG_TYPE_NR];
-   unsigned long   handles[MAX_REG_TYPE_NR];
+   void*obj[MAX_REG_TYPE_NR];
unsigned inttypes[MAX_REG_TYPE_NR];
struct g2d_buf_desc descs[MAX_REG_TYPE_NR];
 };
@@ -360,11 +360,10 @@ add_to_list:
 }
 
 static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev,
-   unsigned long obj,
+   void *obj,
bool force)
 {
-   struct g2d_cmdlist_userptr *g2d_userptr =
-   (struct g2d_cmdlist_userptr *)obj;
+   struct g2d_cmdlist_userptr *g2d_userptr = obj;
struct page **pages;
 
if (!obj)
@@ -407,7 +406,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
unsigned long userptr,
unsigned long size,
struct drm_file *filp,
-   unsigned long *obj)
+   void **obj)
 {
struct drm_exynos_file_private *file_priv = filp->driver_priv;
struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
@@ -434,7 +433,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
 */
if (g2d_userptr->size == size) {
atomic_inc(_userptr->refcount);
-   *obj = (unsigned long)g2d_userptr;
+   *obj = g2d_userptr;
 
return _userptr->dma_addr;
}
@@ -517,7 +516,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
g2d_userptr->in_pool = true;
}
 
-   *obj = (unsigned long)g2d_userptr;
+   *obj = g2d_userptr;
 
return _userptr->dma_addr;
 
@@ -549,9 +548,7 @@ static void g2d_userptr_free_all(struct drm_device *drm_dev,
 
list_for_each_entry_safe(g2d_userptr, n, _priv->userptr_list, list)
if (g2d_userptr->in_pool)
-   g2d_userptr_put_dma_addr(drm_dev,
-   (unsigned long)g2d_userptr,
-   true);
+   g2d_userptr_put_dma_addr(drm_dev, g2d_userptr, true);
 
g2d->current_pool = 0;
 }
@@ -706,26 +703,23 @@ static int g2d_map_cmdlist_gem(struct g2d_data *g2d,
buf_desc = _info->descs[reg_type];
 
if (buf_info->types[reg_type] == BUF_TYPE_GEM) {
-   unsigned long size;
+   struct exynos_drm_gem *exynos_gem;
 
-   size = exynos_drm_gem_get_size(drm_dev, handle, file);
-   if (!size) {
+   exynos_gem = exynos_drm_gem_get(drm_dev, handle, file);
+   if (IS_ERR(exynos_gem)) {
ret = -EFAULT;
goto err;
}
 
if (!g2d_check_buf_desc_is_valid(buf_desc, reg_type,
-   size)) {
+exynos_gem->size)) {
+   exynos_drm_gem_put(drm_dev, exynos_gem);
ret = -EFAULT;
goto err;
}
 
-   addr = exynos_drm_gem_get_dma_addr(drm_dev, handle,
-   file);
-   if (IS_ERR(addr)) {
-   ret = -EFAULT;
-   goto err;
-   }
+

[PATCH v2 10/22] drm/exynos: introduce exynos_drm_plane_config structure

2015-11-30 Thread Marek Szyprowski
This patch adds common structure for keeping plane configuration and
capabilities data. This patch is inspired by similar code developed by
Tobias Jakobi.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 18 ---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 23 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   | 19 
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 25 ++-
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 34 +
 drivers/gpu/drm/exynos/exynos_drm_plane.h |  7 ++---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  | 25 ++-
 drivers/gpu/drm/exynos/exynos_mixer.c | 44 +++
 8 files changed, 121 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 12f558fc3ef6..189ee5ca0a7a 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -26,7 +26,6 @@
 #include "exynos_drm_iommu.h"
 
 #define WINDOWS_NR 3
-#define CURSOR_WIN 2
 #define MIN_FB_WIDTH_FOR_16WORD_BURST  128
 
 static const char * const decon_clks_name[] = {
@@ -57,6 +56,7 @@ struct decon_context {
struct drm_device   *drm_dev;
struct exynos_drm_crtc  *crtc;
struct exynos_drm_plane planes[WINDOWS_NR];
+   struct exynos_drm_plane_config  configs[WINDOWS_NR];
void __iomem*addr;
struct clk  *clks[ARRAY_SIZE(decon_clks_name)];
int pipe;
@@ -72,6 +72,12 @@ static const uint32_t decon_formats[] = {
DRM_FORMAT_ARGB,
 };
 
+static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
+   DRM_PLANE_TYPE_PRIMARY,
+   DRM_PLANE_TYPE_OVERLAY,
+   DRM_PLANE_TYPE_CURSOR,
+};
+
 static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask,
  u32 val)
 {
@@ -484,7 +490,6 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct exynos_drm_private *priv = drm_dev->dev_private;
struct exynos_drm_plane *exynos_plane;
enum exynos_drm_output_type out_type;
-   enum drm_plane_type type;
unsigned int win;
int ret;
 
@@ -494,10 +499,13 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
for (win = ctx->first_win; win < WINDOWS_NR; win++) {
int tmp = (win == ctx->first_win) ? 0 : win;
 
-   type = exynos_plane_get_type(tmp, CURSOR_WIN);
+   ctx->configs[win].pixel_formats = decon_formats;
+   ctx->configs[win].num_pixel_formats = ARRAY_SIZE(decon_formats);
+   ctx->configs[win].zpos = win;
+   ctx->configs[win].type = decon_win_types[tmp];
+
ret = exynos_plane_init(drm_dev, >planes[win],
-   1 << ctx->pipe, type, decon_formats,
-   ARRAY_SIZE(decon_formats), win);
+   1 << ctx->pipe, >configs[win]);
if (ret)
return ret;
}
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 1c62de1a0839..c47f9af8170b 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -41,13 +41,13 @@
 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
 
 #define WINDOWS_NR 2
-#define CURSOR_WIN 1
 
 struct decon_context {
struct device   *dev;
struct drm_device   *drm_dev;
struct exynos_drm_crtc  *crtc;
struct exynos_drm_plane planes[WINDOWS_NR];
+   struct exynos_drm_plane_config  configs[WINDOWS_NR];
struct clk  *pclk;
struct clk  *aclk;
struct clk  *eclk;
@@ -82,6 +82,11 @@ static const uint32_t decon_formats[] = {
DRM_FORMAT_BGRA,
 };
 
+static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
+   DRM_PLANE_TYPE_PRIMARY,
+   DRM_PLANE_TYPE_CURSOR,
+};
+
 static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc)
 {
struct decon_context *ctx = crtc->ctx;
@@ -637,8 +642,7 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct decon_context *ctx = dev_get_drvdata(dev);
struct drm_device *drm_dev = data;
struct exynos_drm_plane *exynos_plane;
-   enum drm_plane_type type;
-   unsigned int zpos;
+   unsigned int i;
int ret;
 
ret = decon_ctx_initialize(ctx, drm_dev);
@@ -647,11 +651,14 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
return ret;
}
 
-   for (zpos = 

[PATCH v2 06/22] drm/exynos: move dma_addr attribute from exynos plane to exynos fb

2015-11-30 Thread Marek Szyprowski
DMA address is a framebuffer attribute and the right place for it is
exynos_drm_framebuffer not exynos_drm_plane. This patch also introduces
helper function for getting dma address of the given framebuffer.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 13 -
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 16 +---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  3 ---
 drivers/gpu/drm/exynos/exynos_drm_fb.c| 16 ++--
 drivers/gpu/drm/exynos/exynos_drm_fb.h|  3 +--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 10 ++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 18 --
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  |  5 -
 drivers/gpu/drm/exynos/exynos_mixer.c |  7 ---
 9 files changed, 38 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index edfd6e390ef7..320efc3d0659 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -21,6 +21,7 @@
 
 #include "exynos_drm_drv.h"
 #include "exynos_drm_crtc.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_plane.h"
 #include "exynos_drm_iommu.h"
 
@@ -261,9 +262,11 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 {
struct decon_context *ctx = crtc->ctx;
struct drm_plane_state *state = plane->base.state;
+   struct drm_framebuffer *fb = state->fb;
unsigned int win = plane->zpos;
-   unsigned int bpp = state->fb->bits_per_pixel >> 3;
-   unsigned int pitch = state->fb->pitches[0];
+   unsigned int bpp = fb->bits_per_pixel >> 3;
+   unsigned int pitch = fb->pitches[0];
+   dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0);
u32 val;
 
if (test_bit(BIT_SUSPENDED, >flags))
@@ -284,9 +287,9 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
VIDOSD_Wx_ALPHA_B_F(0x0);
writel(val, ctx->addr + DECON_VIDOSDxD(win));
 
-   writel(plane->dma_addr[0], ctx->addr + DECON_VIDW0xADD0B0(win));
+   writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win));
 
-   val = plane->dma_addr[0] + pitch * plane->crtc_h;
+   val = dma_addr + pitch * plane->crtc_h;
writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));
 
if (ctx->out_type != IFTYPE_HDMI)
@@ -297,7 +300,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
| BIT_VAL(plane->crtc_w * bpp, 14, 0);
writel(val, ctx->addr + DECON_VIDW0xADD2(win));
 
-   decon_win_set_pixfmt(ctx, win, state->fb);
+   decon_win_set_pixfmt(ctx, win, fb);
 
/* window enable */
decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 4db04f244c17..1629732574e0 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -30,6 +30,7 @@
 #include "exynos_drm_crtc.h"
 #include "exynos_drm_plane.h"
 #include "exynos_drm_drv.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_fbdev.h"
 #include "exynos_drm_iommu.h"
 
@@ -395,13 +396,14 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 {
struct decon_context *ctx = crtc->ctx;
struct drm_plane_state *state = plane->base.state;
+   struct drm_framebuffer *fb = state->fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
unsigned int last_y;
unsigned int win = plane->zpos;
-   unsigned int bpp = state->fb->bits_per_pixel >> 3;
-   unsigned int pitch = state->fb->pitches[0];
+   unsigned int bpp = fb->bits_per_pixel >> 3;
+   unsigned int pitch = fb->pitches[0];
 
if (ctx->suspended)
return;
@@ -417,14 +419,14 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 */
 
/* buffer start address */
-   val = (unsigned long)plane->dma_addr[0];
+   val = (unsigned long)exynos_drm_fb_dma_addr(fb, 0);
writel(val, ctx->regs + VIDW_BUF_START(win));
 
-   padding = (pitch / bpp) - state->fb->width;
+   padding = (pitch / bpp) - fb->width;
 
/* buffer size */
-   writel(state->fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
-   writel(state->fb->height, ctx->regs + VIDW_WHOLE_Y(win));
+   writel(fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
+   writel(fb->height, ctx->regs + VIDW_WHOLE_Y(win));
 
/* offset from the start of the buffer to read */
writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
@@ -466,7 +468,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 
writel(alpha, ctx->regs + VIDOSD_D(win));
 
-   decon_win_set_pixfmt(ctx, win, 

[PATCH v2 04/22] drm/exynos: rotator: convert to common clock framework

2015-11-30 Thread Marek Szyprowski
This driver was not used after introduction of common clock framework.
This patch adds missing prepare/unprepare calls and allows to use it
again with current kernel code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_rotator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c 
b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index 2f5c118f4c8e..bea0f7826d30 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -790,10 +790,10 @@ static int rotator_remove(struct platform_device *pdev)
 static int rotator_clk_crtl(struct rot_context *rot, bool enable)
 {
if (enable) {
-   clk_enable(rot->clock);
+   clk_prepare_enable(rot->clock);
rot->suspended = false;
} else {
-   clk_disable(rot->clock);
+   clk_disable_unprepare(rot->clock);
rot->suspended = true;
}
 
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 08/22] drm/exynos: mixer: use crtc->state->adjusted_mode instead of crtc->mode

2015-11-30 Thread Marek Szyprowski
This patch replaces usage of crtc->mode with crtc->state->adjusted_mode
like it is already done in common plane code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 154537a23c90..84ee3396c429 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -402,9 +402,9 @@ static void vp_video_buffer(struct mixer_context *ctx,
 {
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
+   struct drm_display_mode *mode = >base.crtc->state->adjusted_mode;
struct mixer_resources *res = >mixer_res;
struct drm_framebuffer *fb = state->base.fb;
-   struct drm_display_mode *mode = >base.crtc->mode;
unsigned long flags;
dma_addr_t luma_addr[2], chroma_addr[2];
bool tiled_mode = false;
@@ -539,9 +539,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 {
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
+   struct drm_display_mode *mode = >base.crtc->state->adjusted_mode;
struct mixer_resources *res = >mixer_res;
struct drm_framebuffer *fb = state->base.fb;
-   struct drm_display_mode *mode = >base.crtc->mode;
unsigned long flags;
unsigned int win = plane->zpos;
unsigned int x_ratio = 0, y_ratio = 0;
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/22] drm/exynos: exynos7-decon: remove excessive check

2015-11-30 Thread Marek Szyprowski
Display area is already checked by exynos plane core, so there is no
need for such check in driver code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 38d7762ebdcb..4db04f244c17 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -394,7 +394,6 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
struct decon_context *ctx = crtc->ctx;
-   struct drm_display_mode *mode = >base.state->adjusted_mode;
struct drm_plane_state *state = plane->base.state;
int padding;
unsigned long val, alpha;
@@ -436,15 +435,6 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
plane->crtc_w, plane->crtc_h);
 
-   /*
-* OSD position.
-* In case the window layout goes of LCD layout, DECON fails.
-*/
-   if ((plane->crtc_x + plane->crtc_w) > mode->hdisplay)
-   plane->crtc_x = mode->hdisplay - plane->crtc_w;
-   if ((plane->crtc_y + plane->crtc_h) > mode->vdisplay)
-   plane->crtc_y = mode->vdisplay - plane->crtc_h;
-
val = VIDOSDxA_TOPLEFT_X(plane->crtc_x) |
VIDOSDxA_TOPLEFT_Y(plane->crtc_y);
writel(val, ctx->regs + VIDOSD_A(win));
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/22] drm/exynos: gsc: add device tree support and remove usage of static mappings

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

This patch adds device tree support for exynos_drm_gsc. This patch
also fixed build issue on non-Exynos platforms, thus dependency on
!ARCH_MULTIPLATFORM can be now removed. The driver cannot be used
simultaneously with V4L2 Mem2Mem GScaller driver thought.

Signed-off-by: Seung-Woo Kim 
[updated commit message, removed the need for wb-lcd property, because
all gscallers have support for lcd writeback, replaced dependency on
!ARCH_MULTIPLATFORM with !VIDEO_SAMSUNG_EXYNOS_GSC]
Signed-off-by: Marek Szyprowski 
---
 .../devicetree/bindings/media/exynos5-gsc.txt  |  4 +++
 drivers/gpu/drm/exynos/Kconfig |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_gsc.c| 30 +++---
 drivers/gpu/drm/exynos/regs-gsc.h  |  4 +--
 4 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/exynos5-gsc.txt 
b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
index 0604d42f38d1..5fe9372abb37 100644
--- a/Documentation/devicetree/bindings/media/exynos5-gsc.txt
+++ b/Documentation/devicetree/bindings/media/exynos5-gsc.txt
@@ -7,6 +7,10 @@ Required properties:
 - reg: should contain G-Scaler physical address location and length.
 - interrupts: should contain G-Scaler interrupt number
 
+Optional properties:
+- samsung,sysreg: handle to syscon used to control the system registers to
+  set writeback input and destination
+
 Example:
 
 gsc_0:  gsc@0x13e0 {
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 96e86cf4455b..83efca941388 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -118,7 +118,7 @@ config DRM_EXYNOS_ROTATOR
 
 config DRM_EXYNOS_GSC
bool "GScaler"
-   depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5 && !ARCH_MULTIPLATFORM
+   depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5 && !VIDEO_SAMSUNG_EXYNOS_GSC
help
  Choose this option if you want to use Exynos GSC for DRM.
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index ed55d37b6330..7aecd23cfa11 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -15,7 +15,8 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -126,6 +127,7 @@ struct gsc_capability {
  * @ippdrv: prepare initialization using ippdrv.
  * @regs_res: register resources.
  * @regs: memory mapped io registers.
+ * @sysreg: handle to SYSREG block regmap.
  * @lock: locking of operations.
  * @gsc_clk: gsc gate clock.
  * @sc: scaler infomations.
@@ -138,6 +140,7 @@ struct gsc_context {
struct exynos_drm_ippdrvippdrv;
struct resource *regs_res;
void __iomem*regs;
+   struct regmap   *sysreg;
struct mutexlock;
struct clk  *gsc_clk;
struct gsc_scaler   sc;
@@ -437,9 +440,12 @@ static int gsc_sw_reset(struct gsc_context *ctx)
 
 static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
 {
-   u32 gscblk_cfg;
+   unsigned int gscblk_cfg;
 
-   gscblk_cfg = readl(SYSREG_GSCBLK_CFG1);
+   if (!ctx->sysreg)
+   return;
+
+   regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, _cfg);
 
if (enable)
gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
@@ -448,7 +454,7 @@ static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, 
bool enable)
else
gscblk_cfg |= GSC_BLK_PXLASYNC_LO_MASK_WB(ctx->id);
 
-   writel(gscblk_cfg, SYSREG_GSCBLK_CFG1);
+   regmap_write(ctx->sysreg, SYSREG_GSCBLK_CFG1, gscblk_cfg);
 }
 
 static void gsc_handle_irq(struct gsc_context *ctx, bool enable,
@@ -1663,6 +1669,15 @@ static int gsc_probe(struct platform_device *pdev)
if (!ctx)
return -ENOMEM;
 
+   if (dev->of_node) {
+   ctx->sysreg = syscon_regmap_lookup_by_phandle(dev->of_node,
+   "samsung,sysreg");
+   if (IS_ERR(ctx->sysreg)) {
+   dev_warn(dev, "failed to get system register.\n");
+   ctx->sysreg = NULL;
+   }
+   }
+
/* clock control */
ctx->gsc_clk = devm_clk_get(dev, "gscl");
if (IS_ERR(ctx->gsc_clk)) {
@@ -1796,6 +1811,12 @@ static const struct dev_pm_ops gsc_pm_ops = {
SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL)
 };
 
+static const struct of_device_id exynos_drm_gsc_of_match[] = {
+   { .compatible = "samsung,exynos5-gsc" },
+   { },
+};
+MODULE_DEVICE_TABLE(of, exynos_drm_gsc_of_match);
+
 struct platform_driver gsc_driver = {
.probe  = gsc_probe,
.remove = gsc_remove,
@@ -1803,6 +1824,7 @@ struct platform_driver gsc_driver = {
.name   = "exynos-drm-gsc",
   

[PATCH v2 13/22] drm/exynos: fix clipping when scaling is enabled

2015-11-30 Thread Marek Szyprowski
This patch fixes calculation of src x/y offset for negative crtc x/y
values when scaling is enabled. This fixes possible IOMMU fault when
scaling is enabled.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 9eaa8627175f..427aeec78a28 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -85,25 +85,26 @@ static void exynos_plane_mode_set(struct 
exynos_drm_plane_state *exynos_state)
src_w = state->src_w >> 16;
src_h = state->src_h >> 16;
 
+   /* set ratio */
+   exynos_state->h_ratio = (src_w << 16) / crtc_w;
+   exynos_state->v_ratio = (src_h << 16) / crtc_h;
+
+   /* clip to visible area */
actual_w = exynos_plane_get_size(crtc_x, crtc_w, mode->hdisplay);
actual_h = exynos_plane_get_size(crtc_y, crtc_h, mode->vdisplay);
 
if (crtc_x < 0) {
if (actual_w)
-   src_x -= crtc_x;
+   src_x += ((-crtc_x) * exynos_state->h_ratio) >> 16;
crtc_x = 0;
}
 
if (crtc_y < 0) {
if (actual_h)
-   src_y -= crtc_y;
+   src_y += ((-crtc_y) * exynos_state->v_ratio) >> 16;
crtc_y = 0;
}
 
-   /* set ratio */
-   exynos_state->h_ratio = (src_w << 16) / crtc_w;
-   exynos_state->v_ratio = (src_h << 16) / crtc_h;
-
/* set drm framebuffer data. */
exynos_state->src.x = src_x;
exynos_state->src.y = src_y;
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 22/22] drm/exynos: add support for plane rotation, scalling and colospace convesion

2015-11-30 Thread Marek Szyprowski
This patch adds generic plane rotation property for all supported
drivers. This has been implemented with additional help from Exynos IPP
(Exynos Image Post-Processing subsystem) with temporary framebuffers.
Besides rotation, scaling and color space conversion are also supported.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/Kconfig|   8 +
 drivers/gpu/drm/exynos/Makefile   |   1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |   9 +
 drivers/gpu/drm/exynos/exynos_drm_ipp.c   | 154 ++-
 drivers/gpu/drm/exynos/exynos_drm_ipp.h   |   4 +
 drivers/gpu/drm/exynos/exynos_drm_plane.c |  28 +-
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c | 369 ++
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h |  73 +
 8 files changed, 641 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 83efca941388..e7d414aefbdc 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -104,6 +104,14 @@ config DRM_EXYNOS_IPP
help
  Choose this option if you want to use IPP feature for DRM.
 
+config DRM_EXYNOS_PLANE_IPP
+   depends on DRM_EXYNOS_IPP
+   bool "Use IPP framework for implementing unsupported plane properties"
+   help
+ Choose this option if you want to let IPP framework to provide plane
+ properties (like rotation, overlay scaling and more pixel formats),
+ which are not supported by hardware CRTC drivers.
+
 config DRM_EXYNOS_FIMC
bool "FIMC"
depends on DRM_EXYNOS_IPP && MFD_SYSCON
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 6496532aaa91..92c3f7cac7a9 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -19,6 +19,7 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)   += exynos_hdmi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)+= exynos_drm_vidi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_PLANE_IPP)   += exynos_drm_plane_ipp.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)+= exynos_drm_fimc.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += exynos_drm_rotator.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 670f6d06a2a9..b17e419935db 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -70,6 +70,13 @@ struct exynos_drm_plane_state {
unsigned int h_ratio;
unsigned int v_ratio;
struct drm_framebuffer *fb;
+   unsigned int rotation;
+
+   unsigned int ipp_needed;
+   uint32_t ipp_pixel_format;
+   struct exynos_drm_rect ipp_src;
+   struct exynos_drm_rect ipp_dst;
+   struct drm_framebuffer *ipp_fb;
 };
 
 static inline struct exynos_drm_plane_state *
@@ -93,6 +100,8 @@ struct exynos_drm_plane {
const struct exynos_drm_plane_config *config;
unsigned int zpos;
struct drm_framebuffer *pending_fb;
+   struct drm_framebuffer *ipp_cur_fb;
+   struct drm_framebuffer *ipp_next_fb;
 };
 
 #define EXYNOS_DRM_PLANE_CAP_DOUBLE(1 << 0)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 44a6689e0f4c..231cfbfe036c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include "exynos_drm_drv.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_gem.h"
 #include "exynos_drm_ipp.h"
 #include "exynos_drm_iommu.h"
@@ -1513,7 +1514,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv 
*ippdrv,
 
spin_lock_irqsave(_dev->event_lock, flags);
list_move_tail(>base.link, >base.file_priv->event_list);
-   wake_up_interruptible(>base.file_priv->event_wait);
+   wake_up(>base.file_priv->event_wait);
spin_unlock_irqrestore(_dev->event_lock, flags);
mutex_unlock(_node->event_lock);
 
@@ -1579,6 +1580,157 @@ err_completion:
complete(_node->start_complete);
 }
 
+static struct drm_exynos_ipp_mem_node
+   *ipp_get_internal_mem_node(struct drm_device *drm_dev,
+   struct drm_exynos_ipp_cmd_node *c_node,
+   __u32 prop_id, enum drm_exynos_ops_id ops_id,
+   struct drm_framebuffer *fb)
+{
+   struct drm_exynos_ipp_mem_node *m_node;
+   struct drm_exynos_ipp_buf_info *buf_info;
+   int i;
+
+   m_node = kzalloc(sizeof(*m_node), GFP_KERNEL);
+   if (!m_node)
+   return ERR_PTR(-ENOMEM);
+
+   buf_info = _node->buf_info;
+
+   m_node->ops_id = ops_id;
+   m_node->prop_id = prop_id;
+  

[PATCH v2 11/22] drm/exynos: add generic check for plane state

2015-11-30 Thread Marek Szyprowski
This patch adds generic check for plane state - display area dimensions,
so drivers can always assume that they get valid plane state to set.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  3 +++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 31 +++
 drivers/gpu/drm/exynos/exynos_mixer.c |  3 +++
 3 files changed, 37 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 6f8a296a3115..82bbd7f4b316 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -89,6 +89,9 @@ struct exynos_drm_plane {
struct drm_framebuffer *pending_fb;
 };
 
+#define EXYNOS_DRM_PLANE_CAP_DOUBLE(1 << 0)
+#define EXYNOS_DRM_PLANE_CAP_SCALE (1 << 1)
+
 /*
  * Exynos DRM plane configuration structure.
  *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index b620d7a76799..9eaa8627175f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -173,6 +173,36 @@ static struct drm_plane_funcs exynos_plane_funcs = {
.atomic_destroy_state = exynos_drm_plane_destroy_state,
 };
 
+static int
+exynos_drm_plane_check_size(const struct exynos_drm_plane_config *config,
+   struct exynos_drm_plane_state *state)
+{
+   bool width_ok = false, height_ok = false;
+
+   if (config->capabilities & EXYNOS_DRM_PLANE_CAP_SCALE)
+   return 0;
+
+   if (state->src.w == state->crtc.w)
+   width_ok = true;
+
+   if (state->src.h == state->crtc.h)
+   height_ok = true;
+
+   if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) &&
+   state->h_ratio == (1 << 15))
+   width_ok = true;
+
+   if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) &&
+   state->v_ratio == (1 << 15))
+   height_ok = true;
+
+   if (width_ok & height_ok)
+   return 0;
+
+   DRM_DEBUG_KMS("scaling mode is not supported");
+   return -ENOTSUPP;
+}
+
 static int exynos_plane_atomic_check(struct drm_plane *plane,
 struct drm_plane_state *state)
 {
@@ -187,6 +217,7 @@ static int exynos_plane_atomic_check(struct drm_plane 
*plane,
/* translate state into exynos_state */
exynos_plane_mode_set(exynos_state);
 
+   ret = exynos_drm_plane_check_size(exynos_plane->config, exynos_state);
return ret;
 }
 
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index a229f86d221a..4190285798ef 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -117,16 +117,19 @@ static const struct exynos_drm_plane_config 
plane_configs[MIXER_WIN_NR] = {
.type = DRM_PLANE_TYPE_PRIMARY,
.pixel_formats = mixer_formats,
.num_pixel_formats = ARRAY_SIZE(mixer_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE,
}, {
.zpos = 1,
.type = DRM_PLANE_TYPE_CURSOR,
.pixel_formats = mixer_formats,
.num_pixel_formats = ARRAY_SIZE(mixer_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE,
}, {
.zpos = 2,
.type = DRM_PLANE_TYPE_OVERLAY,
.pixel_formats = vp_formats,
.num_pixel_formats = ARRAY_SIZE(vp_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_SCALE,
},
 };
 
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 19/22] drm/exynos: fix to calculate offset of each plane for ipp gsc

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

NV12 and YUV420 formats are needed to calculate offset of each plane
in a gem buffer for ipp gsc. Without proper offset, only Y plane
can be processed, so result shows green frame. This patch fixes to
calculate offset for cbcr planes for NV12 and YUV420 formats.

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 116 
 1 file changed, 116 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 7aecd23cfa11..2882b9347cc8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -486,6 +486,98 @@ static void gsc_handle_irq(struct gsc_context *ctx, bool 
enable,
gsc_write(cfg, GSC_IRQ);
 }
 
+static int gsc_set_planar_addr(struct drm_exynos_ipp_buf_info *buf_info,
+   u32 fmt, struct drm_exynos_sz *sz)
+{
+   dma_addr_t *base[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t size[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t ofs[EXYNOS_DRM_PLANAR_MAX];
+   bool bypass = false;
+   uint64_t tsize = 0;
+   int i;
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+   ofs[i] = 0;
+   tsize += size[i];
+   DRM_DEBUG_KMS("base[%d][0x%lx]s[%d][%llu]\n",
+   i, (unsigned long)*base[i], i, size[i]);
+   }
+
+   if (!tsize) {
+   DRM_INFO("failed to get buffer size.\n");
+   return 0;
+   }
+
+   switch (fmt) {
+   case DRM_FORMAT_NV12:
+   case DRM_FORMAT_NV21:
+   case DRM_FORMAT_NV16:
+   case DRM_FORMAT_NV61:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[0] >> 1;
+   if (*base[0] && *base[1]) {
+   if (size[0] + size[1] < ofs[0] + ofs[1])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_YUV410:
+   case DRM_FORMAT_YVU410:
+   case DRM_FORMAT_YUV411:
+   case DRM_FORMAT_YVU411:
+   case DRM_FORMAT_YUV420:
+   case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   case DRM_FORMAT_YUV444:
+   case DRM_FORMAT_YVU444:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[2] = ofs[0] >> 2;
+   if (*base[0] && *base[1] && *base[2]) {
+   if (size[0]+size[1]+size[2] < ofs[0]+ofs[1]+ofs[2])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_XRGB:
+   ofs[0] = sz->hsize * sz->vsize << 2;
+   if (*base[0]) {
+   if (size[0] < ofs[0])
+   goto err_info;
+   }
+   bypass = true;
+   break;
+   default:
+   bypass = true;
+   break;
+   }
+
+   if (!bypass) {
+   *base[1] = *base[0] + ofs[0];
+   if (ofs[1] && ofs[2])
+   *base[2] = *base[1] + ofs[1];
+   }
+
+   DRM_DEBUG_KMS("y[0x%lx],cb[0x%lx],cr[0x%lx]\n", (unsigned long)*base[0],
+   (unsigned long)*base[1], (unsigned long)*base[2]);
+
+   return 0;
+
+err_info:
+   DRM_ERROR("invalid size for fmt[0x%x]\n", fmt);
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+
+   DRM_ERROR("base[%d][0x%lx]s[%d][%llu]ofs[%d][%llu]\n",
+   i, (unsigned long)*base[i], i, size[i], i, ofs[i]);
+   }
+
+   return -EINVAL;
+}
 
 static int gsc_src_set_fmt(struct device *dev, u32 fmt)
 {
@@ -715,6 +807,8 @@ static int gsc_src_set_addr(struct device *dev,
struct exynos_drm_ippdrv *ippdrv = >ippdrv;
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
struct drm_exynos_ipp_property *property;
+   struct drm_exynos_ipp_config *config;
+   int ret;
 
if (!c_node) {
DRM_ERROR("failed to get c_node.\n");
@@ -734,6 +828,13 @@ static int gsc_src_set_addr(struct device *dev,
/* address register set */
switch (buf_type) {
case IPP_BUF_ENQUEUE:
+   config = >config[EXYNOS_DRM_OPS_SRC];
+   ret = gsc_set_planar_addr(buf_info, config->fmt, >sz);
+   if (ret) {
+   dev_err(dev, "failed to set plane src addr.\n");
+   return ret;
+   }
+
gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
GSC_IN_BASE_ADDR_Y(buf_id));
gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
@@ -1170,6 +1271,8 @@ 

[PATCH v2 17/22] drm/exynos: gem: set default alignment for dumb GEM buffers

2015-11-30 Thread Marek Szyprowski
This patch forces all GEM buffers to have pitch aligned at least to 8
pixels. This is a common requirement for various Exynos IPP blocks,
which otherwise won't be able to operate on buffers of random size.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 ++
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index bb2e449a20c3..670f6d06a2a9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -24,6 +24,8 @@
 
 #define DEFAULT_WIN0
 
+#define EXYNOS_DRM_PITCH_ALIGN 8
+
 #define to_exynos_crtc(x)  container_of(x, struct exynos_drm_crtc, base)
 #define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base)
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c 
b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 252eb301470c..b5db6e6cc043 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -417,7 +417,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
 *  with DRM_IOCTL_MODE_CREATE_DUMB command.
 */
 
-   args->pitch = args->width * ((args->bpp + 7) / 8);
+   args->pitch = roundup(args->width, EXYNOS_DRM_PITCH_ALIGN) * 
((args->bpp + 7) / 8);
args->size = args->pitch * args->height;
 
if (is_drm_iommu_supported(dev))
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 15/22] drm/exynos: gem: remove old unused prototypes

2015-11-30 Thread Marek Szyprowski
This patch removes old, unused function prototypes from exynos_drm_gem.h.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_gem.h | 28 
 1 file changed, 28 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h 
b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index 37ab8b282db6..9ca5047959ec 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -55,8 +55,6 @@ struct exynos_drm_gem {
struct sg_table *sgt;
 };
 
-struct page **exynos_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask);
-
 /* destroy a buffer with gem object */
 void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem);
 
@@ -91,10 +89,6 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
unsigned int gem_handle,
struct drm_file *filp);
 
-/* map user space allocated by malloc to pages. */
-int exynos_drm_gem_userptr_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-
 /* get buffer information to memory region allocated by gem. */
 int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,
  struct drm_file *file_priv);
@@ -123,28 +117,6 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, 
struct vm_fault *vmf);
 /* set vm_flags and we can change the vm attribute to other one at here. */
 int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 
-static inline int vma_is_io(struct vm_area_struct *vma)
-{
-   return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
-}
-
-/* get a copy of a virtual memory region. */
-struct vm_area_struct *exynos_gem_get_vma(struct vm_area_struct *vma);
-
-/* release a userspace virtual memory area. */
-void exynos_gem_put_vma(struct vm_area_struct *vma);
-
-/* get pages from user space. */
-int exynos_gem_get_pages_from_userptr(unsigned long start,
-   unsigned int npages,
-   struct page **pages,
-   struct vm_area_struct *vma);
-
-/* drop the reference to pages. */
-void exynos_gem_put_pages_to_userptr(struct page **pages,
-   unsigned int npages,
-   struct vm_area_struct *vma);
-
 /* map sgt with dma region. */
 int exynos_gem_map_sgt_with_dma(struct drm_device *drm_dev,
struct sg_table *sgt,
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/22] Exynos DRM: new life of IPP (Image Post Processing) subsystem

2015-11-30 Thread Marek Szyprowski
Dear All,

This patch series introduces a new life into Exynos IPP (Image Post
Processing) subsystem by integrating it (transparently for userspace
applications) with Exynos DRM core plane management. This means that all
CRTC drivers transparently get support for standard features of IPP
subsystem like rotation, scaling and color space conversion.

Support for features not supported natively by CRTC drivers is
implemented with a help of temporary framebuffers, where image data is
processed by IPP subsystem before performing the scanout by a CRTC driver.

This is second version of this patchset. The initial version is available
here:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/49743

The main change since v1 is support for color space conversion and minor
fixes in the preparation patches (added support for native scaling in
Exynos Video Processor module).

This feature is 'experimental'. From the initial discussion I see that
there is no consensus if this feature should be integrated seamplessly
in Exynos DRM core or provided by a separate API. This will be further
discussed.

However, I would like to ask for merging patches 1-15, which are pure
bugfixes and code cleanups. The patches are based on top of current
exynos-drm-next branch.

Best regards
Marek Szyprowski
Samsung R Institute Poland


Patch summary:

Marek Szyprowski (17):
  drm/exynos: rotator: convert to common clock framework
  drm/exynos: exynos7-decon: remove excessive check
  drm/exynos: move dma_addr attribute from exynos plane to exynos fb
  drm/exynos: introduce exynos_drm_plane_state structure
  drm/exynos: mixer: use crtc->state->adjusted_mode instead of
crtc->mode
  drm/exynos: mixer: enable video overlay plane only when VP is
available
  drm/exynos: introduce exynos_drm_plane_config structure
  drm/exynos: add generic check for plane state
  drm/exynos: mixer: use ratio precalculated in exynos_state
  drm/exynos: fix clipping when scaling is enabled
  drm/exynos: fimd: fix dma burst size setting for small plane size
  drm/exynos: gem: remove old unused prototypes
  drm/exynos: add fb pointer to exynos_drm_plane_state
  drm/exynos: gem: set default alignment for dumb GEM buffers
  drm/exynos: gem: simplify access to exynos gem object
  drm/exynos: ipp: make framework context global
  drm/exynos: add support for plane rotation, scalling and colospace
convesion

Seung-Woo Kim (5):
  drm/exynos: gsc: prepare and unprepare gsc clock
  drm/exynos: gsc: fix wrong pm_runtime state
  drm/exynos: gsc: add device tree support and remove usage of static
mappings
  drm/exynos: fix to calculate offset of each plane for ipp fimc
  drm/exynos: fix to calculate offset of each plane for ipp gsc

 .../devicetree/bindings/media/exynos5-gsc.txt  |   4 +
 drivers/gpu/drm/exynos/Kconfig |  10 +-
 drivers/gpu/drm/exynos/Makefile|   1 +
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c  |  48 ++-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c |  68 ++--
 drivers/gpu/drm/exynos/exynos_drm_drv.h|  96 --
 drivers/gpu/drm/exynos/exynos_drm_fb.c |  16 +-
 drivers/gpu/drm/exynos/exynos_drm_fb.h |   3 +-
 drivers/gpu/drm/exynos/exynos_drm_fimc.c   | 106 ++
 drivers/gpu/drm/exynos/exynos_drm_fimd.c   |  88 ++---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|  48 ++-
 drivers/gpu/drm/exynos/exynos_drm_gem.c|  54 +--
 drivers/gpu/drm/exynos/exynos_drm_gem.h|  51 +--
 drivers/gpu/drm/exynos/exynos_drm_gsc.c| 151 -
 drivers/gpu/drm/exynos/exynos_drm_ipp.c| 240 +++---
 drivers/gpu/drm/exynos/exynos_drm_ipp.h|   8 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c  | 237 -
 drivers/gpu/drm/exynos/exynos_drm_plane.h  |   7 +-
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c  | 369 +
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h  |  73 
 drivers/gpu/drm/exynos/exynos_drm_rotator.c|   4 +-
 drivers/gpu/drm/exynos/exynos_drm_vidi.c   |  30 +-
 drivers/gpu/drm/exynos/exynos_mixer.c  | 129 ---
 drivers/gpu/drm/exynos/regs-gsc.h  |   4 +-
 24 files changed, 1375 insertions(+), 470 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h

-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/22] drm/exynos: mixer: use ratio precalculated in exynos_state

2015-11-30 Thread Marek Szyprowski
Common plane code already calculates and checks for supported scalling
modes, so additional code in mixer driver can be now removed.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 33 +++--
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 4190285798ef..dfb35e2da4db 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -528,33 +528,6 @@ static void mixer_layer_update(struct mixer_context *ctx)
mixer_reg_writemask(res, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE);
 }
 
-static int mixer_setup_scale(const struct exynos_drm_plane *plane,
-   unsigned int *x_ratio, unsigned int *y_ratio)
-{
-   struct exynos_drm_plane_state *state =
-   to_exynos_plane_state(plane->base.state);
-
-   if (state->crtc.w != state->src.w) {
-   if (state->crtc.w == 2 * state->src.w)
-   *x_ratio = 1;
-   else
-   goto fail;
-   }
-
-   if (state->crtc.h != state->src.h) {
-   if (state->crtc.h == 2 * state->src.h)
-   *y_ratio = 1;
-   else
-   goto fail;
-   }
-
-   return 0;
-
-fail:
-   DRM_DEBUG_KMS("only 2x width/height scaling of plane supported\n");
-   return -ENOTSUPP;
-}
-
 static void mixer_graph_buffer(struct mixer_context *ctx,
   struct exynos_drm_plane *plane)
 {
@@ -594,9 +567,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
return;
}
 
-   /* check if mixer supports requested scaling setup */
-   if (mixer_setup_scale(plane, _ratio, _ratio))
-   return;
+   /* ratio is already checked by common plane code */
+   x_ratio = state->h_ratio == (1 << 15);
+   y_ratio = state->v_ratio == (1 << 15);
 
dst_x_offset = state->crtc.x;
dst_y_offset = state->crtc.y;
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 16/22] drm/exynos: add fb pointer to exynos_drm_plane_state

2015-11-30 Thread Marek Szyprowski
Add framebuffer pointer to exynos_drm_plane_state and tell drivers to use
it. This lets common plane code to set temporary framebuffer in the
future and drivers will use it without additional changes.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 2 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 2 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   | 8 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 ++
 drivers/gpu/drm/exynos/exynos_mixer.c | 4 ++--
 6 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 189ee5ca0a7a..1f705bede7dd 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -269,7 +269,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
unsigned int win = plane->zpos;
unsigned int bpp = fb->bits_per_pixel >> 3;
unsigned int pitch = fb->pitches[0];
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index c47f9af8170b..17aa11702a40 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -402,7 +402,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 82bbd7f4b316..bb2e449a20c3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -53,9 +53,12 @@ struct exynos_drm_rect {
  *   (clipped to visible part).
  * @h_ratio: horizontal scaling ratio, 16.16 fixed point
  * @v_ratio: vertical scaling ratio, 16.16 fixed point
+ * @fb: framebuffer with image data to be displayed (drivers should use this
+ *  instead of .base->fb)
  *
- * this structure consists plane state data that will be applied to hardware
- * specific overlay info.
+ * This structure consists plane state data that will be applied to hardware
+ * specific overlay info. Some data is duplicated (comparing with base state)
+ * to let common code to modify it for internal use.
  */
 
 struct exynos_drm_plane_state {
@@ -64,6 +67,7 @@ struct exynos_drm_plane_state {
struct exynos_drm_rect src;
unsigned int h_ratio;
unsigned int v_ratio;
+   struct drm_framebuffer *fb;
 };
 
 static inline struct exynos_drm_plane_state *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 2e2247126581..0046495173f3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -650,7 +650,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct fimd_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
dma_addr_t dma_addr;
unsigned long val, size, offset;
unsigned int last_x, last_y, buf_offsize, line_size;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 427aeec78a28..8a1242b5a938 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -117,6 +117,8 @@ static void exynos_plane_mode_set(struct 
exynos_drm_plane_state *exynos_state)
exynos_state->crtc.w = actual_w;
exynos_state->crtc.h = actual_h;
 
+   exynos_state->fb = state->fb;
+
DRM_DEBUG_KMS("plane : offset_x/y(%d,%d), width/height(%d,%d)",
exynos_state->crtc.x, exynos_state->crtc.y,
exynos_state->crtc.w, exynos_state->crtc.h);
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index dfb35e2da4db..787aa03f4359 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -425,7 +425,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
to_exynos_plane_state(plane->base.state);
struct drm_display_mode *mode = 

[PATCH v2 07/22] drm/exynos: introduce exynos_drm_plane_state structure

2015-11-30 Thread Marek Szyprowski
This patch introduces exynos_drm_plane_state structure, which subclasses
drm_plane_state and holds precalculated data suitable for configuring
Exynos hardware.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  21 ++---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c|  21 ++---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  56 +++-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  |  33 +++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 125 +++---
 drivers/gpu/drm/exynos/exynos_mixer.c |  61 +++--
 6 files changed, 197 insertions(+), 120 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 320efc3d0659..12f558fc3ef6 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -260,9 +260,10 @@ static void decon_atomic_begin(struct exynos_drm_crtc 
*crtc,
 static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
+   struct exynos_drm_plane_state *state =
+   to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_plane_state *state = plane->base.state;
-   struct drm_framebuffer *fb = state->fb;
+   struct drm_framebuffer *fb = state->base.fb;
unsigned int win = plane->zpos;
unsigned int bpp = fb->bits_per_pixel >> 3;
unsigned int pitch = fb->pitches[0];
@@ -272,11 +273,11 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
if (test_bit(BIT_SUSPENDED, >flags))
return;
 
-   val = COORDINATE_X(plane->crtc_x) | COORDINATE_Y(plane->crtc_y);
+   val = COORDINATE_X(state->crtc.x) | COORDINATE_Y(state->crtc.y);
writel(val, ctx->addr + DECON_VIDOSDxA(win));
 
-   val = COORDINATE_X(plane->crtc_x + plane->crtc_w - 1) |
-   COORDINATE_Y(plane->crtc_y + plane->crtc_h - 1);
+   val = COORDINATE_X(state->crtc.x + state->crtc.w - 1) |
+   COORDINATE_Y(state->crtc.y + state->crtc.h - 1);
writel(val, ctx->addr + DECON_VIDOSDxB(win));
 
val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
@@ -289,15 +290,15 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 
writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win));
 
-   val = dma_addr + pitch * plane->crtc_h;
+   val = dma_addr + pitch * state->src.h;
writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));
 
if (ctx->out_type != IFTYPE_HDMI)
-   val = BIT_VAL(pitch - plane->crtc_w * bpp, 27, 14)
-   | BIT_VAL(plane->crtc_w * bpp, 13, 0);
+   val = BIT_VAL(pitch - state->crtc.w * bpp, 27, 14)
+   | BIT_VAL(state->crtc.w * bpp, 13, 0);
else
-   val = BIT_VAL(pitch - plane->crtc_w * bpp, 29, 15)
-   | BIT_VAL(plane->crtc_w * bpp, 14, 0);
+   val = BIT_VAL(pitch - state->crtc.w * bpp, 29, 15)
+   | BIT_VAL(state->crtc.w * bpp, 14, 0);
writel(val, ctx->addr + DECON_VIDW0xADD2(win));
 
decon_win_set_pixfmt(ctx, win, fb);
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 1629732574e0..1c62de1a0839 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -394,9 +394,10 @@ static void decon_atomic_begin(struct exynos_drm_crtc 
*crtc,
 static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
+   struct exynos_drm_plane_state *state =
+   to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_plane_state *state = plane->base.state;
-   struct drm_framebuffer *fb = state->fb;
+   struct drm_framebuffer *fb = state->base.fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
@@ -429,22 +430,22 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
writel(fb->height, ctx->regs + VIDW_WHOLE_Y(win));
 
/* offset from the start of the buffer to read */
-   writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
-   writel(plane->src_y, ctx->regs + VIDW_OFFSET_Y(win));
+   writel(state->src.x, ctx->regs + VIDW_OFFSET_X(win));
+   writel(state->src.y, ctx->regs + VIDW_OFFSET_Y(win));
 
DRM_DEBUG_KMS("start addr = 0x%lx\n",
(unsigned long)val);
DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
-   plane->crtc_w, plane->crtc_h);
+   state->crtc.w, state->crtc.h);
 
-   val = 

[PATCH v2 09/22] drm/exynos: mixer: enable video overlay plane only when VP is available

2015-11-30 Thread Marek Szyprowski
Video overlay plane should be registered only when suitable hardware
sub-block (Video Processor) is available.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 84ee3396c429..8d2ce13eb725 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1167,6 +1167,9 @@ static int mixer_bind(struct device *dev, struct device 
*manager, void *data)
const uint32_t *formats;
unsigned int fcount;
 
+   if (zpos == VP_DEFAULT_WIN && !ctx->vp_enabled)
+   continue;
+
if (zpos < VP_DEFAULT_WIN) {
formats = mixer_formats;
fcount = ARRAY_SIZE(mixer_formats);
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] arm: dts: Fix audio card detection on peach boards

2015-11-30 Thread Javier Martinez Canillas
Hello Alim,

On 10/12/2015 09:37 AM, Alim Akhtar wrote:
> Since commit 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards"),
> sound card detection is broken on peach boards and gives below errors:
> 
> [3.630457] max98090 7-0010: MAX98091 REVID=0x51
> [3.634233] max98090 7-0010: use default 2.8v micbias
> [3.640985] snow-audio sound: HiFi <-> 383.i2s mapping ok
> [3.645307] max98090 7-0010: Invalid master clock frequency
> [3.650824] snow-audio sound: ASoC: Peach-Pi-I2S-MAX98091 late_probe() 
> failed: -22
> [3.658914] snow-audio sound: snd_soc_register_card failed (-22)
> [3.664366] snow-audio: probe of sound failed with error -22
> 
> This patch adds missing assigned-clocks and assigned-clock-parents for
> pmu_system_controller node which is used as "mclk" for audio codec.
> 
> Signed-off-by: Alim Akhtar 
> Fixes: 2fad972d45c4 ("ARM: dts: Add mclk entry for Peach boards")

I found that this patch is not enough to have proper audio working
on an Exynos5800 Peach Pi. Even playing a simple wav does not work:

$ time aplay -D sysdefault /usr/share/sounds/alsa/Front_Center.wav 
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little 
Endian, Rate 48000 Hz, Mono

real0m1.138s
user0m0.005s
sys 0m0.005s

This should be ~1.5 seconds so audio is processed faster than expected.

So something else besides making the CLKOUT to provide a valid frequency
for the codec's master clock is needed.

Do you know what's missing in mainline? For instance, I see that the
sound/soc/samsung/snow.c ASoC machine driver doesn't have a hw_params
but I'm not that familiar with ALSA to know if that makes sense or not.

Also, do you know if the "simple-audio-card" can be used instead for
snow and peachs as it is used for other Exynos5 boards or a specific
ASoC machine driver is really needed for these Chromebooks?

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] ARM: amba: Move reading of periphid to amba_match()

2015-11-30 Thread Ulf Hansson
On 26 November 2015 at 13:49, Marek Szyprowski  wrote:
> From: Tomeu Vizoso 
>
> Reading the periphid when the Primecell device is registered means that
> the apb pclk must be available by then or the device won't be registered
> at all.
>
> By reading the periphid in amba_match() we can return -EPROBE_DEFER if
> the apb pclk isn't there yet and the device will be retried later.
>
> Signed-off-by: Tomeu Vizoso 
> Signed-off-by: Marek Szyprowski 
> ---
>  drivers/amba/bus.c | 88 
> --
>  1 file changed, 46 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index f009936..72ebf9b 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -24,6 +24,8 @@
>
>  #define to_amba_driver(d)  container_of(d, struct amba_driver, drv)
>
> +static int read_periphid(struct amba_device *d, unsigned int *periphid);

I would change this to:
static int amba_read_periphid(struct amba_device *dev);

That will actually also make the patch smaller.

> +
>  static const struct amba_id *
>  amba_lookup(const struct amba_id *table, struct amba_device *dev)
>  {
> @@ -43,11 +45,22 @@ static int amba_match(struct device *dev, struct 
> device_driver *drv)
>  {
> struct amba_device *pcdev = to_amba_device(dev);
> struct amba_driver *pcdrv = to_amba_driver(drv);
> +   int ret;
>
> /* When driver_override is set, only bind to the matching driver */
> if (pcdev->driver_override)
> return !strcmp(pcdev->driver_override, drv->name);
>
> +   if (!pcdev->periphid) {
> +   ret = read_periphid(pcdev, >periphid);
> +   if (ret) {
> +   if (ret != -EPROBE_DEFER)
> +   dev_err(dev, "Failed to read periphid: %d",
> +   ret);
> +   return ret;
> +   }
> +   }
> +
> return amba_lookup(pcdrv->id_table, pcdev) != NULL;
>  }
>
> @@ -336,44 +349,22 @@ static void amba_device_release(struct device *dev)
> kfree(d);
>  }
>
> -/**
> - * amba_device_add - add a previously allocated AMBA device structure
> - * @dev: AMBA device allocated by amba_device_alloc
> - * @parent: resource parent for this devices resources
> - *
> - * Claim the resource, and read the device cell ID if not already
> - * initialized.  Register the AMBA device with the Linux device
> - * manager.
> - */
> -int amba_device_add(struct amba_device *dev, struct resource *parent)
> +static int read_periphid(struct amba_device *d, unsigned int *periphid)
>  {
> u32 size;
> void __iomem *tmp;
> -   int i, ret;
> -
> -   WARN_ON(dev->irq[0] == (unsigned int)-1);
> -   WARN_ON(dev->irq[1] == (unsigned int)-1);
> -
> -   ret = request_resource(parent, >res);
> -   if (ret)
> -   goto err_out;
> -
> -   /* Hard-coded primecell ID instead of plug-n-play */

This line now belongs in amba_match(), please move it there instead of
just deleting it.

> -   if (dev->periphid != 0)
> -   goto skip_probe;
> +   int i, ret = 0;
>
> /*
>  * Dynamically calculate the size of the resource
>  * and use this for iomap
>  */
> -   size = resource_size(>res);
> -   tmp = ioremap(dev->res.start, size);
> -   if (!tmp) {
> -   ret = -ENOMEM;
> -   goto err_release;
> -   }
> +   size = resource_size(>res);
> +   tmp = ioremap(d->res.start, size);
> +   if (!tmp)
> +   return -ENOMEM;
>
> -   ret = amba_get_enable_pclk(dev);
> +   ret = amba_get_enable_pclk(d);
> if (ret == 0) {
> u32 pid, cid;
>
> @@ -388,37 +379,50 @@ int amba_device_add(struct amba_device *dev, struct 
> resource *parent)
> cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
> (i * 8);
>
> -   amba_put_disable_pclk(dev);
> +   amba_put_disable_pclk(d);
>
> if (cid == AMBA_CID || cid == CORESIGHT_CID)
> -   dev->periphid = pid;
> +   *periphid = pid;
>
> -   if (!dev->periphid)
> +   if (!*periphid)
> ret = -ENODEV;
> }
>
> iounmap(tmp);
>
> +   return ret;
> +}
> +
> +/**
> + * amba_device_add - add a previously allocated AMBA device structure
> + * @dev: AMBA device allocated by amba_device_alloc
> + * @parent: resource parent for this devices resources
> + *
> + * Claim the resource, and register the AMBA device with the Linux device
> + * manager.
> + */
> +int amba_device_add(struct amba_device *dev, struct resource *parent)
> +{
> +   int ret;
> +
> +   WARN_ON(dev->irq[0] == 

[PATCH 07/20] drm: fix inclusion of drm.h in exynos_sarea.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/exynos_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
index 5575ed1..a5b2dd9 100644
--- a/include/uapi/drm/exynos_drm.h
+++ b/include/uapi/drm/exynos_drm.h
@@ -15,7 +15,7 @@
 #ifndef _UAPI_EXYNOS_DRM_H_
 #define _UAPI_EXYNOS_DRM_H_
 
-#include 
+#include "drm.h"
 
 /**
  * User-desired buffer creation information structure.
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/4] driver core: handle -EPROBE_DEFER from bus_type.match()

2015-11-30 Thread Ulf Hansson
On 26 November 2015 at 13:49, Marek Szyprowski  wrote:
> From: Tomeu Vizoso 
>
> Lets implementations of the match() callback in struct bus_type to

/s/Lets/Allow

> return errors and if it's -EPROBE_DEFER then queue the device for
> deferred probing.
>
> This is useful to buses such as AMBA in which devices are registered
> before their matching information can be retrieved from the HW
> (typically because a clock driver hasn't probed yet).
>
> Signed-off-by: Tomeu Vizoso 
> Signed-off-by: Marek Szyprowski 
> ---
>  drivers/base/dd.c  | 24 ++--
>  include/linux/device.h |  2 +-
>  2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index a641cf3..a20c119 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -490,6 +490,7 @@ static int __device_attach_driver(struct device_driver 
> *drv, void *_data)
> struct device_attach_data *data = _data;
> struct device *dev = data->dev;
> bool async_allowed;
> +   int ret;
>
> /*
>  * Check if device has already been claimed. This may
> @@ -500,8 +501,17 @@ static int __device_attach_driver(struct device_driver 
> *drv, void *_data)
> if (dev->driver)
> return -EBUSY;
>
> -   if (!driver_match_device(drv, dev))
> +   ret = driver_match_device(drv, dev);
> +   if (!ret)
> return 0;
> +   else if (ret < 0) {

Depending on what happens with the added dev_warn() below, perhaps a
switch statement can make it a bit clearer, instead of these messy if
clauses?

> +   if (ret == -EPROBE_DEFER) {
> +   dev_dbg(dev, "Device match requests probe 
> deferral\n");
> +   driver_deferred_probe_add(dev);
> +   } else
> +   dev_warn(dev, "Bus failed to match device: %d", ret);

Greg commented on this before, as it may introduce some noise [1].

I started browsing various bus’s implementation of the ->match()
callback. A quick search tells me that most implementations are
following the Documentation/driver-model/porting.txt, which means
returning 0 or 1. Actually I couldn't find anyone returning any other
value, though it was a quick search.

On the other hand, include/linux/device.h states a "non-zero" value is
allowed to be return, so there's a tiny conflict between the code and
the documentation. I guess we should fix that!?

No matter what, I realize that it could be useful to print a message
when receiving a negative error code, maybe dev_dbg() could be
sufficient?

> +   return ret;
> +   }
>
> async_allowed = driver_allows_async_probing(drv);
>
> @@ -621,6 +631,7 @@ void device_initial_probe(struct device *dev)
>  static int __driver_attach(struct device *dev, void *data)
>  {
> struct device_driver *drv = data;
> +   int ret;
>
> /*
>  * Lock device and try to bind to it. We drop the error
> @@ -632,8 +643,17 @@ static int __driver_attach(struct device *dev, void 
> *data)
>  * is an error.
>  */
>
> -   if (!driver_match_device(drv, dev))
> +   ret = driver_match_device(drv, dev);
> +   if (!ret)
> +   return 0;
> +   else if (ret < 0) {
> +   if (ret == -EPROBE_DEFER) {
> +   dev_dbg(dev, "Device match requests probe 
> deferral\n");
> +   driver_deferred_probe_add(dev);
> +   } else
> +   dev_warn(dev, "Bus failed to match device: %d", ret);
> return 0;
> +   }
>
> if (dev->parent)/* Needed for USB */
> device_lock(dev->parent);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index b8f411b..d4e7d1f 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -70,7 +70,7 @@ extern void bus_remove_file(struct bus_type *, struct 
> bus_attribute *);
>   * @dev_groups:Default attributes of the devices on the bus.
>   * @drv_groups: Default attributes of the device drivers on the bus.
>   * @match: Called, perhaps multiple times, whenever a new device or 
> driver
> - * is added for this bus. It should return a nonzero value if the
> + * is added for this bus. It should return a positive value if 
> the
>   * given device can be handled by the given driver.
>   * @uevent:Called when a device is added, removed, or a few other things
>   * that generate uevents to add the environment variables.
> --
> 1.9.2
>

Kind regards
Uffe

[1]
https://lkml.org/lkml/2015/10/17/24
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html