aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-11-09 18:19:14 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:21:38 -0500
commit82e91ffef60e6eba9848fe149ce1eecd2b5aef12 (patch)
tree9ccc6a518a1f678ae15cfb3a59c05127286cff96 /net/decnet
parent0afc46c4683df512eef34a71a85065dc555c2af2 (diff)
[NET]: Turn nfmark into generic mark
nfmark is being used in various subsystems and has become the defacto mark field for all kinds of packets. Therefore it makes sense to rename it to `mark' and remove the dependency on CONFIG_NETFILTER. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet')
-rw-r--r--net/decnet/dn_route.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 23489f7232d2..3482839af280 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1236,7 +1236,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
1236 .saddr = cb->src, 1236 .saddr = cb->src,
1237 .scope = RT_SCOPE_UNIVERSE, 1237 .scope = RT_SCOPE_UNIVERSE,
1238#ifdef CONFIG_DECNET_ROUTE_FWMARK 1238#ifdef CONFIG_DECNET_ROUTE_FWMARK
1239 .fwmark = skb->nfmark 1239 .fwmark = skb->mark
1240#endif 1240#endif
1241 } }, 1241 } },
1242 .iif = skb->dev->ifindex }; 1242 .iif = skb->dev->ifindex };
@@ -1458,7 +1458,7 @@ int dn_route_input(struct sk_buff *skb)
1458 (rt->fl.fld_dst == cb->dst) && 1458 (rt->fl.fld_dst == cb->dst) &&
1459 (rt->fl.oif == 0) && 1459 (rt->fl.oif == 0) &&
1460#ifdef CONFIG_DECNET_ROUTE_FWMARK 1460#ifdef CONFIG_DECNET_ROUTE_FWMARK
1461 (rt->fl.fld_fwmark == skb->nfmark) && 1461 (rt->fl.fld_fwmark == skb->mark) &&
1462#endif 1462#endif
1463 (rt->fl.iif == cb->iif)) { 1463 (rt->fl.iif == cb->iif)) {
1464 rt->u.dst.lastuse = jiffies; 1464 rt->u.dst.lastuse = jiffies;
d='n468' href='#n468'>468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                             
/*
 * max98090.c -- MAX98090 ALSA SoC Audio driver
 *
 * Copyright 2011 Maxim Integrated Products
 *
 * 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.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/switch.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <linux/slab.h>
#include <asm/div64.h>
#include <sound/max98090.h>
#include "max98090.h"

static const u8 max98090_reg_def[M98090_REG_CNT] = {
	0x00, /* 00 */
	0x00, /* 01 */
	0x00, /* 02 */
	0x00, /* 03 */
	0x00, /* 04 */
	0x00, /* 05 */
	0x00, /* 06 */
	0x00, /* 07 */
	0x00, /* 08 */
	0x00, /* 09 */
	0x00, /* 0A */
	0x00, /* 0B */
	0x00, /* 0C */
	0x00, /* 0D */
	0x00, /* 0E */
	0x00, /* 0F */
	0x00, /* 10 */
	0x00, /* 11 */
	0x00, /* 12 */
	0x00, /* 13 */
	0x00, /* 14 */
	0x00, /* 15 */
	0x00, /* 16 */
	0x00, /* 17 */
	0x00, /* 18 */
	0x00, /* 19 */
	0x00, /* 1A */
	0x00, /* 1B */
	0x00, /* 1C */
	0x00, /* 1D */
	0x00, /* 1E */
	0x00, /* 1F */
	0x00, /* 20 */
	0x00, /* 21 */
	0x00, /* 22 */
	0x00, /* 23 */
	0x00, /* 24 */
	0x00, /* 25 */
	0x00, /* 26 */
	0x00, /* 27 */
	0x00, /* 28 */
	0x00, /* 29 */
	0x00, /* 2A */
	0x00, /* 2B */
	0x00, /* 2C */
	0x00, /* 2D */
	0x00, /* 2E */
	0x00, /* 2F */
	0x00, /* 30 */
	0x00, /* 31 */
	0x00, /* 32 */
	0x00, /* 33 */
	0x00, /* 34 */
	0x00, /* 35 */
	0x00, /* 36 */
	0x00, /* 37 */
	0x00, /* 38 */
	0x00, /* 39 */
	0x00, /* 3A */
	0x00, /* 3B */
	0x00, /* 3C */
	0x00, /* 3D */
	0x00, /* 3E */
	0x00, /* 3F */
	0x00, /* 40 */
	0x00, /* 41 */
	0x00, /* 42 */
	0x00, /* 43 */
	0x00, /* 44 */
	0x00, /* 45 */
	0x00, /* 46 */
	0x00, /* 47 */
	0x00, /* 48 */
	0x00, /* 49 */
	0x00, /* 4A */
	0x00, /* 4B */
	0x00, /* 4C */
	0x00, /* 4D */
	0x00, /* 4E */
	0x00, /* 4F */
	0x00, /* 50 */
	0x00, /* 51 */
	0x00, /* 52 */
	0x00, /* 53 */
	0x00, /* 54 */
	0x00, /* 55 */
	0x00, /* 56 */
	0x00, /* 57 */
	0x00, /* 58 */
	0x00, /* 59 */
	0x00, /* 5A */
	0x00, /* 5B */
	0x00, /* 5C */
	0x00, /* 5D */
	0x00, /* 5E */
	0x00, /* 5F */
	0x00, /* 60 */
	0x00, /* 61 */
	0x00, /* 62 */
	0x00, /* 63 */
	0x00, /* 64 */
	0x00, /* 65 */
	0x00, /* 66 */
	0x00, /* 67 */
	0x00, /* 68 */
	0x00, /* 69 */
	0x00, /* 6A */
	0x00, /* 6B */
	0x00, /* 6C */
	0x00, /* 6D */
	0x00, /* 6E */
	0x00, /* 6F */
	0x00, /* 70 */
	0x00, /* 71 */
	0x00, /* 72 */
	0x00, /* 73 */
	0x00, /* 74 */
	0x00, /* 75 */
	0x00, /* 76 */
	0x00, /* 77 */
	0x00, /* 78 */
	0x00, /* 79 */
	0x00, /* 7A */
	0x00, /* 7B */
	0x00, /* 7C */
	0x00, /* 7D */
	0x00, /* 7E */
	0x00, /* 7F */
	0x00, /* 80 */
	0x00, /* 81 */
	0x00, /* 82 */
	0x00, /* 83 */
	0x00, /* 84 */
	0x00, /* 85 */
	0x00, /* 86 */
	0x00, /* 87 */
	0x00, /* 88 */
	0x00, /* 89 */
	0x00, /* 8A */
	0x00, /* 8B */
	0x00, /* 8C */
	0x00, /* 8D */
	0x00, /* 8E */
	0x00, /* 8F */
	0x00, /* 90 */
	0x00, /* 91 */
	0x30, /* 92 */
	0xF0, /* 93 */
	0x00, /* 94 */
	0x00, /* 95 */
	0x3F, /* 96 */
	0x00, /* 97 */
	0x00, /* 98 */
	0x00, /* 99 */
	0x00, /* 9A */
	0x00, /* 9B */
	0x00, /* 9C */
	0x00, /* 9D */
	0x00, /* 9E */
	0x00, /* 9F */
	0x00, /* A0 */
	0x00, /* A1 */
	0x00, /* A2 */
	0x00, /* A3 */
	0x00, /* A4 */
	0x00, /* A5 */
	0x00, /* A6 */
	0x00, /* A7 */
	0x00, /* A8 */
	0x00, /* A9 */
	0x00, /* AA */
	0x00, /* AB */
	0x00, /* AC */
	0x00, /* AD */
	0x00, /* AE */
	0x00, /* AF */
	0x00, /* B0 */
	0x00, /* B1 */
	0x00, /* B2 */
	0x00, /* B3 */
	0x00, /* B4 */
	0x00, /* B5 */
	0x00, /* B6 */
	0x00, /* B7 */
	0x00, /* B8 */
	0x00, /* B9 */
	0x00, /* BA */
	0x00, /* BB */
	0x00, /* BC */
	0x00, /* BD */
	0x00, /* BE */
	0x00, /* BF */
	0x00, /* C0 */
	0x00, /* C1 */
	0x00, /* C2 */
	0x00, /* C3 */
	0x00, /* C4 */
	0x00, /* C5 */
	0x00, /* C6 */
	0x00, /* C7 */
	0x00, /* C8 */
	0x00, /* C9 */
	0x00, /* CA */
	0x00, /* CB */
	0x00, /* CC */
	0x00, /* CD */
	0x00, /* CE */
	0x00, /* CF */
	0x00, /* D0 */
	0x00, /* D1 */
	0x00, /* D2 */
	0x00, /* D3 */
	0x00, /* D4 */
	0x00, /* D5 */
	0x00, /* D6 */
	0x00, /* D7 */
	0x00, /* D8 */
	0x00, /* D9 */
	0x00, /* DA */
	0x00, /* DB */
	0x00, /* DC */
	0x00, /* DD */
	0x00, /* DE */
	0x00, /* DF */
	0x00, /* E0 */
	0x00, /* E1 */
	0x00, /* E2 */
	0x00, /* E3 */
	0x00, /* E4 */
	0x00, /* E5 */
	0x00, /* E6 */
	0x00, /* E7 */
	0x00, /* E8 */
	0x00, /* E9 */
	0x00, /* EA */
	0x00, /* EB */
	0x00, /* EC */
	0x00, /* ED */
	0x00, /* EE */
	0x00, /* EF */
	0x00, /* F0 */
	0x00, /* F1 */
	0x00, /* F2 */
	0x00, /* F3 */
	0x00, /* F4 */
	0x00, /* F5 */
	0x00, /* F6 */
	0x00, /* F7 */
	0x00, /* F8 */
	0x00, /* F9 */
	0x00, /* FA */
	0x00, /* FB */
	0x00, /* FC */
	0x00, /* FD */
	0x00, /* FE */
	0x00, /* FF */
};


static struct {
	int readable;
	int writable;
} max98090_access[M98090_REG_CNT] = {
	{ 0x00, 0x80 }, /* 00 */
	{ 0xFF, 0x00 }, /* 01 */
	{ 0xFF, 0x00 }, /* 02 */
	{ 0xFF, 0xE7 }, /* 03 */
	{ 0xFF, 0xFD }, /* 04 */
	{ 0xFF, 0x3F }, /* 05 */
	{ 0xFF, 0x3F }, /* 06 */
	{ 0xFF, 0xF0 }, /* 07 */
	{ 0xFF, 0xFE }, /* 08 */
	{ 0xFF, 0xF8 }, /* 09 */
	{ 0xFF, 0xFF }, /* 0A */
	{ 0xFF, 0xFF }, /* 0B */
	{ 0xFF, 0xF0 }, /* 0C */
	{ 0xFF, 0xFF }, /* 0D */
	{ 0xFF, 0xFF }, /* 0E */
	{ 0xFF, 0xD3 }, /* 0F */
	{ 0xFF, 0x7F }, /* 10 */
	{ 0xFF, 0x7F }, /* 11 */
	{ 0xFF, 0x00 }, /* 12 */
	{ 0xFF, 0x00 }, /* 13 */
	{ 0xFF, 0x00 }, /* 14 */
	{ 0xFF, 0xFF }, /* 15 */
	{ 0xFF, 0xFF }, /* 16 */
	{ 0xFF, 0x3F }, /* 17 */
	{ 0xFF, 0x3F }, /* 18 */
	{ 0xFF, 0x0F }, /* 19 */
	{ 0xFF, 0xDF }, /* 1A */
	{ 0xFF, 0x30 }, /* 1B */
	{ 0xFF, 0xF1 }, /* 1C */
	{ 0xFF, 0x7F }, /* 1D */
	{ 0xFF, 0xFF }, /* 1E */
	{ 0xFF, 0xFF }, /* 1F */
	{ 0xFF, 0xFF }, /* 20 */
	{ 0xFF, 0x87 }, /* 21 */
	{ 0xFF, 0x3F }, /* 22 */
	{ 0xFF, 0x03 }, /* 23 */
	{ 0xFF, 0xFF }, /* 24 */
	{ 0xFF, 0x3F }, /* 25 */
	{ 0xFF, 0xF0 }, /* 26 */
	{ 0xFF, 0xBF }, /* 27 */
	{ 0xFF, 0x1F }, /* 28 */
	{ 0xFF, 0x3F }, /* 29 */
	{ 0xFF, 0x3F }, /* 2A */
	{ 0xFF, 0x3F }, /* 2B */
	{ 0xFF, 0x9F }, /* 2C */
	{ 0xFF, 0x9F }, /* 2D */
	{ 0xFF, 0x3F }, /* 2E */
	{ 0xFF, 0x3F }, /* 2F */
	{ 0xFF, 0x0F }, /* 30 */
	{ 0xFF, 0xBF }, /* 31 */
	{ 0xFF, 0xBF }, /* 32 */
	{ 0xFF, 0xF7 }, /* 33 */
	{ 0xFF, 0xFF }, /* 34 */
	{ 0xFF, 0xFF }, /* 35 */
	{ 0xFF, 0x1F }, /* 36 */
	{ 0xFF, 0x3F }, /* 37 */
	{ 0xFF, 0x03 }, /* 38 */
	{ 0xFF, 0x9F }, /* 39 */
	{ 0xFF, 0xBF }, /* 3A */
	{ 0xFF, 0x03 }, /* 3B */
	{ 0xFF, 0x9F }, /* 3C */
	{ 0xFF, 0xC3 }, /* 3D */
	{ 0xFF, 0x1F }, /* 3E */
	{ 0xFF, 0xFF }, /* 3F */
	{ 0xFF, 0x07 }, /* 40 */
	{ 0xFF, 0x0F }, /* 41 */
	{ 0xFF, 0x01 }, /* 42 */
	{ 0xFF, 0x03 }, /* 43 */
	{ 0xFF, 0x05 }, /* 44 */
	{ 0xFF, 0x80 }, /* 45 */
	{ 0x00, 0x00 }, /* 46 */
	{ 0x00, 0x00 }, /* 47 */
	{ 0x00, 0x00 }, /* 48 */
	{ 0x00, 0x00 }, /* 49 */
	{ 0x00, 0x00 }, /* 4A */
	{ 0x00, 0x00 }, /* 4B */
	{ 0x00, 0x00 }, /* 4C */
	{ 0x00, 0x00 }, /* 4D */
	{ 0x00, 0x00 }, /* 4E */
	{ 0x00, 0x00 }, /* 4F */
	{ 0x00, 0x00 }, /* 50 */
	{ 0x00, 0x00 }, /* 51 */
	{ 0x00, 0x00 }, /* 52 */
	{ 0x00, 0x00 }, /* 53 */
	{ 0x00, 0x00 }, /* 54 */
	{ 0x00, 0x00 }, /* 55 */
	{ 0x00, 0x00 }, /* 56 */
	{ 0x00, 0x00 }, /* 57 */
	{ 0x00, 0x00 }, /* 58 */
	{ 0x00, 0x00 }, /* 59 */
	{ 0x00, 0x00 }, /* 5A */
	{ 0x00, 0x00 }, /* 5B */
	{ 0x00, 0x00 }, /* 5C */
	{ 0x00, 0x00 }, /* 5D */
	{ 0x00, 0x00 }, /* 5E */
	{ 0x00, 0x00 }, /* 5F */
	{ 0x00, 0x00 }, /* 60 */
	{ 0x00, 0x00 }, /* 61 */
	{ 0x00, 0x00 }, /* 62 */
	{ 0x00, 0x00 }, /* 63 */
	{ 0x00, 0x00 }, /* 64 */
	{ 0x00, 0x00 }, /* 65 */
	{ 0x00, 0x00 }, /* 66 */
	{ 0x00, 0x00 }, /* 67 */
	{ 0x00, 0x00 }, /* 68 */
	{ 0x00, 0x00 }, /* 69 */
	{ 0x00, 0x00 }, /* 6A */
	{ 0x00, 0x00 }, /* 6B */
	{ 0x00, 0x00 }, /* 6C */
	{ 0x00, 0x00 }, /* 6D */
	{ 0x00, 0x00 }, /* 6E */
	{ 0x00, 0x00 }, /* 6F */
	{ 0x00, 0x00 }, /* 70 */
	{ 0x00, 0x00 }, /* 71 */
	{ 0x00, 0x00 }, /* 72 */
	{ 0x00, 0x00 }, /* 73 */
	{ 0x00, 0x00 }, /* 74 */
	{ 0x00, 0x00 }, /* 75 */
	{ 0x00, 0x00 }, /* 76 */
	{ 0x00, 0x00 }, /* 77 */
	{ 0x00, 0x00 }, /* 78 */
	{ 0x00, 0x00 }, /* 79 */
	{ 0x00, 0x00 }, /* 7A */
	{ 0x00, 0x00 }, /* 7B */
	{ 0x00, 0x00 }, /* 7C */
	{ 0x00, 0x00 }, /* 7D */
	{ 0x00, 0x00 }, /* 7E */
	{ 0x00, 0x00 }, /* 7F */
	{ 0x00, 0x00 }, /* 80 */
	{ 0x00, 0x00 }, /* 81 */
	{ 0x00, 0x00 }, /* 82 */
	{ 0x00, 0x00 }, /* 83 */
	{ 0x00, 0x00 }, /* 84 */
	{ 0x00, 0x00 }, /* 85 */
	{ 0x00, 0x00 }, /* 86 */
	{ 0x00, 0x00 }, /* 87 */
	{ 0x00, 0x00 }, /* 88 */
	{ 0x00, 0x00 }, /* 89 */
	{ 0x00, 0x00 }, /* 8A */
	{ 0x00, 0x00 }, /* 8B */
	{ 0x00, 0x00 }, /* 8C */
	{ 0x00, 0x00 }, /* 8D */
	{ 0x00, 0x00 }, /* 8E */
	{ 0x00, 0x00 }, /* 8F */
	{ 0x00, 0x00 }, /* 90 */
	{ 0x00, 0x00 }, /* 91 */
	{ 0x00, 0x00 }, /* 92 */
	{ 0x00, 0x00 }, /* 93 */
	{ 0x00, 0x00 }, /* 94 */
	{ 0x00, 0x00 }, /* 95 */
	{ 0x00, 0x00 }, /* 96 */
	{ 0x00, 0x00 }, /* 97 */
	{ 0x00, 0x00 }, /* 98 */
	{ 0x00, 0x00 }, /* 99 */
	{ 0x00, 0x00 }, /* 9A */
	{ 0x00, 0x00 }, /* 9B */
	{ 0x00, 0x00 }, /* 9C */
	{ 0x00, 0x00 }, /* 9D */
	{ 0x00, 0x00 }, /* 9E */
	{ 0x00, 0x00 }, /* 9F */
	{ 0x00, 0x00 }, /* A0 */
	{ 0x00, 0x00 }, /* A1 */
	{ 0x00, 0x00 }, /* A2 */
	{ 0x00, 0x00 }, /* A3 */
	{ 0x00, 0x00 }, /* A4 */
	{ 0x00, 0x00 }, /* A5 */
	{ 0x00, 0x00 }, /* A6 */
	{ 0x00, 0x00 }, /* A7 */
	{ 0x00, 0x00 }, /* A8 */
	{ 0x00, 0x00 }, /* A9 */
	{ 0x00, 0x00 }, /* AA */
	{ 0x00, 0x00 }, /* AB */
	{ 0x00, 0x00 }, /* AC */
	{ 0x00, 0x00 }, /* AD */
	{ 0x00, 0x00 }, /* AE */
	{ 0x00, 0x00 }, /* AF */
	{ 0x00, 0x00 }, /* B0 */
	{ 0x00, 0x00 }, /* B1 */
	{ 0x00, 0x00 }, /* B2 */
	{ 0x00, 0x00 }, /* B3 */
	{ 0x00, 0x00 }, /* B4 */
	{ 0x00, 0x00 }, /* B5 */
	{ 0x00, 0x00 }, /* B6 */
	{ 0x00, 0x00 }, /* B7 */
	{ 0x00, 0x00 }, /* B8 */
	{ 0x00, 0x00 }, /* B9 */
	{ 0x00, 0x00 }, /* BA */
	{ 0x00, 0x00 }, /* BB */
	{ 0x00, 0x00 }, /* BC */
	{ 0x00, 0x00 }, /* BD */
	{ 0x00, 0x00 }, /* BE */
	{ 0x00, 0x00 }, /* BF */
	{ 0x00, 0x00 }, /* C0 */
	{ 0x00, 0x00 }, /* C1 */
	{ 0x00, 0x00 }, /* C2 */
	{ 0x00, 0x00 }, /* C3 */
	{ 0x00, 0x00 }, /* C4 */
	{ 0x00, 0x00 }, /* C5 */
	{ 0x00, 0x00 }, /* C6 */
	{ 0x00, 0x00 }, /* C7 */
	{ 0x00, 0x00 }, /* C8 */
	{ 0x00, 0x00 }, /* C9 */
	{ 0x00, 0x00 }, /* CA */
	{ 0x00, 0x00 }, /* CB */
	{ 0x00, 0x00 }, /* CC */
	{ 0x00, 0x00 }, /* CD */
	{ 0x00, 0x00 }, /* CE */
	{ 0x00, 0x00 }, /* CF */
	{ 0x00, 0x00 }, /* D0 */
	{ 0x00, 0x00 }, /* D1 */
	{ 0x00, 0x00 }, /* D2 */
	{ 0x00, 0x00 }, /* D3 */
	{ 0x00, 0x00 }, /* D4 */
	{ 0x00, 0x00 }, /* D5 */
	{ 0x00, 0x00 }, /* D6 */
	{ 0x00, 0x00 }, /* D7 */
	{ 0x00, 0x00 }, /* D8 */
	{ 0x00, 0x00 }, /* D9 */
	{ 0x00, 0x00 }, /* DA */
	{ 0x00, 0x00 }, /* DB */
	{ 0x00, 0x00 }, /* DC */
	{ 0x00, 0x00 }, /* DD */
	{ 0x00, 0x00 }, /* DE */
	{ 0x00, 0x00 }, /* DF */
	{ 0x00, 0x00 }, /* E0 */
	{ 0x00, 0x00 }, /* E1 */
	{ 0x00, 0x00 }, /* E2 */
	{ 0x00, 0x00 }, /* E3 */
	{ 0x00, 0x00 }, /* E4 */
	{ 0x00, 0x00 }, /* E5 */
	{ 0x00, 0x00 }, /* E6 */
	{ 0x00, 0x00 }, /* E7 */
	{ 0x00, 0x00 }, /* E8 */
	{ 0x00, 0x00 }, /* E9 */
	{ 0x00, 0x00 }, /* EA */
	{ 0x00, 0x00 }, /* EB */
	{ 0x00, 0x00 }, /* EC */
	{ 0x00, 0x00 }, /* ED */
	{ 0x00, 0x00 }, /* EE */
	{ 0x00, 0x00 }, /* EF */
	{ 0x00, 0x00 }, /* F0 */
	{ 0x00, 0x00 }, /* F1 */
	{ 0x00, 0x00 }, /* F2 */
	{ 0x00, 0x00 }, /* F3 */
	{ 0x00, 0x00 }, /* F4 */
	{ 0x00, 0x00 }, /* F5 */
	{ 0x00, 0x00 }, /* F6 */
	{ 0x00, 0x00 }, /* F7 */
	{ 0x00, 0x00 }, /* F8 */
	{ 0x00, 0x00 }, /* F9 */
	{ 0x00, 0x00 }, /* FA */
	{ 0x00, 0x00 }, /* FB */
	{ 0x00, 0x00 }, /* FC */
	{ 0x00, 0x00 }, /* FD */
	{ 0x00, 0x00 }, /* FE */
	{ 0xFF, 0x00 }, /* FF */
};

static int max98090_readable(struct snd_soc_codec *codec, unsigned int reg)
{
	if (reg >= M98090_REG_CNT)
		return 0;
	return max98090_access[reg].readable != 0;
}

static int max98090_volatile(struct snd_soc_codec *codec, unsigned int reg)
{
	if (reg > M98090_REG_MAX_CACHED)
		return 1;

	switch (reg) {
	case M98090_001_INT_STS:
	case M98090_002_JACK_STS:
		return 1;
	}

	return 0;
}
//------------------------------------------------
// Implementation of I2C functions
//------------------------------------------------
inline unsigned int max98090_i2c_read(struct snd_soc_codec *codec, unsigned int reg)
{
	int ret;

	ret = i2c_smbus_read_byte_data(codec->control_data, (u8)(reg & 0xFF));

	if (ret < 0)
		printk("DEBUG -> %s error!!! [%d]\n",__FUNCTION__,__LINE__);
	return ret;
}

/*
 * write max98090 register cache
 */
static inline void max98090_write_reg_cache(struct snd_soc_codec *codec,
	unsigned int reg, unsigned int value)
{
	u16 *cache = codec->reg_cache;

	/* Reset register and reserved registers are uncached */
	if (reg == 0 || reg > ARRAY_SIZE(max98090_reg_def) - 1)
		return;

	cache[reg] = value;
}

/*
 * write to the max98090 register space
 */
static int max98090_i2c_write(struct snd_soc_codec *codec, unsigned int reg,
	unsigned int value)
{
	max98090_write_reg_cache (codec, reg, value);

	if(i2c_smbus_write_byte_data(codec->control_data, (u8)(reg & 0xFF), (u8)(value & 0xFF))<0) {
		printk("%s error!!! [%d]\n",__FUNCTION__,__LINE__);
		return -EIO;
	}
	
	return 0;
}

//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------

static const char *playback_path[] = {"OFF", "RCV", "SPK", "HP", "SPK_HP", "TV_OUT", };
static const char *record_path[] = {"Main Mic", "Headset Mic", };

static const struct soc_enum path_control_enum[] = {
	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(playback_path),playback_path),
	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(record_path),record_path),
};

#if defined(CONFIG_MAX98090_HEADSET)
enum {
	JACK_NO_DEVICE			= 0x0,
	HEADSET_4_POLE_DEVICE	= 0x01 << 0,
	HEADSET_3_POLE_DEVICE	= 0x01 << 1,

	TVOUT_DEVICE			= 0x01 << 2,
	UNKNOWN_DEVICE			= 0x01 << 3,
};

enum {
	JACK_DETACHED		= 0x0,
	JACK_ATTACHED		= 0x1,
};

struct switch_dev switch_jack_detection = {
	.name = "h2w",
};
static unsigned int current_jack_type_status = UNKNOWN_DEVICE;
#endif
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
static int max98090_set_playback_path(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);

	int path_num = ucontrol->value.integer.value[0];

	max98090->cur_path = path_num;
	
	switch(path_num) {
		case 0 : // headset
		case 1 : // earpiece
//			max98090_set_playback_headset(codec);
			max98090_set_playback_speaker_headset(codec);
			break;
		case 2 : // speaker
//			max98090_set_playback_speaker(codec);
			max98090_set_playback_speaker_headset(codec);
			break;
		case 3 :
			max98090_set_playback_speaker_headset(codec);
			break;
		case 4 :
			break;
		default :
			break;
	}
//	max98090_set_record_main_mic(codec);
	return 0;
}

//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
static int max98090_get_playback_path(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
	
	printk(" %s [%d] current playback path %d\n",__FUNCTION__,__LINE__, max98090->cur_path);

	ucontrol->value.integer.value[0] = max98090->cur_path;

	return 0;
}

//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
static int max98090_set_record_path(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);

	int path_num = ucontrol->value.integer.value[0];
	
	max98090->rec_path = path_num;
	printk(" %s [%d] param %d\n",__FUNCTION__,__LINE__, path_num);

	switch(path_num) {
		case 0 :
			max98090_set_record_main_mic(codec);
			break;
		case 1 :
			max98090_set_record_main_mic(codec);
			break;
		case 2 :
			max98090_set_record_main_mic(codec);
			break;
		default :
			break;
	}

	return 0;
}

//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
static int max98090_get_record_path(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);

	printk(" %s [%d] current record path %d\n",__FUNCTION__,__LINE__, max98090->rec_path);

	ucontrol->value.integer.value[0] = max98090->rec_path;

	return 0;
}

//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
static const struct snd_kcontrol_new max98090_snd_controls[] = {
	/* Path Control */
	SOC_ENUM_EXT("Playback Path", path_control_enum[0],
                max98090_get_playback_path, max98090_set_playback_path),

	SOC_ENUM_EXT("MIC Path", path_control_enum[1],
                max98090_get_record_path, max98090_set_record_path),
};

static int max98090_add_widgets(struct snd_soc_codec *codec)
{
	snd_soc_add_controls(codec, max98090_snd_controls,
			     ARRAY_SIZE(max98090_snd_controls));
	return 0;
}

#if defined(CONFIG_MAX98090_HEADSET) 
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
#define MAX98090_DELAY	msecs_to_jiffies(1000)
static void max98090_work(struct work_struct *work)
{
	struct max98090_priv *max98090 = container_of(work, struct max98090_priv, work.work);
	struct snd_soc_codec *codec= max98090->codec;
	int jack_auto_sts=0;
	int read_value=0;

//	jack_auto_sts = snd_soc_read(codec, M98090_002_JACK_STS);
//	jack_man_sts = snd_soc_read(codec, M98090_008_JACK_MANUAL_STS);

//printk("CKKIM -> %s[%d] : jack_auto_sts = 0x%02x \n\n",__func__,__LINE__, jack_auto_sts);
//	if(jack_man_sts&0x18){
		read_value = JACK_NO_DEVICE;
//	}
//	else if(jack_auto_sts&0x08){
//		read_value = HEADSET_4_POLE_DEVICE;
//	}
//	else {
//		read_value = JACK_NO_DEVICE;
//	}
	if(read_value != current_jack_type_status)
	{
		current_jack_type_status=read_value;
		switch_set_state(&switch_jack_detection, current_jack_type_status);
		mdelay(500);
		switch(current_jack_type_status)
		{
			case HEADSET_3_POLE_DEVICE :
			case HEADSET_4_POLE_DEVICE :
				max98090_disable_playback_path(codec, SPK);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = HP;
//				snd_soc_write(codec, M98090_089_JACK_DET_AUTO, 0x84);
				break;
			case JACK_NO_DEVICE :
				max98090_disable_playback_path(codec, HP);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = SPK;
				break;
			default :
				max98090_disable_playback_path(codec, SPK);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = HP;
				break;
		}
		schedule_delayed_work(&max98090->work, msecs_to_jiffies(2000));
	}
	else schedule_delayed_work(&max98090->work, msecs_to_jiffies(1000));

}

void	odroid_audio_tvout(bool tvout)
{
	return;
}
#endif

//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
/* codec mclk clock divider coefficients */
static const struct {
	u32 rate;
	u8  sr;
} rate_table[] = {
	{8000,  M98090_QS_SR_8K},
	{16000, M98090_QS_SR_16K},
	{32000, M98090_QS_SR_32K},
	{44100, M98090_QS_SR_44K1},
	{48000, M98090_QS_SR_48K},
	{96000, M98090_QS_SR_96K},
};

static int rate_value(int rate, u8 *value)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(rate_table); i++) {
		if (rate_table[i].rate >= rate) {
			*value = rate_table[i].sr;
			return 0;
		}
	}
	*value = rate_table[0].sr;
	return -EINVAL;
}

static int max98090_dai1_hw_params(struct snd_pcm_substream *substream,
				   struct snd_pcm_hw_params *params,
				   struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
	struct max98090_cdata *cdata;
	unsigned long long ni;
	unsigned int rate;
	u8 regval;

	cdata = &max98090->dai;

snd_soc_write(codec, M98090_006_IF_QS, M98090_QS_DAI_I2S_SLV);
snd_soc_write(codec, M98090_005_SAMPLERATE_QS, M98090_QS_SR_44K1);
snd_soc_write(codec, M98090_007_DAC_PATH_QS, 0x80);

//	rate = params_rate(params);
//
//	switch (params_format(params)) {
//	case SNDRV_PCM_FORMAT_S16_LE:
//		snd_soc_update_bits(codec, M98090_022_DAI_IF_FORMAT,
//			M98090_DAI_WS, 0);
//		break;
//	case SNDRV_PCM_FORMAT_S24_LE:
//		snd_soc_update_bits(codec, M98090_022_DAI_IF_FORMAT,
//			M98090_DAI_WS, 1);
//		break;
//	default:
//		return -EINVAL;
//	}
//
////	if (rate_value(rate, &regval))
////		return -EINVAL;
//
//	snd_soc_update_bits(codec, M98090_005_SAMPLERATE_QS,
//		M98090_QS_SR_MASK, M98090_QS_SR_44K1);
//
//	cdata->rate = rate;
//
//	/* Configure NI when operating as master */
//	if (snd_soc_read(codec, M98090_021_MASTER_MODE_CLK) & M98090_DAI_MAS) {
//		if (max98090->sysclk == 0) {
//			dev_err(codec->dev, "Invalid system clock frequency\n");
//			return -EINVAL;
//		}
//		ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL)
//				* (unsigned long long int)rate;
//		do_div(ni, (unsigned long long int)max98090->sysclk);
//		snd_soc_write(codec, M98090_01D_ANYCLK_CNTL1,
//			(ni >> 8) & 0x7F);
//		snd_soc_write(codec, M98090_01E_ANYCLK_CNTL2,
//			ni & 0xFF);
//
//	}
//
//	/* Update sample rate mode */
//	if (rate < 50000)
//		snd_soc_update_bits(codec, M98090_026_FILTER_CONFIG,
//			M98090_FILTER_DHF, 0);
//	else
//		snd_soc_update_bits(codec, M98090_026_FILTER_CONFIG,
//			M98090_FILTER_DHF, M98090_FILTER_DHF);

//max98090_set_playback_speaker_headset(codec);

	return 0;
}

static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
				   int clk_id, unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = dai->codec;
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);

	/* Requested clock frequency is already setup */
	if (freq == max98090->sysclk)
		return 0;

	max98090->sysclk = freq; /* remember current sysclk */

//	/* Setup clocks for slave mode, and using the PLL
//	 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
//	 *         0x02 (when master clk is 20MHz to 40MHz)..
//	 *         0x03 (when master clk is 40MHz to 60MHz)..
//	 */
//	if ((freq >= 10000000) && (freq < 20000000)) {
//		snd_soc_write(codec, M98090_01B_SYS_CLK, 0x10);
//	} else if ((freq >= 20000000) && (freq < 40000000)) {
//		snd_soc_write(codec, M98090_01B_SYS_CLK, 0x20);
//	} else if ((freq >= 40000000) && (freq < 60000000)) {
//		snd_soc_write(codec, M98090_01B_SYS_CLK, 0x30);
//	} else {
//		dev_err(codec->dev, "Invalid master clock frequency\n");
//		return -EINVAL;
//	}

snd_soc_write(codec, M98090_004_SYS_CLK_QS, M98090_QS_MCLK_11P2896M);
	dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq);

	return 0;
}

static int max98090_dai1_set_fmt(struct snd_soc_dai *codec_dai,
				 unsigned int fmt)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
	struct max98090_cdata *cdata;
	u8 regval = 0;
	u8 master = 0;

	cdata = &max98090->dai;

	if (fmt != cdata->fmt) {
		cdata->fmt = fmt;

//		switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
//		case SND_SOC_DAIFMT_CBS_CFS:
//			/* Slave mode PLL */
//			snd_soc_write(codec, M98090_01D_ANYCLK_CNTL1,
//				0x60);
//			snd_soc_write(codec, M98090_01E_ANYCLK_CNTL2,
//				0x00);
//			break;
//		case SND_SOC_DAIFMT_CBM_CFM:
//			/* Set to master mode */
//			master = M98090_DAI_MAS;
//			break;
//		case SND_SOC_DAIFMT_CBS_CFM:
//		case SND_SOC_DAIFMT_CBM_CFS:
//		default:
//			dev_err(codec->dev, "Clock mode unsupported");
//			return -EINVAL;
//		}
//
//		switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
//		case SND_SOC_DAIFMT_I2S:
//			regval |= M98090_DAI_DLY;
//			break;
//		case SND_SOC_DAIFMT_LEFT_J:
//			break;
//		default:
//			return -EINVAL;
//		}
//
//		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
//		case SND_SOC_DAIFMT_NB_NF:
//			break;
//		case SND_SOC_DAIFMT_NB_IF:
//			regval |= M98090_DAI_WCI;
//			break;
//		case SND_SOC_DAIFMT_IB_NF:
//			regval |= M98090_DAI_BCI;
//			break;
//		case SND_SOC_DAIFMT_IB_IF:
//			regval |= M98090_DAI_BCI|M98090_DAI_WCI;
//			break;
//		default:
//			return -EINVAL;
//		}
//
//		snd_soc_write(codec, M98090_021_MASTER_MODE_CLK, master);
//
//		snd_soc_update_bits(codec, M98090_022_DAI_IF_FORMAT,
//			M98090_DAI_DLY | M98090_DAI_BCI | M98090_DAI_RJ |