21 #include <linux/slab.h>
23 #define SRC_RESOURCE_NUM 256
24 #define SRCIMP_RESOURCE_NUM 256
26 static unsigned int conj_mask;
28 static int src_default_config_memrd(
struct src *
src);
29 static int src_default_config_memwr(
struct src *
src);
30 static int src_default_config_arcrw(
struct src *
src);
32 static int (*src_default_config[3])(
struct src *) = {
33 [
MEMRD] = src_default_config_memrd,
34 [
MEMWR] = src_default_config_memwr,
35 [
ARCRW] = src_default_config_arcrw
38 static int src_set_state(
struct src *
src,
unsigned int state)
48 static int src_set_bm(
struct src *src,
unsigned int bm)
88 static int src_set_vo(
struct src *src,
unsigned int vo)
108 static int src_set_bp(
struct src *src,
unsigned int bp)
118 static int src_set_cisz(
struct src *src,
unsigned int cisz)
158 static int src_set_pitch(
struct src *src,
unsigned int pitch)
182 unsigned int dirty = 0;
185 src->
rsc.ops->master(&src->
rsc);
186 if (src->
rsc.msr > 1) {
197 for (i = 1; i < src->
rsc.msr; i++) {
198 src->
rsc.ops->next_conj(&src->
rsc);
203 src->
rsc.ops->master(&src->
rsc);
217 static int src_init(
struct src *src)
219 src_default_config[src->
mode](
src);
224 static struct src *src_next_interleave(
struct src *src)
229 static int src_default_config_memrd(
struct src *src)
231 struct hw *hw = src->
rsc.hw;
232 unsigned int rsr, msr;
236 for (rsr = 0, msr = src->
rsc.msr; msr > 1; msr >>= 1)
254 src->
rsc.ops->master(&src->
rsc);
258 for (msr = 1; msr < src->
rsc.msr; msr++) {
259 src->
rsc.ops->next_conj(&src->
rsc);
264 src->
rsc.ops->master(&src->
rsc);
269 static int src_default_config_memwr(
struct src *src)
271 struct hw *hw = src->
rsc.hw;
290 src->
rsc.ops->master(&src->
rsc);
297 static int src_default_config_arcrw(
struct src *src)
299 struct hw *hw = src->
rsc.hw;
300 unsigned int rsr, msr;
305 for (rsr = 0, msr = src->
rsc.msr; msr > 1; msr >>= 1)
326 src->
rsc.ops->master(&src->
rsc);
327 for (msr = 0; msr < src->
rsc.msr; msr++) {
331 src->
rsc.ops->next_conj(&src->
rsc);
333 src->
rsc.ops->master(&src->
rsc);
340 .set_bm = src_set_bm,
341 .set_sf = src_set_sf,
342 .set_pm = src_set_pm,
343 .set_rom = src_set_rom,
344 .set_vo = src_set_vo,
345 .set_st = src_set_st,
346 .set_bp = src_set_bp,
347 .set_cisz = src_set_cisz,
348 .set_ca = src_set_ca,
349 .set_sa = src_set_sa,
350 .set_la = src_set_la,
351 .set_pitch = src_set_pitch,
352 .set_clr_zbufs = src_set_clear_zbufs,
353 .commit_write = src_commit_write,
354 .get_ca = src_get_ca,
356 .next_interleave = src_next_interleave,
360 src_rsc_init(
struct src *src,
u32 idx,
368 for (i = 0, p = src; i <
n; i++, p++) {
374 p->
ops = &src_rsc_ops;
377 src_default_config[desc->
mode](p);
388 for (i--, p--; i >= 0; i--, p--) {
396 static int src_rsc_uninit(
struct src *src,
struct src_mgr *mgr)
402 for (i = 0, p = src; i <
n; i++, p++) {
416 get_src_rsc(
struct src_mgr *mgr,
const struct src_desc *desc,
struct src **rsrc)
432 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
449 err = src_rsc_init(src, idx, desc, mgr);
466 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
470 static int put_src_rsc(
struct src_mgr *mgr,
struct src *src)
475 src->
rsc.ops->master(&src->
rsc);
478 src->
rsc.ops->index(&src->
rsc));
482 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
483 src_rsc_uninit(src, mgr);
489 static int src_enable_s(
struct src_mgr *mgr,
struct src *src)
491 struct hw *hw = mgr->
mgr.hw;
494 src->
rsc.ops->master(&src->
rsc);
495 for (i = 0; i < src->
rsc.msr; i++) {
497 src->
rsc.ops->index(&src->
rsc));
498 src->
rsc.ops->next_conj(&src->
rsc);
500 src->
rsc.ops->master(&src->
rsc);
505 static int src_enable(
struct src_mgr *mgr,
struct src *src)
507 struct hw *hw = mgr->
mgr.hw;
510 src->
rsc.ops->master(&src->
rsc);
511 for (i = 0; i < src->
rsc.msr; i++) {
513 src->
rsc.ops->index(&src->
rsc));
514 src->
rsc.ops->next_conj(&src->
rsc);
516 src->
rsc.ops->master(&src->
rsc);
521 static int src_disable(
struct src_mgr *mgr,
struct src *src)
523 struct hw *hw = mgr->
mgr.hw;
526 src->
rsc.ops->master(&src->
rsc);
527 for (i = 0; i < src->
rsc.msr; i++) {
529 src->
rsc.ops->index(&src->
rsc));
530 src->
rsc.ops->next_conj(&src->
rsc);
532 src->
rsc.ops->master(&src->
rsc);
539 struct hw *hw = mgr->
mgr.hw;
552 src_mgr = kzalloc(
sizeof(*src_mgr),
GFP_KERNEL);
561 conj_mask = ((
struct hw *)hw)->src_dirty_conj_mask();
563 src_mgr->
get_src = get_src_rsc;
564 src_mgr->
put_src = put_src_rsc;
571 for (i = 0; i < 256; i++)
572 ((
struct hw *)hw)->src_mgr_dsb_src(src_mgr->
mgr.ctrl_blk, i);
574 ((
struct hw *)hw)->src_mgr_commit_write(hw, src_mgr->
mgr.ctrl_blk);
595 static int srcimp_master(
struct rsc *
rsc)
601 static int srcimp_next_conj(
struct rsc *
rsc)
607 static int srcimp_index(
const struct rsc *
rsc)
612 static struct rsc_ops srcimp_basic_rsc_ops = {
613 .master = srcimp_master,
614 .next_conj = srcimp_next_conj,
615 .index = srcimp_index,
624 srcimp->
rsc.ops->master(&srcimp->
rsc);
625 src->
rsc.ops->master(&src->
rsc);
626 input->
ops->master(input);
629 for (i = 0; i < srcimp->
rsc.msr; i++) {
631 entry->
slot = input->
ops->output_slot(input);
633 entry->
addr = srcimp->
rsc.ops->index(&srcimp->
rsc);
634 srcimp->
mgr->imap_add(srcimp->
mgr, entry);
637 srcimp->
rsc.ops->next_conj(&srcimp->
rsc);
638 input->
ops->next_conj(input);
641 srcimp->
rsc.ops->master(&srcimp->
rsc);
642 input->
ops->master(input);
647 static int srcimp_unmap(
struct srcimp *srcimp)
652 for (i = 0; i < srcimp->
rsc.msr; i++) {
653 if (srcimp->
mapped & (0x1 << i)) {
654 srcimp->
mgr->imap_delete(srcimp->
mgr,
665 .unmap = srcimp_unmap
668 static int srcimp_rsc_init(
struct srcimp *srcimp,
688 srcimp->
rsc.ops = &srcimp_basic_rsc_ops;
689 srcimp->
ops = &srcimp_ops;
692 srcimp->
rsc.ops->master(&srcimp->
rsc);
701 static int srcimp_rsc_uninit(
struct srcimp *srcimp)
714 static int get_srcimp_rsc(
struct srcimp_mgr *mgr,
716 struct srcimp **rsrcimp)
720 struct srcimp *srcimp;
726 srcimp = kzalloc(
sizeof(*srcimp),
GFP_KERNEL);
733 for (i = 0; i < desc->
msr; i++) {
740 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
746 err = srcimp_rsc_init(srcimp, desc, mgr);
756 for (i--; i >= 0; i--)
759 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
764 static int put_srcimp_rsc(
struct srcimp_mgr *mgr,
struct srcimp *srcimp)
770 for (i = 0; i < srcimp->
rsc.msr; i++)
773 spin_unlock_irqrestore(&mgr->
mgr_lock, flags);
774 srcimp_rsc_uninit(srcimp);
780 static int srcimp_map_op(
void *
data,
struct imapper *entry)
783 struct hw *hw = mgr->
hw;
806 spin_unlock_irqrestore(&mgr->
imap_lock, flags);
823 spin_unlock_irqrestore(&mgr->
imap_lock, flags);
835 srcimp_mgr = kzalloc(
sizeof(*srcimp_mgr),
GFP_KERNEL);
845 INIT_LIST_HEAD(&srcimp_mgr->
imappers);
858 srcimp_mgr->
imap_add = srcimp_imap_add;
861 *rsrcimp_mgr = srcimp_mgr;
879 spin_unlock_irqrestore(&srcimp_mgr->
imap_lock, flags);