* [RFC 01/11] OMAPDSS: Add writeback output driver
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 02/11] OMAPDSS: APPLY: Add get/set info functions for writeback Archit Taneja
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
Writeback is implemented as an output driver. This lets writeback to connect
to overlay managers, and configure writeback's manager like properties the same
way other output drivers do.
This driver can be considered something similar to the DPI output driver. It
provides functions which configure the writeback's manager-like registers via
apply. One difference though is that these functions won't be used by a panel
driver. They'd be used by a writeback user directly.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/Kconfig | 13 +++++
drivers/video/omap2/dss/Makefile | 1 +
drivers/video/omap2/dss/core.c | 6 +++
drivers/video/omap2/dss/dss.h | 6 +++
drivers/video/omap2/dss/writeback.c | 102 +++++++++++++++++++++++++++++++++++
include/video/omapdss.h | 10 ++++
6 files changed, 138 insertions(+)
create mode 100644 drivers/video/omap2/dss/writeback.c
diff --git a/drivers/video/omap2/dss/Kconfig b/drivers/video/omap2/dss/Kconfig
index 50e8802..9e52d4b 100644
--- a/drivers/video/omap2/dss/Kconfig
+++ b/drivers/video/omap2/dss/Kconfig
@@ -99,6 +99,19 @@ config OMAP2_DSS_DSI
See http://www.mipi.org/ for DSI specifications.
+config OMAP4_DSS_WRITEBACK
+ bool "writeback support"
+ default n
+ help
+ writeback is a DISPC pipeline that takes pixel data from an overlay
+ output or a overlay manager output and writes it back into a specified
+ address in memory.
+
+ writeback pipeline allows us to take benefit of the hardware
+ processing available inside the DISPC like color space conversion,
+ rescaling, compositing etc and perform either a memory-to-memory
+ transfer with data processing, or capture a displayed frame.
+
config OMAP2_DSS_MIN_FCK_PER_PCK
int "Minimum FCK/PCK ratio (for scaling)"
range 0 32
diff --git a/drivers/video/omap2/dss/Makefile b/drivers/video/omap2/dss/Makefile
index 4070191..211a290 100644
--- a/drivers/video/omap2/dss/Makefile
+++ b/drivers/video/omap2/dss/Makefile
@@ -8,4 +8,5 @@ omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi.o \
hdmi_panel.o ti_hdmi_4xxx_ip.o
+omapdss-$(CONFIG_OMAP4_DSS_WRITEBACK) += writeback.o
ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index b1a9ce1..4040868 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -528,6 +528,9 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
#ifdef CONFIG_OMAP4_DSS_HDMI
hdmi_init_platform_driver,
#endif
+#ifdef CONFIG_OMAP4_DSS_WRITEBACK
+ writeback_init_platform_driver,
+#endif
};
static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
@@ -549,6 +552,9 @@ static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
#ifdef CONFIG_OMAP4_DSS_HDMI
hdmi_uninit_platform_driver,
#endif
+#ifdef CONFIG_OMAP4_DSS_WRITEBACK
+ writeback_uninit_platform_driver,
+#endif
};
static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)];
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 84a7f6a..f7eb7d6 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -528,6 +528,12 @@ bool hdmi_mode_has_audio(void);
int hdmi_audio_config(struct omap_dss_audio *audio);
#endif
+/* Writeback */
+#ifdef CONFIG_OMAP4_DSS_WRITEBACK
+int writeback_init_platform_driver(void) __init;
+void writeback_uninit_platform_driver(void) __exit;
+#endif
+
/* RFBI */
int rfbi_init_platform_driver(void) __init;
void rfbi_uninit_platform_driver(void) __exit;
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
new file mode 100644
index 0000000..b5c6406
--- /dev/null
+++ b/drivers/video/omap2/dss/writeback.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Archit Taneja <archit@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define DSS_SUBSYS_NAME "WB"
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <video/omapdss.h>
+
+#include "dss.h"
+
+struct writeback_data {
+ struct mutex lock;
+
+ struct omap_dss_output output;
+};
+
+static inline struct writeback_data *writeback_get_drv_data(struct platform_device *wbdev)
+{
+ return dev_get_drvdata(&wbdev->dev);
+}
+
+static inline struct platform_device *writeback_get_wbdev_from_output(struct omap_dss_output *out)
+{
+ return out->pdev;
+}
+
+struct omap_dss_output *omap_dss_get_writeback(void)
+{
+ return omap_dss_get_output(OMAP_DSS_OUTPUT_WB);
+}
+EXPORT_SYMBOL(omap_dss_get_writeback);
+
+static void __init writeback_init_output(struct platform_device *pdev,
+ struct writeback_data *wb_data)
+{
+ struct omap_dss_output *out = &wb_data->output;
+
+ dss_register_output(out);
+
+ out->pdev = pdev;
+ out->id = OMAP_DSS_OUTPUT_WB;
+ out->type = OMAP_DISPLAY_TYPE_NONE;
+}
+
+static int __init omap_writeback_probe(struct platform_device *pdev)
+{
+ struct writeback_data *wb_data;
+
+ wb_data = devm_kzalloc(&pdev->dev, sizeof(*wb_data), GFP_KERNEL);
+ if (!wb_data)
+ return -ENOMEM;
+
+ dev_set_drvdata(&pdev->dev, wb_data);
+
+ mutex_init(&wb_data->lock);
+
+ writeback_init_output(pdev, wb_data);
+
+ return 0;
+}
+
+static int __exit omap_writeback_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct platform_driver omap_writeback_driver = {
+ .remove = __exit_p(omap_writeback_remove),
+ .driver = {
+ .name = "omapdss_writeback",
+ .owner = THIS_MODULE,
+ },
+};
+
+int __init writeback_init_platform_driver(void)
+{
+ return platform_driver_probe(&omap_writeback_driver,
+ omap_writeback_probe);
+}
+
+void __exit writeback_uninit_platform_driver(void)
+{
+ platform_driver_unregister(&omap_writeback_driver);
+}
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index b1248c2..e81fcb2 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -217,6 +217,7 @@ enum omap_dss_output_id {
OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
OMAP_DSS_OUTPUT_VENC = 1 << 5,
OMAP_DSS_OUTPUT_HDMI = 1 << 6,
+ OMAP_DSS_OUTPUT_WB = 1 << 7,
};
/* RFBI */
@@ -836,4 +837,13 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+#ifdef CONFIG_OMAP4_DSS_WRITEBACK
+struct omap_dss_output *omap_dss_get_writeback(void);
+#else
+static inline struct omap_dss_output *omap_dss_get_writeback(void)
+{
+ return NULL;
+}
+#endif
+
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 02/11] OMAPDSS: APPLY: Add get/set info functions for writeback
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
2012-11-07 14:56 ` [RFC 01/11] OMAPDSS: Add writeback output driver Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 03/11] OMAPDSS: APPLY: Apply writeback configurations Archit Taneja
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
Writeback contains overlay-like parameters which need to be applied by a user
of writeback.
Create functions in APPLY which get and set user_info of type
omap_dss_writeback_info, these are similar to overlay's dss_ovl_get_info and
dss_ovl_set_info ops. The writeback output driver provides equivalent functions
for a writeback user, these finally call the above APPLY functions.
Add a private data struct for writeback which stores the user_info and it's
state. This struct will be later added with more params to represent the other
levels of the APPLY cache. Add a helper function to retrieve the private data.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 42 +++++++++++++++++++++++++++++++++++
drivers/video/omap2/dss/dss.h | 5 +++++
drivers/video/omap2/dss/writeback.c | 14 ++++++++++++
include/video/omapdss.h | 4 ++++
4 files changed, 65 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 7a7b820..b2e4f6a 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -106,9 +106,16 @@ struct mgr_priv_data {
struct dss_lcd_mgr_config lcd_config;
};
+struct wb_priv_data {
+
+ bool user_info_dirty;
+ struct omap_dss_writeback_info user_info;
+};
+
static struct {
struct ovl_priv_data ovl_priv_data_array[MAX_DSS_OVERLAYS];
struct mgr_priv_data mgr_priv_data_array[MAX_DSS_MANAGERS];
+ struct wb_priv_data wb_priv_data;
bool irq_enabled;
} dss_data;
@@ -131,6 +138,11 @@ static struct mgr_priv_data *get_mgr_priv(struct omap_overlay_manager *mgr)
return &dss_data.mgr_priv_data_array[mgr->id];
}
+static struct wb_priv_data *get_wb_priv(struct omap_dss_output *wb)
+{
+ return &dss_data.wb_priv_data;
+}
+
void dss_apply_init(void)
{
const int num_ovls = dss_feat_get_num_ovls();
@@ -1465,3 +1477,33 @@ err:
return r;
}
+int dss_wb_set_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ unsigned long flags;
+
+ /* TODO: Check validity of info */
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ wp->user_info = *info;
+ wp->user_info_dirty = true;
+
+ spin_unlock_irqrestore(&data_lock, flags);
+
+ return 0;
+}
+
+void dss_wb_get_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ unsigned long flags;
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ *info = wp->user_info;
+
+ spin_unlock_irqrestore(&data_lock, flags);
+}
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index f7eb7d6..f738c1e 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -210,6 +210,11 @@ int dss_ovl_set_manager(struct omap_overlay *ovl,
struct omap_overlay_manager *mgr);
int dss_ovl_unset_manager(struct omap_overlay *ovl);
+int dss_wb_set_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info);
+void dss_wb_get_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info);
+
/* output */
void dss_register_output(struct omap_dss_output *out);
void dss_unregister_output(struct omap_dss_output *out);
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index b5c6406..be7027b 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -42,6 +42,20 @@ static inline struct platform_device *writeback_get_wbdev_from_output(struct oma
return out->pdev;
}
+int omapdss_writeback_set_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info)
+{
+ return dss_wb_set_info(wb, info);
+}
+EXPORT_SYMBOL(omapdss_writeback_set_info);
+
+void omapdss_writeback_get_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info)
+{
+ dss_wb_get_info(wb, info);
+}
+EXPORT_SYMBOL(omapdss_writeback_get_info);
+
struct omap_dss_output *omap_dss_get_writeback(void)
{
return omap_dss_get_output(OMAP_DSS_OUTPUT_WB);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index e81fcb2..2a3a878 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -837,6 +837,10 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+int omapdss_writeback_set_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info);
+void omapdss_writeback_get_info(struct omap_dss_output *wb,
+ struct omap_dss_writeback_info *info);
#ifdef CONFIG_OMAP4_DSS_WRITEBACK
struct omap_dss_output *omap_dss_get_writeback(void);
#else
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 03/11] OMAPDSS: APPLY: Apply writeback configurations
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
2012-11-07 14:56 ` [RFC 01/11] OMAPDSS: Add writeback output driver Archit Taneja
2012-11-07 14:56 ` [RFC 02/11] OMAPDSS: APPLY: Add get/set info functions for writeback Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 04/11] OMAPDSS: writeback: Configure writeback input size Archit Taneja
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
Add changes in apply to let a user apply writeback configurations. This
basically involves a writeback user to commit the writeback_info it has set
previously.
Only memory to memory mode is supported for now in APPLY. Actual register
writes would only happen when a mem to mem update is initiated. Therefore,
there isn't a need to support the cases of shadow registers being dirty.
Add the following:
- info and info_dirty fields in private data to represent the lower cache of
writeback info in APPLY.
- Function omap_dss_wb_apply which propagates user_info to info, and an
equivalent function in writeback output driver exposed to writeback users.
- Function dss_wb_write_regs to be used by APPLY to configure writeback DISPC
registers.
- Helper function which tells the mode of writeback.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 68 +++++++++++++++++++++++++++++++++++
drivers/video/omap2/dss/dss.h | 1 +
drivers/video/omap2/dss/writeback.c | 6 ++++
include/video/omapdss.h | 1 +
4 files changed, 76 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index b2e4f6a..76886da 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -110,6 +110,15 @@ struct wb_priv_data {
bool user_info_dirty;
struct omap_dss_writeback_info user_info;
+
+ bool info_dirty;
+ struct omap_dss_writeback_info info;
+
+ /*
+ * If true in memory to memory mode, a manager is connected to it.
+ * However, it may not be active.
+ */
+ bool enabled;
};
static struct {
@@ -209,6 +218,11 @@ static bool mgr_manual_update(struct omap_overlay_manager *mgr)
return mp->lcd_config.stallmode;
}
+static bool wb_manual_update(struct omap_dss_output *wb)
+{
+ return true;
+}
+
static int dss_check_settings_low(struct omap_overlay_manager *mgr,
bool applying)
{
@@ -684,6 +698,36 @@ static void dss_mgr_write_regs_extra(struct omap_overlay_manager *mgr)
mp->shadow_extra_info_dirty = true;
}
+static void dss_wb_write_regs(struct omap_dss_output *wb)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ struct omap_dss_writeback_info *wi;
+ struct mgr_priv_data *mp;
+ u32 fifo_low, fifo_high;
+ bool use_fifo_merge = false;
+ int r;
+
+ if (!wp->enabled || !wp->info_dirty)
+ return;
+
+ wi = &wp->info;
+
+ mp = get_mgr_priv(wb->manager);
+
+ dispc_ovl_compute_fifo_thresholds(OMAP_DSS_WB, &fifo_low, &fifo_high,
+ use_fifo_merge, wb_manual_update(wb));
+
+ dispc_ovl_set_fifo_threshold(OMAP_DSS_WB, fifo_low, fifo_high);
+
+ r = dispc_wb_setup(wi, wb_manual_update(wb), &mp->timings);
+ if (r) {
+ DSSERR("dispc_wb_setup failed %d\n", r);
+ return;
+ }
+
+ wp->info_dirty = false;
+}
+
static void dss_write_regs(void)
{
const int num_mgrs = omap_dss_get_num_overlay_managers();
@@ -1507,3 +1551,27 @@ void dss_wb_get_info(struct omap_dss_output *wb,
spin_unlock_irqrestore(&data_lock, flags);
}
+
+int omap_dss_wb_apply(struct omap_dss_output *wb)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ unsigned long flags;
+
+ DSSDBG("omap_dss_wb_apply\n");
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ /* check for settings here */
+
+ if (!wp->user_info_dirty)
+ goto end;
+
+ wp->user_info_dirty = false;
+ wp->info_dirty = true;
+ wp->info = wp->user_info;
+
+end:
+ spin_unlock_irqrestore(&data_lock, flags);
+
+ return 0;
+}
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index f738c1e..1b9c936 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -214,6 +214,7 @@ int dss_wb_set_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
void dss_wb_get_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
+int omap_dss_wb_apply(struct omap_dss_output *wb);
/* output */
void dss_register_output(struct omap_dss_output *out);
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index be7027b..c05dd54 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -42,6 +42,12 @@ static inline struct platform_device *writeback_get_wbdev_from_output(struct oma
return out->pdev;
}
+int omapdss_writeback_apply(struct omap_dss_output *wb)
+{
+ return omap_dss_wb_apply(wb);
+}
+EXPORT_SYMBOL(omapdss_writeback_apply);
+
int omapdss_writeback_set_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info)
{
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 2a3a878..2bc10cb 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -837,6 +837,7 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+int omapdss_writeback_apply(struct omap_dss_output *wb);
int omapdss_writeback_set_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
void omapdss_writeback_get_info(struct omap_dss_output *wb,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 04/11] OMAPDSS: writeback: Configure writeback input size
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (2 preceding siblings ...)
2012-11-07 14:56 ` [RFC 03/11] OMAPDSS: APPLY: Apply writeback configurations Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 05/11] OMAPDSS: APPLY: Add writeback enable/disable funcs Archit Taneja
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
The input to the writeback piepline comes from an overlay manager or an overlay
in mem to mem mode. In both cases the input size configured for writeback should
be the size of the overlay or overlay manager output.
We ignore the case of direct connections between an overlay and writeback for
now. Assuming that writeback output connected only to a manager, we need to
ensure that the manger dimensions change when the user tries to change
writeback's input size.
This is achieved by the output driver calling dss_mgr_set_timings. When applying
the manager timings, we also dirty the writeback_info cache so that the next
writeback update will incorporate the new manager timings. In effect, we don't
maintain private data/cache for the input size of writeback as it's always equal
to the manager's input size. However, we take care of updating the writeback
registers whenever we change the manager's input size.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 18 ++++++++++++++++++
drivers/video/omap2/dss/writeback.c | 31 +++++++++++++++++++++++++++++++
include/video/omapdss.h | 1 +
3 files changed, 50 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 76886da..8fe7fce 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -223,6 +223,11 @@ static bool wb_manual_update(struct omap_dss_output *wb)
return true;
}
+static bool output_is_wb(struct omap_dss_output *out)
+{
+ return out ? out->id = OMAP_DSS_OUTPUT_WB : false;
+}
+
static int dss_check_settings_low(struct omap_overlay_manager *mgr,
bool applying)
{
@@ -1226,6 +1231,19 @@ static void dss_apply_mgr_timings(struct omap_overlay_manager *mgr,
mp->timings = *timings;
mp->extra_info_dirty = true;
+
+ /*
+ * If the connected output is writeback, and if the width or height of
+ * the overlay manager change, writeback's input size needs to be
+ * changed too. Dirty the writeback info so that it's reconfigured
+ * along with the manager timings change.
+ */
+ if (output_is_wb(mgr->output)) {
+ struct omap_dss_output *wb = mgr->output;
+ struct wb_priv_data *wp = get_wb_priv(wb);
+
+ wp->info_dirty = true;
+ }
}
void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index c05dd54..9a80f72 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -30,6 +30,12 @@ struct writeback_data {
struct mutex lock;
struct omap_dss_output output;
+ /*
+ * timings of manager to which writeback is connected, only configured
+ * by writeback driver in mem to mem mode. In capture mode, manager
+ * timings will be configured by the display interface.
+ */
+ struct omap_video_timings input_timings;
};
static inline struct writeback_data *writeback_get_drv_data(struct platform_device *wbdev)
@@ -42,6 +48,23 @@ static inline struct platform_device *writeback_get_wbdev_from_output(struct oma
return out->pdev;
}
+void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ mutex_lock(&wb_data->lock);
+
+ wb_data->input_timings.x_res = w;
+ wb_data->input_timings.y_res = h;
+
+ if (wb->manager)
+ dss_mgr_set_timings(wb->manager, &wb_data->input_timings);
+
+ mutex_unlock(&wb_data->lock);
+}
+EXPORT_SYMBOL(omapdss_writeback_set_input_size);
+
int omapdss_writeback_apply(struct omap_dss_output *wb)
{
return omap_dss_wb_apply(wb);
@@ -92,6 +115,14 @@ static int __init omap_writeback_probe(struct platform_device *pdev)
mutex_init(&wb_data->lock);
+ /* initialize with dummy timings */
+ wb_data->input_timings = (struct omap_video_timings)
+ { 640, 480, 0, 1, 1, 1, 1, 0, 0, false,
+ OMAPDSS_SIG_ACTIVE_HIGH, OMAPDSS_SIG_ACTIVE_HIGH,
+ OMAPDSS_DRIVE_SIG_RISING_EDGE, OMAPDSS_SIG_ACTIVE_HIGH,
+ OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
+ };
+
writeback_init_output(pdev, wb_data);
return 0;
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 2bc10cb..d8064ed 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -837,6 +837,7 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h);
int omapdss_writeback_apply(struct omap_dss_output *wb);
int omapdss_writeback_set_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 05/11] OMAPDSS: APPLY: Add writeback enable/disable funcs
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (3 preceding siblings ...)
2012-11-07 14:56 ` [RFC 04/11] OMAPDSS: writeback: Configure writeback input size Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 06/11] OMAPDSS: APPLY: configure channel_in for writeback Archit Taneja
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
Add dss_wb_enable/dss_wb_disable funcs in APPLY similar to that of manager's
enable/disable functions. Since, these functions support only writeback in
memory to memory mode, their job is reduced to just setting the private enable
parameter correctly.
Writeback can't be enabled if the manager it is connected to is not enabled
first. dss_wb_enable makes sure that the connected manager is enabled,
dss_wb_disable doesn't have much dependency on whether the connected manager
is disabled before or after.
Add corresponding enable/disable functions in the output driver which the
writeback user will use. The output driver enable function also takes the
responsibility of configuring and enabling the connected manager. The function
writeback_configure_manager configures the manager in stall mode and sets
the dimensions to the desired writeback input size. The output driver disable
functions disables both manager and writeback.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 70 +++++++++++++++++++++++++++++++++++
drivers/video/omap2/dss/dss.h | 2 +
drivers/video/omap2/dss/writeback.c | 63 +++++++++++++++++++++++++++++++
include/video/omapdss.h | 2 +
4 files changed, 137 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 8fe7fce..1ab1755 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -1593,3 +1593,73 @@ end:
return 0;
}
+
+int dss_wb_enable(struct omap_dss_output *wb)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ struct mgr_priv_data *mp;
+ unsigned long flags;
+ int r;
+
+ mutex_lock(&apply_lock);
+
+ if (wp->enabled) {
+ r = 0;
+ goto out;
+ }
+
+ if (wb->manager = NULL) {
+ DSSERR("can't enable writeback without a manager\n");
+ r = -EINVAL;
+ goto out;
+ }
+
+ mp = get_mgr_priv(wb->manager);
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ if (!mp->enabled) {
+ DSSERR("can't enable writeback with a disabled manager\n");
+ r = -EINVAL;
+ goto err;
+ }
+
+ wp->enabled = true;
+
+ /*
+ * TODO: check settings here, if we fail, set wp->enabled back to
+ * false
+ */
+
+ spin_unlock_irqrestore(&data_lock, flags);
+
+ mutex_unlock(&apply_lock);
+
+ return 0;
+err:
+ spin_unlock_irqrestore(&data_lock, flags);
+out:
+ mutex_unlock(&apply_lock);
+
+ return r;
+}
+
+void dss_wb_disable(struct omap_dss_output *wb)
+{
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ unsigned long flags;
+
+ mutex_lock(&apply_lock);
+
+ if (!wp->enabled)
+ goto out;
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ wp->updating = false;
+ wp->enabled = false;
+
+ spin_unlock_irqrestore(&data_lock, flags);
+out:
+ mutex_unlock(&apply_lock);
+}
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 1b9c936..6238895 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -215,6 +215,8 @@ int dss_wb_set_info(struct omap_dss_output *wb,
void dss_wb_get_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
int omap_dss_wb_apply(struct omap_dss_output *wb);
+int dss_wb_enable(struct omap_dss_output *wb);
+void dss_wb_disable(struct omap_dss_output *wb);
/* output */
void dss_register_output(struct omap_dss_output *out);
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index 9a80f72..598defd 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -65,6 +65,69 @@ void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h)
}
EXPORT_SYMBOL(omapdss_writeback_set_input_size);
+static void writeback_config_manager(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+ struct dss_lcd_mgr_config lcd_config;
+
+ dss_mgr_set_timings(wb->manager, &wb_data->input_timings);
+
+ lcd_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
+ lcd_config.stallmode = true;
+ lcd_config.fifohandcheck = false;
+ lcd_config.clock_info.lck_div = 1;
+ lcd_config.clock_info.pck_div = 1;
+ lcd_config.video_port_width = 24;
+ lcd_config.lcden_sig_polarity = false;
+
+ /*
+ * apply lcd_config such that manager appears to be in stallmode, this
+ * makes the manager operate in manual update mode
+ */
+ dss_mgr_set_lcd_config(wb->manager, &lcd_config);
+
+ dss_mgr_enable(wb->manager);
+}
+
+int omapdss_writeback_enable(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+ int r;
+
+ mutex_lock(&wb_data->lock);
+
+ r = dispc_runtime_get();
+ if (r)
+ goto err;
+
+ writeback_config_manager(wb);
+
+ r = dss_wb_enable(wb);
+err:
+ mutex_unlock(&wb_data->lock);
+
+ return r;
+}
+EXPORT_SYMBOL(omapdss_writeback_enable);
+
+void omapdss_writeback_disable(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ mutex_lock(&wb_data->lock);
+
+ dss_wb_disable(wb);
+ dss_mgr_disable(wb->manager);
+
+ dispc_runtime_put();
+
+ mutex_unlock(&wb_data->lock);
+}
+EXPORT_SYMBOL(omapdss_writeback_disable);
+
int omapdss_writeback_apply(struct omap_dss_output *wb)
{
return omap_dss_wb_apply(wb);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index d8064ed..f63c0cb 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -837,6 +837,8 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+int omapdss_writeback_enable(struct omap_dss_output *wb);
+void omapdss_writeback_disable(struct omap_dss_output *wb);
void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h);
int omapdss_writeback_apply(struct omap_dss_output *wb);
int omapdss_writeback_set_info(struct omap_dss_output *wb,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 06/11] OMAPDSS: APPLY: configure channel_in for writeback
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (4 preceding siblings ...)
2012-11-07 14:56 ` [RFC 05/11] OMAPDSS: APPLY: Add writeback enable/disable funcs Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 07/11] OMAPDSS: writeback: add mechanism to do mem to mem updates Archit Taneja
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
writeback's input is configured by the CHANNELIN field in DISPC_WB_ATTRIBUTES.
It's an immediate write register field. We need to change writeback's channel
in whenever the manager to which it is connected changes.
When changing managers for overlays, we needed to be certain that the overlay
was disabled. We added some extra waits for that. However, such a thing isn't
required for writeback as it's disabled for sure after we call dss_wb_disable.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 31 +++++++++++++++++++++++++++++++
drivers/video/omap2/dss/dss.h | 9 +++++++++
drivers/video/omap2/dss/writeback.c | 23 +++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 1ab1755..a205ed4 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -1175,6 +1175,22 @@ int dss_mgr_set_output(struct omap_overlay_manager *mgr,
goto err;
}
+ if (output_is_wb(output)) {
+ enum dss_writeback_channel channel;
+
+ r = dss_writeback_calc_channel_in(mgr, &channel);
+ if (r)
+ goto err;
+
+ r = dispc_runtime_get();
+ if (r)
+ goto err;
+
+ dispc_wb_set_channel_in(channel);
+
+ dispc_runtime_put();
+ }
+
output->manager = mgr;
mgr->output = output;
@@ -1210,6 +1226,21 @@ int dss_mgr_unset_output(struct omap_overlay_manager *mgr)
spin_unlock_irqrestore(&data_lock, flags);
+ if (output_is_wb(mgr->output)) {
+ struct omap_dss_output *wb = mgr->output;
+ struct wb_priv_data *wp = get_wb_priv(wb);
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ if (wp->enabled) {
+ DSSERR("WB output can't be unset when enabled\n");
+ r = -EINVAL;
+ goto err1;
+ }
+
+ spin_unlock_irqrestore(&data_lock, flags);
+ }
+
mgr->output->manager = NULL;
mgr->output = NULL;
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 6238895..f9e7074 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -540,6 +540,15 @@ int hdmi_audio_config(struct omap_dss_audio *audio);
#ifdef CONFIG_OMAP4_DSS_WRITEBACK
int writeback_init_platform_driver(void) __init;
void writeback_uninit_platform_driver(void) __exit;
+int dss_writeback_calc_channel_in(struct omap_overlay_manager *mgr,
+ enum dss_writeback_channel *channel);
+#else
+static inline int dss_writeback_calc_channel_in(struct omap_overlay_manager *mgr,
+ enum dss_writeback_channel *channel)
+{
+ WARN("%s: WB not compiled in, returning 0\n", __func__);
+ return 0;
+}
#endif
/* RFBI */
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index 598defd..09394fb 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -48,6 +48,29 @@ static inline struct platform_device *writeback_get_wbdev_from_output(struct oma
return out->pdev;
}
+int dss_writeback_calc_channel_in(struct omap_overlay_manager *mgr,
+ enum dss_writeback_channel *channel)
+{
+ /*
+ * Add a case for dummy writeback manager once we support connecting
+ * writeback directly to an overlay.
+ */
+ switch (mgr->id) {
+ case OMAP_DSS_CHANNEL_DIGIT:
+ *channel = DSS_WB_TV_MGR;
+ break;
+ case OMAP_DSS_CHANNEL_LCD2:
+ *channel = DSS_WB_LCD2_MGR;
+ break;
+ case OMAP_DSS_CHANNEL_LCD:
+ default:
+ *channel = DSS_WB_LCD1_MGR;
+ break;
+ }
+
+ return 0;
+}
+
void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h)
{
struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 07/11] OMAPDSS: writeback: add mechanism to do mem to mem updates
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (5 preceding siblings ...)
2012-11-07 14:56 ` [RFC 06/11] OMAPDSS: APPLY: configure channel_in for writeback Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 08/11] OMAPDSS: APPLY: Check if overlay is connected in mem to mem mode Archit Taneja
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
writeback in mem to mem mode works like an overlay manager connected to a
display in stallmode. When we set ENABLE in DISPC_WB_ATTRIBUTES writeback, it
starts a mem to mem transfer. On completion, we get a FRAMEDONEWB interrupt and
the ENABLE bit is cleared by HW.
In APPLY, we add dss_wb_start_update, this function is similar to
dss_mgr_start_update, but is responsible for configuring both the manager(and
the overlays connected to it) and the writeback registers. We add an updating
field in the writeback private data which tells APPLY when we are busy and
when we are done with a mem to mem transfer. We register to the framedone isr
when needed and we update the updating field in dss_apply_irq_handler when we
are done with the transfer.
In the writeback output driver, we add a semaphore based way to lock the
writeback resource as we do in DSI command mode. The writeback user is expected
to lock the bus, call omapdss_writeback_update and mention a callback along with
it, and unlock the bus in the callback. omapdss_writeback_update registers to
the FRAMEDONE interrupt to trigger the callback and starts the update by calling
the corresponding APPLY function.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 83 +++++++++++++++++++++++++++
drivers/video/omap2/dss/dss.h | 1 +
drivers/video/omap2/dss/writeback.c | 106 +++++++++++++++++++++++++++++++++++
include/video/omapdss.h | 4 ++
4 files changed, 194 insertions(+)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index a205ed4..2fd08d8 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -114,6 +114,9 @@ struct wb_priv_data {
bool info_dirty;
struct omap_dss_writeback_info info;
+ /* If true, writeback output is enabled */
+ bool updating;
+
/*
* If true in memory to memory mode, a manager is connected to it.
* However, it may not be active.
@@ -285,6 +288,7 @@ static int dss_check_settings_apply(struct omap_overlay_manager *mgr)
static bool need_isr(void)
{
const int num_mgrs = dss_feat_get_num_mgrs();
+ const int num_wbs = dss_feat_get_num_wbs();
int i;
for (i = 0; i < num_mgrs; ++i) {
@@ -362,6 +366,20 @@ static bool need_isr(void)
}
}
+ for (i = 0; i < num_wbs; i++) {
+ struct omap_dss_output *wb = omap_dss_get_writeback();
+ struct wb_priv_data *wp = get_wb_priv(wb);
+
+ if (!wp->enabled)
+ continue;
+
+ if (wb_manual_update(wb)) {
+ /* to catch FRAMEDONEWB */
+ if (wp->updating)
+ return true;
+ }
+ }
+
return false;
}
@@ -841,6 +859,7 @@ static void dss_apply_irq_handler(void *data, u32 mask);
static void dss_register_vsync_isr(void)
{
const int num_mgrs = dss_feat_get_num_mgrs();
+ const int num_wbs = dss_feat_get_num_wbs();
u32 mask;
int r, i;
@@ -851,6 +870,9 @@ static void dss_register_vsync_isr(void)
for (i = 0; i < num_mgrs; ++i)
mask |= dispc_mgr_get_framedone_irq(i);
+ for (i = 0; i < num_wbs; i++)
+ mask |= dispc_wb_get_framedone_irq();
+
r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask);
WARN_ON(r);
@@ -860,6 +882,7 @@ static void dss_register_vsync_isr(void)
static void dss_unregister_vsync_isr(void)
{
const int num_mgrs = dss_feat_get_num_mgrs();
+ const int num_wbs = dss_feat_get_num_wbs();
u32 mask;
int r, i;
@@ -870,6 +893,9 @@ static void dss_unregister_vsync_isr(void)
for (i = 0; i < num_mgrs; ++i)
mask |= dispc_mgr_get_framedone_irq(i);
+ for (i = 0; i < num_wbs; i++)
+ mask |= dispc_wb_get_framedone_irq();
+
r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask);
WARN_ON(r);
@@ -879,6 +905,7 @@ static void dss_unregister_vsync_isr(void)
static void dss_apply_irq_handler(void *data, u32 mask)
{
const int num_mgrs = dss_feat_get_num_mgrs();
+ const int num_wbs = dss_feat_get_num_wbs();
int i;
bool extra_updating;
@@ -906,6 +933,16 @@ static void dss_apply_irq_handler(void *data, u32 mask)
}
}
+ for (i = 0; i < num_wbs; i++) {
+ struct omap_dss_output *wb = omap_dss_get_writeback();
+ struct wb_priv_data *wp = get_wb_priv(wb);
+
+ if (!wp->enabled)
+ continue;
+
+ wp->updating = dispc_wb_is_enabled();
+ }
+
dss_write_regs();
dss_set_go_bits();
@@ -1685,6 +1722,11 @@ void dss_wb_disable(struct omap_dss_output *wb)
if (!wp->enabled)
goto out;
+ if (wp->updating) {
+ DSSERR("can't disable writeback in the middle of an update\n");
+ goto out;
+ }
+
spin_lock_irqsave(&data_lock, flags);
wp->updating = false;
@@ -1694,3 +1736,44 @@ void dss_wb_disable(struct omap_dss_output *wb)
out:
mutex_unlock(&apply_lock);
}
+
+/*
+ * When doing a writeback mem to mem update, the updating field for writeback
+ * private data is true, but for manager private data the updating field is
+ * false. This is because a manager isn't really 'enabled' in HW, it's the
+ * writeback pipeline which initiates the transfer.
+ */
+void dss_wb_start_update(struct omap_dss_output *wb)
+{
+ struct omap_overlay_manager *mgr = wb->manager;
+ struct wb_priv_data *wp = get_wb_priv(wb);
+ unsigned long flags;
+ int r;
+
+ spin_lock_irqsave(&data_lock, flags);
+
+ WARN_ON(wp->updating);
+
+ /* add some similar check for writeback later */
+
+ r = dss_check_settings(mgr);
+ if (r) {
+ DSSERR("cannot start manual update: illegal configuration\n");
+ spin_unlock_irqrestore(&data_lock, flags);
+ return;
+ }
+
+ dss_wb_write_regs(wb);
+
+ dss_mgr_write_regs(mgr);
+ dss_mgr_write_regs_extra(mgr);
+
+ wp->updating = true;
+
+ if (!dss_data.irq_enabled && need_isr())
+ dss_register_vsync_isr();
+
+ dispc_wb_enable(true);
+
+ spin_unlock_irqrestore(&data_lock, flags);
+}
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index f9e7074..8c70b08 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -217,6 +217,7 @@ void dss_wb_get_info(struct omap_dss_output *wb,
int omap_dss_wb_apply(struct omap_dss_output *wb);
int dss_wb_enable(struct omap_dss_output *wb);
void dss_wb_disable(struct omap_dss_output *wb);
+void dss_wb_start_update(struct omap_dss_output *wb);
/* output */
void dss_register_output(struct omap_dss_output *out);
diff --git a/drivers/video/omap2/dss/writeback.c b/drivers/video/omap2/dss/writeback.c
index 09394fb..7a25e99 100644
--- a/drivers/video/omap2/dss/writeback.c
+++ b/drivers/video/omap2/dss/writeback.c
@@ -20,6 +20,8 @@
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/module.h>
+#include <linux/semaphore.h>
+#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <video/omapdss.h>
@@ -27,7 +29,15 @@
#include "dss.h"
struct writeback_data {
+ struct platform_device *pdev;
+
struct mutex lock;
+ struct semaphore bus_lock;
+
+ void (*framedone_callback)(int, void *);
+ void *framedone_data;
+
+ struct delayed_work framedone_timeout_work;
struct omap_dss_output output;
/*
@@ -71,6 +81,32 @@ int dss_writeback_calc_channel_in(struct omap_overlay_manager *mgr,
return 0;
}
+void omapdss_writeback_bus_lock(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ down(&wb_data->bus_lock);
+}
+EXPORT_SYMBOL(omapdss_writeback_bus_lock);
+
+void omapdss_writeback_bus_unlock(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ up(&wb_data->bus_lock);
+}
+EXPORT_SYMBOL(omapdss_writeback_bus_unlock);
+
+static bool writeback_bus_is_locked(struct omap_dss_output *wb)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ return wb_data->bus_lock.count = 0;
+}
+
void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h)
{
struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
@@ -88,11 +124,39 @@ void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h)
}
EXPORT_SYMBOL(omapdss_writeback_set_input_size);
+static void writeback_handle_framedone(struct platform_device *wbdev, int error)
+{
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ wb_data->framedone_callback(error, wb_data->framedone_data);
+}
+
+static void writeback_framedone_timeout_work_callback(struct work_struct *work)
+{
+ struct writeback_data *wb_data = container_of(work,
+ struct writeback_data, framedone_timeout_work.work);
+
+ DSSERR("FRAMEDONE WB not received for 100ms\n");
+
+ writeback_handle_framedone(wb_data->pdev, -ETIMEDOUT);
+}
+
+static void writeback_framedone_irq_callback(void *data, u32 mask)
+{
+ struct platform_device *wbdev = (struct platform_device *) data;
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+
+ cancel_delayed_work(&wb_data->framedone_timeout_work);
+
+ writeback_handle_framedone(wb_data->pdev, 0);
+}
+
static void writeback_config_manager(struct omap_dss_output *wb)
{
struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
struct dss_lcd_mgr_config lcd_config;
+ int r;
dss_mgr_set_timings(wb->manager, &wb_data->input_timings);
@@ -110,6 +174,11 @@ static void writeback_config_manager(struct omap_dss_output *wb)
*/
dss_mgr_set_lcd_config(wb->manager, &lcd_config);
+ r = omap_dispc_register_isr(writeback_framedone_irq_callback,
+ (void *) wbdev, DISPC_IRQ_FRAMEDONEWB);
+ if (r)
+ DSSERR("Failed to register for FRAMEDONEWB irq\n");
+
dss_mgr_enable(wb->manager);
}
@@ -119,6 +188,8 @@ int omapdss_writeback_enable(struct omap_dss_output *wb)
struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
int r;
+ WARN_ON(!writeback_bus_is_locked(wb));
+
mutex_lock(&wb_data->lock);
r = dispc_runtime_get();
@@ -139,18 +210,48 @@ void omapdss_writeback_disable(struct omap_dss_output *wb)
{
struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+ int r;
+
+ WARN_ON(!writeback_bus_is_locked(wb));
mutex_lock(&wb_data->lock);
dss_wb_disable(wb);
dss_mgr_disable(wb->manager);
+ r = omap_dispc_unregister_isr(writeback_framedone_irq_callback,
+ (void *) wbdev, DISPC_IRQ_FRAMEDONEWB);
+ if (r)
+ DSSERR("Failed to unregister FRAMEDONEWB irq\n");
+
dispc_runtime_put();
mutex_unlock(&wb_data->lock);
}
EXPORT_SYMBOL(omapdss_writeback_disable);
+int omapdss_writeback_update(struct omap_dss_output *wb,
+ void (*callback)(int, void *), void *data)
+{
+ struct platform_device *wbdev = writeback_get_wbdev_from_output(wb);
+ struct writeback_data *wb_data = writeback_get_drv_data(wbdev);
+ int r;
+
+ WARN_ON(!writeback_bus_is_locked(wb));
+
+ wb_data->framedone_callback = callback;
+ wb_data->framedone_data = data;
+
+ r = schedule_delayed_work(&wb_data->framedone_timeout_work,
+ msecs_to_jiffies(100));
+ BUG_ON(r = 0);
+
+ dss_wb_start_update(wb);
+
+ return 0;
+}
+EXPORT_SYMBOL(omapdss_writeback_update);
+
int omapdss_writeback_apply(struct omap_dss_output *wb)
{
return omap_dss_wb_apply(wb);
@@ -199,7 +300,12 @@ static int __init omap_writeback_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, wb_data);
+ wb_data->pdev = pdev;
mutex_init(&wb_data->lock);
+ sema_init(&wb_data->bus_lock, 1);
+
+ INIT_DEFERRABLE_WORK(&wb_data->framedone_timeout_work,
+ writeback_framedone_timeout_work_callback);
/* initialize with dummy timings */
wb_data->input_timings = (struct omap_video_timings)
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index f63c0cb..c7f3ac7 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -837,9 +837,13 @@ void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
struct rfbi_timings *timings);
+void omapdss_writeback_bus_lock(struct omap_dss_output *wb);
+void omapdss_writeback_bus_unlock(struct omap_dss_output *wb);
int omapdss_writeback_enable(struct omap_dss_output *wb);
void omapdss_writeback_disable(struct omap_dss_output *wb);
void omapdss_writeback_set_input_size(struct omap_dss_output *wb, u16 w, u16 h);
+int omapdss_writeback_update(struct omap_dss_output *wb,
+ void (*callback)(int, void *), void *data);
int omapdss_writeback_apply(struct omap_dss_output *wb);
int omapdss_writeback_set_info(struct omap_dss_output *wb,
struct omap_dss_writeback_info *info);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 08/11] OMAPDSS: APPLY: Check if overlay is connected in mem to mem mode
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (6 preceding siblings ...)
2012-11-07 14:56 ` [RFC 07/11] OMAPDSS: writeback: add mechanism to do mem to mem updates Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 09/11] OMAPDSS: FEATURES: Add writeback as supported outputs for OMAP4 managers Archit Taneja
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
When a manager is connected to writeback in mem to mem mode, all the connected
fetch and process data at rate suitable for the scalar to perform the required
downscaling. This is because there isn't any display connected here, and hence
no real time constraints. When calling dispc_ovl_setup, pass the correct value
of mem_to_mem parameter so that it can discard pixel clock related scaling
limitations.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/apply.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 2fd08d8..e1c589c 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -615,10 +615,13 @@ int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl)
static void dss_ovl_write_regs(struct omap_overlay *ovl)
{
+ struct omap_overlay_manager *mgr = ovl->manager;
+ struct omap_dss_output *out = mgr->output;
struct ovl_priv_data *op = get_ovl_priv(ovl);
struct omap_overlay_info *oi;
bool replication;
struct mgr_priv_data *mp;
+ bool mem_to_mem;
int r;
DSSDBG("writing ovl %d regs", ovl->id);
@@ -628,11 +631,13 @@ static void dss_ovl_write_regs(struct omap_overlay *ovl)
oi = &op->info;
- mp = get_mgr_priv(ovl->manager);
+ mp = get_mgr_priv(mgr);
replication = dss_ovl_use_replication(mp->lcd_config, oi->color_mode);
- r = dispc_ovl_setup(ovl->id, oi, replication, &mp->timings, false);
+ mem_to_mem = output_is_wb(out) ? wb_manual_update(out) : false;
+
+ r = dispc_ovl_setup(ovl->id, oi, replication, &mp->timings, mem_to_mem);
if (r) {
/*
* We can't do much here, as this function can be called from
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 09/11] OMAPDSS: FEATURES: Add writeback as supported outputs for OMAP4 managers
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (7 preceding siblings ...)
2012-11-07 14:56 ` [RFC 08/11] OMAPDSS: APPLY: Check if overlay is connected in mem to mem mode Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 10/11] ARCH: ARM: OMAP: Create a platform device for writeback Archit Taneja
2012-11-07 14:56 ` [RFC 11/11] Example: OMAPFB: clear framebuffers using writeback Archit Taneja
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
The writeback pipeline can connect to any of the OMAP4 overlay managers. Add it
as a supported output in dss features.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/dss/dss_features.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/video/omap2/dss/dss_features.c b/drivers/video/omap2/dss/dss_features.c
index 3e8287c..e8d10cb 100644
--- a/drivers/video/omap2/dss/dss_features.c
+++ b/drivers/video/omap2/dss/dss_features.c
@@ -202,15 +202,15 @@ static const enum omap_dss_output_id omap3630_dss_supported_outputs[] = {
static const enum omap_dss_output_id omap4_dss_supported_outputs[] = {
/* OMAP_DSS_CHANNEL_LCD */
OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
- OMAP_DSS_OUTPUT_DSI1,
+ OMAP_DSS_OUTPUT_DSI1 | OMAP_DSS_OUTPUT_WB,
/* OMAP_DSS_CHANNEL_DIGIT */
OMAP_DSS_OUTPUT_VENC | OMAP_DSS_OUTPUT_HDMI |
- OMAP_DSS_OUTPUT_DPI,
+ OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_WB,
/* OMAP_DSS_CHANNEL_LCD2 */
OMAP_DSS_OUTPUT_DPI | OMAP_DSS_OUTPUT_DBI |
- OMAP_DSS_OUTPUT_DSI2,
+ OMAP_DSS_OUTPUT_DSI2 | OMAP_DSS_OUTPUT_WB,
};
static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 10/11] ARCH: ARM: OMAP: Create a platform device for writeback
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (8 preceding siblings ...)
2012-11-07 14:56 ` [RFC 09/11] OMAPDSS: FEATURES: Add writeback as supported outputs for OMAP4 managers Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
2012-11-07 14:56 ` [RFC 11/11] Example: OMAPFB: clear framebuffers using writeback Archit Taneja
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
writeback is a like DPI in the sense that it's completelty a part of DISPC.
Hence it doesn't have it's own resource, or a hwmod entity tied to it.
Create a simple platfrom device for writeback in omap_display_init. Set the
parent to the omapdss_dss platform device like done for other DSS submodules.
Signed-off-by: Archit Taneja <archit@ti.com>
---
arch/arm/mach-omap2/display.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 282c814e..2e01b61 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -414,6 +414,15 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
}
}
+ if (cpu_is_omap44xx()) {
+ pdev = create_simple_dss_pdev("omapdss_writeback", -1,
+ NULL, 0, dss_pdev);
+ if (IS_ERR(pdev)) {
+ pr_err("Could not build platform_device for omapdss_writeback\n");
+ return PTR_ERR(pdev);
+ }
+ }
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 11/11] Example: OMAPFB: clear framebuffers using writeback
2012-11-07 14:56 [RFC 00/11] OMAPDSS: Add writeback mem to mem mode support Archit Taneja
` (9 preceding siblings ...)
2012-11-07 14:56 ` [RFC 10/11] ARCH: ARM: OMAP: Create a platform device for writeback Archit Taneja
@ 2012-11-07 14:56 ` Archit Taneja
10 siblings, 0 replies; 12+ messages in thread
From: Archit Taneja @ 2012-11-07 14:56 UTC (permalink / raw)
To: tomi.valkeinen; +Cc: linux-fbdev, linux-omap, Archit Taneja
This is an example to demonstrate how writeback is used to clear framebuffers.
The function omapfb_clear_fb_writeback is added as an alternative to the MPU
intensive function cfb_fillrect.
The writeback is attached to a free manager which has no overlays connected to
it, the manager's default color is set to black, and the size of both writeback
and manager are set to the framebuffer size. writeback_info is configured to
write the manager's output to the framebuffer address, and a mem to me update is
done.
This currently isn't full proof as it the logic of getting a free manager isn't
optimal yet and has a few corner cases.
Signed-off-by: Archit Taneja <archit@ti.com>
---
drivers/video/omap2/omapfb/omapfb-main.c | 132 +++++++++++++++++++++++++++++-
1 file changed, 131 insertions(+), 1 deletion(-)
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index be9096c..680f1eb 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -1590,8 +1590,131 @@ static int omapfb_allocate_all_fbs(struct omapfb2_device *fbdev)
return 0;
}
+static struct omap_overlay_manager *get_free_manager(struct fb_info *fbi)
+{
+ struct omapfb_info *ofbi = FB2OFB(fbi);
+ struct omapfb2_device *fbdev = ofbi->fbdev;
+ struct omap_overlay *ovl;
+ struct omap_overlay_manager *mgr, *def_mgr;
+ int i;
+
+ ovl = omap_dss_get_overlay(0);
+ def_mgr = ovl->manager;
+
+ for (i = 0; i < fbdev->num_managers; i++) {
+ mgr = fbdev->managers[i];
+ if (mgr != def_mgr)
+ return mgr;
+ }
+
+ return NULL;
+}
+
+static void wb_callback(int err, void *data)
+{
+ struct omap_dss_output *wb = (struct omap_dss_output *) data;
+
+ omapdss_writeback_bus_unlock(wb);
+}
+
+static int omapfb_clear_fb_writeback(struct fb_info *fbi)
+{
+ struct fb_var_screeninfo *var = &fbi->var;
+ struct fb_fix_screeninfo *fix = &fbi->fix;
+ struct omapfb_info *ofbi = FB2OFB(fbi);
+ struct omap_overlay_manager *mgr = NULL;
+ struct omap_overlay_manager_info mgr_info;
+ struct omap_dss_output *wb, *orig_out = NULL;
+ struct omap_dss_writeback_info wb_info;
+ enum omap_color_mode mode;
+ u32 data_start_p = 0;
+ int r;
+
+ wb = omap_dss_get_writeback();
+ if (!wb)
+ return -ENODEV;
+
+ /* find the first unused overlay manager */
+ mgr = get_free_manager(fbi);
+ if (!mgr)
+ return -ENODEV;
+
+ /* free the manager output */
+ if (mgr->output) {
+ orig_out = mgr->output;
+ mgr->unset_output(mgr);
+ }
+
+ /* get framebuffer color mode */
+ r = fb_mode_to_dss_mode(var, &mode);
+ if (r)
+ return r;
+
+ /* calculate framebuffer buffer address */
+ if (ofbi->region->size)
+ omapfb_calc_addr(ofbi, var, fix, 0, &data_start_p);
+
+ /* link the free overlay manager to writeback */
+ mgr->set_output(mgr, wb);
+
+ omapdss_writeback_bus_lock(wb);
+
+ /* enable writeback to configure writeback and overlay manager params */
+ omapdss_writeback_enable(wb);
+
+ /* configure and apply manager info to set default color to zero */
+ mgr->get_manager_info(mgr, &mgr_info);
+
+ mgr_info.default_color = 0x0;
+
+ mgr->set_manager_info(mgr, &mgr_info);
+
+ mgr->apply(mgr);
+
+ /*
+ * configure writeback parameters to write manager output to
+ * framebuffer
+ */
+ omapdss_writeback_set_input_size(wb, fbi->var.xres_virtual,
+ fbi->var.yres_virtual);
+
+ omapdss_writeback_get_info(wb, &wb_info);
+
+ wb_info.paddr = data_start_p;
+ wb_info.rotation_type = OMAP_DSS_ROT_DMA;
+ wb_info.rotation = 0;
+ wb_info.mirror = 0;
+ wb_info.width = fbi->var.xres_virtual;
+ wb_info.buf_width = fbi->var.xres_virtual;
+ wb_info.height = fbi->var.yres_virtual;
+ wb_info.color_mode = mode;
+
+ omapdss_writeback_set_info(wb, &wb_info);
+
+ omapdss_writeback_apply(wb);
+
+ /* start writeback update */
+ omapdss_writeback_update(wb, wb_callback, wb);
+
+ omapdss_writeback_bus_lock(wb);
+
+ /* disable writeback(and the connected manager) */
+ omapdss_writeback_disable(wb);
+
+ omapdss_writeback_bus_unlock(wb);
+
+ /* restore manager back to it's old state */
+ mgr->unset_output(mgr);
+
+ if (orig_out)
+ mgr->set_output(mgr, orig_out);
+
+ return 0;
+}
+
static void omapfb_clear_fb(struct fb_info *fbi)
{
+ int r;
const struct fb_fillrect rect = {
.dx = 0,
.dy = 0,
@@ -1601,7 +1724,14 @@ static void omapfb_clear_fb(struct fb_info *fbi)
.rop = ROP_COPY,
};
- cfb_fillrect(fbi, &rect);
+ r = omapfb_clear_fb_writeback(fbi);
+
+ /*
+ * if clearing through writeback failed, revert to clearing the
+ * framebuffer through MPU
+ */
+ if (r)
+ cfb_fillrect(fbi, &rect);
}
int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread