diff options
| author | Lajos Molnar <molnar@ti.com> | 2011-06-09 19:45:37 -0400 |
|---|---|---|
| committer | Paolo Pisati <paolo.pisati@canonical.com> | 2012-08-17 04:19:04 -0400 |
| commit | 53a38170c2d3adabe594443f99d473a4056cfbc3 (patch) | |
| tree | fe6cf30fb73c18ba3b2775fc410b5a8e623b471b /drivers/media | |
| parent | c97b88faa32b594be8048b19fd8273358087e9f4 (diff) | |
TILER: Implement tcm_clear, and initialize TILER container
Implement tcm_clear and initialize TILER container to a blank
page. This eliminates problems from reading into an unmapped TILER
page that can happen with 3rd party applications.
Signed-off-by: Lajos Molnar <molnar@ti.com>
Signed-off-by: Andy Gross <andy.gross@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Diffstat (limited to 'drivers/media')
| -rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 8 | ||||
| -rw-r--r-- | drivers/media/video/tiler/tmm-pat.c | 31 | ||||
| -rw-r--r-- | drivers/media/video/tiler/tmm.h | 2 |
3 files changed, 36 insertions, 5 deletions
diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index 69e79c30319..cfba30b92af 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c | |||
| @@ -1125,6 +1125,7 @@ static s32 __init tiler_init(void) | |||
| 1125 | struct tcm_pt div_pt; | 1125 | struct tcm_pt div_pt; |
| 1126 | struct tcm *sita = NULL; | 1126 | struct tcm *sita = NULL; |
| 1127 | struct tmm *tmm_pat = NULL; | 1127 | struct tmm *tmm_pat = NULL; |
| 1128 | struct pat_area area = {0}; | ||
| 1128 | 1129 | ||
| 1129 | tiler.alloc = alloc_block; | 1130 | tiler.alloc = alloc_block; |
| 1130 | tiler.map = map_block; | 1131 | tiler.map = map_block; |
| @@ -1171,12 +1172,17 @@ static s32 __init tiler_init(void) | |||
| 1171 | tcm[TILFMT_PAGE] = sita; | 1172 | tcm[TILFMT_PAGE] = sita; |
| 1172 | 1173 | ||
| 1173 | /* Allocate tiler memory manager (must have 1 unique TMM per TCM ) */ | 1174 | /* Allocate tiler memory manager (must have 1 unique TMM per TCM ) */ |
| 1174 | tmm_pat = tmm_pat_init(0); | 1175 | tmm_pat = tmm_pat_init(0, dmac_va, dmac_pa); |
| 1175 | tmm[TILFMT_8BIT] = tmm_pat; | 1176 | tmm[TILFMT_8BIT] = tmm_pat; |
| 1176 | tmm[TILFMT_16BIT] = tmm_pat; | 1177 | tmm[TILFMT_16BIT] = tmm_pat; |
| 1177 | tmm[TILFMT_32BIT] = tmm_pat; | 1178 | tmm[TILFMT_32BIT] = tmm_pat; |
| 1178 | tmm[TILFMT_PAGE] = tmm_pat; | 1179 | tmm[TILFMT_PAGE] = tmm_pat; |
| 1179 | 1180 | ||
| 1181 | /* Clear out all PAT entries */ | ||
| 1182 | area.x1 = tiler.width - 1; | ||
| 1183 | area.y1 = tiler.height - 1; | ||
| 1184 | tmm_clear(tmm_pat, area); | ||
| 1185 | |||
| 1180 | tiler.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT]; | 1186 | tiler.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT]; |
| 1181 | 1187 | ||
| 1182 | tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL); | 1188 | tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL); |
diff --git a/drivers/media/video/tiler/tmm-pat.c b/drivers/media/video/tiler/tmm-pat.c index e47f43f3d3d..6f916a89508 100644 --- a/drivers/media/video/tiler/tmm-pat.c +++ b/drivers/media/video/tiler/tmm-pat.c | |||
| @@ -61,6 +61,10 @@ struct fast { | |||
| 61 | struct dmm_mem { | 61 | struct dmm_mem { |
| 62 | struct list_head fast_list; | 62 | struct list_head fast_list; |
| 63 | struct dmm *dmm; | 63 | struct dmm *dmm; |
| 64 | u32 *dmac_va; /* coherent memory */ | ||
| 65 | u32 dmac_pa; /* phys.addr of coherent memory */ | ||
| 66 | struct page *dummy_pg; /* dummy page */ | ||
| 67 | u32 dummy_pa; /* phys.addr of dummy page */ | ||
| 64 | }; | 68 | }; |
| 65 | 69 | ||
| 66 | /* read mem values for a param */ | 70 | /* read mem values for a param */ |
| @@ -163,6 +167,8 @@ static void tmm_pat_deinit(struct tmm *tmm) | |||
| 163 | if (--refs == 0) | 167 | if (--refs == 0) |
| 164 | free_page_cache(); | 168 | free_page_cache(); |
| 165 | 169 | ||
| 170 | __free_page(pvt->dummy_pg); | ||
| 171 | |||
| 166 | mutex_unlock(&mtx); | 172 | mutex_unlock(&mtx); |
| 167 | } | 173 | } |
| 168 | 174 | ||
| @@ -262,7 +268,20 @@ static s32 tmm_pat_map(struct tmm *tmm, struct pat_area area, u32 page_pa) | |||
| 262 | return dmm_pat_refill(pvt->dmm, &pat_desc, MANUAL); | 268 | return dmm_pat_refill(pvt->dmm, &pat_desc, MANUAL); |
| 263 | } | 269 | } |
| 264 | 270 | ||
| 265 | struct tmm *tmm_pat_init(u32 pat_id) | 271 | static void tmm_pat_clear(struct tmm *tmm, struct pat_area area) |
| 272 | { | ||
| 273 | u16 w = (u8) area.x1 - (u8) area.x0; | ||
| 274 | u16 h = (u8) area.y1 - (u8) area.y0; | ||
| 275 | u16 i = (w + 1) * (h + 1); | ||
| 276 | struct dmm_mem *pvt = (struct dmm_mem *) tmm->pvt; | ||
| 277 | |||
| 278 | while (i--) | ||
| 279 | pvt->dmac_va[i] = pvt->dummy_pa; | ||
| 280 | |||
| 281 | tmm_pat_map(tmm, area, pvt->dmac_pa); | ||
| 282 | } | ||
| 283 | |||
| 284 | struct tmm *tmm_pat_init(u32 pat_id, u32 *dmac_va, u32 dmac_pa) | ||
| 266 | { | 285 | { |
| 267 | struct tmm *tmm = NULL; | 286 | struct tmm *tmm = NULL; |
| 268 | struct dmm_mem *pvt = NULL; | 287 | struct dmm_mem *pvt = NULL; |
| @@ -272,9 +291,15 @@ struct tmm *tmm_pat_init(u32 pat_id) | |||
| 272 | tmm = kmalloc(sizeof(*tmm), GFP_KERNEL); | 291 | tmm = kmalloc(sizeof(*tmm), GFP_KERNEL); |
| 273 | if (tmm) | 292 | if (tmm) |
| 274 | pvt = kmalloc(sizeof(*pvt), GFP_KERNEL); | 293 | pvt = kmalloc(sizeof(*pvt), GFP_KERNEL); |
| 275 | if (pvt) { | 294 | if (pvt) |
| 295 | pvt->dummy_pg = alloc_page(GFP_KERNEL | GFP_DMA); | ||
| 296 | if (pvt->dummy_pg) { | ||
| 276 | /* private data */ | 297 | /* private data */ |
| 277 | pvt->dmm = dmm; | 298 | pvt->dmm = dmm; |
| 299 | pvt->dmac_pa = dmac_pa; | ||
| 300 | pvt->dmac_va = dmac_va; | ||
| 301 | pvt->dummy_pa = page_to_phys(pvt->dummy_pg); | ||
| 302 | |||
| 278 | INIT_LIST_HEAD(&pvt->fast_list); | 303 | INIT_LIST_HEAD(&pvt->fast_list); |
| 279 | 304 | ||
| 280 | /* increate tmm_pat references */ | 305 | /* increate tmm_pat references */ |
| @@ -288,7 +313,7 @@ struct tmm *tmm_pat_init(u32 pat_id) | |||
| 288 | tmm->get = tmm_pat_get_pages; | 313 | tmm->get = tmm_pat_get_pages; |
| 289 | tmm->free = tmm_pat_free_pages; | 314 | tmm->free = tmm_pat_free_pages; |
| 290 | tmm->map = tmm_pat_map; | 315 | tmm->map = tmm_pat_map; |
| 291 | tmm->clear = NULL; /* not yet supported */ | 316 | tmm->clear = tmm_pat_clear; |
| 292 | 317 | ||
| 293 | return tmm; | 318 | return tmm; |
| 294 | } | 319 | } |
diff --git a/drivers/media/video/tiler/tmm.h b/drivers/media/video/tiler/tmm.h index fbdc1e23d0e..ffe3682b10d 100644 --- a/drivers/media/video/tiler/tmm.h +++ b/drivers/media/video/tiler/tmm.h | |||
| @@ -104,6 +104,6 @@ void tmm_deinit(struct tmm *tmm) | |||
| 104 | * | 104 | * |
| 105 | * Initialize TMM for PAT with given id. | 105 | * Initialize TMM for PAT with given id. |
| 106 | */ | 106 | */ |
| 107 | struct tmm *tmm_pat_init(u32 pat_id); | 107 | struct tmm *tmm_pat_init(u32 pat_id, u32 *dmac_va, u32 dmac_pa); |
| 108 | 108 | ||
| 109 | #endif | 109 | #endif |
