pr_dbg("%s done.\n", __func__);
}
-void atv_dmd_ring_filter(bool on)
+void atv_dmd_ring_filter(bool on, int std)
{
- unsigned long filter_status = 0;
+ int i = 0;
+ int filter = 0;
+ unsigned long status = 0;
+ unsigned long data = 0;
+ const unsigned int reg_addr[10] = {
+ 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34,
+ };
+ const unsigned int peak_filter[][10] = {
+ /* default */
+ { 0x8423F6, 0xFF86A967, 0x37FE45, 0xFF86A967, 0x3C223B,
+ 0x8423F6, 0xFF86A967, 0x37FE45, 0xFF86A967, 0x3C223B },
+ /* ntsc-m */
+ { 0x8274bf, 0x1d175c, 0x2aa526, 0x1d175c, 0x2d19e4,
+ 0x8274bf, 0x1d175c, 0x2aa526, 0x1d175c, 0x2d19e4 },
+ /* pal-i */
+ { 0x94d888, 0x5a39fb, 0xd8ebb, 0x5a39fb, 0x226744,
+ 0x94d888, 0x5a39fb, 0xd8ebb, 0x5a39fb, 0x226744 }
+ };
+
if (!is_meson_tl1_cpu() && !is_meson_tm2_cpu())
return;
- filter_status = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c);
- if (((filter_status & 0x01) && on) || (!(filter_status & 0x01) && !on))
+ if (on) {
+ if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG) {
+ filter = 2;
+ } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK) {
+ filter = 2;
+ } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I) {
+ filter = 2;
+ } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
+ std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC) {
+ filter = 1;
+ } else {
+ filter = 0;
+ on = false;
+ }
+ } else {
+ filter = 0;
+ }
+
+ status = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c);
+ data = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, reg_addr[0]);
+ if ((data == peak_filter[filter][0]) && on && (status & 0x01))
+ return;
+
+ if (!on && !(status & 0x01))
return;
- if (on) {
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8274bf);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0x1d175c);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x18, 0x2aa526);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x1c, 0x1d175c);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x20, 0x2d19e4);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x24, 0x8274bf);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x28, 0x1d175c);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x2c, 0x2aa526);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x30, 0x1d175c);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x34, 0x2d19e4);
+ /* disable filter */
+ atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x0);
+ for (i = 0; i < 10; ++i) {
+ atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL,
+ reg_addr[i], peak_filter[filter][i]);
+ }
+
+ if (on) {
/* enable filter */
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x1);
- } else {
- /* default value */
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8423F6);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0xFF86A967);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x18, 0x37FE45);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x1c, 0xFF86A967);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x20, 0x3C223B);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x24, 0x8423F6);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x28, 0xFF86A967);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x2c, 0x37FE45);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x30, 0xFF86A967);
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x34, 0x3C223B);
-
- /* disable filter */
- atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x0);
}
pr_dbg("%s do atv_dmd_ring_filter %d ...\n", __func__, on);
if (!priv->scanning || non_std_en)
atv_dmd_misc();
- if (!priv->scanning &&
- (broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
- broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC))
- atv_dmd_ring_filter(true);
+ if (!priv->scanning)
+ atv_dmd_ring_filter(true, broad_std);
else
- atv_dmd_ring_filter(false);
+ atv_dmd_ring_filter(false, broad_std);
atv_dmd_soft_reset();