mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-22 16:07:49 +08:00
Update On Mon Apr 15 01:03:37 CEST 2024
This commit is contained in:
@@ -616,3 +616,4 @@ Update On Wed Apr 10 20:31:24 CEST 2024
|
||||
Update On Thu Apr 11 20:26:19 CEST 2024
|
||||
Update On Fri Apr 12 20:24:06 CEST 2024
|
||||
Update On Sat Apr 13 20:24:55 CEST 2024
|
||||
Update On Mon Apr 15 01:03:26 CEST 2024
|
||||
|
||||
@@ -19,6 +19,7 @@ module.exports = {
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./useNyanpasu";
|
||||
export * from "./useClash";
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import useSWR from "swr";
|
||||
import { clash } from "../service/clash";
|
||||
|
||||
export const useClash = () => {
|
||||
const { setConfigs, setProxies, deleteConnections, ...api } = clash();
|
||||
|
||||
const getConfigs = useSWR("getClashConfig", api.getConfigs);
|
||||
|
||||
const getVersion = useSWR("getClashVersion", api.getVersion);
|
||||
|
||||
const getRules = useSWR("getClashRules", api.getRules);
|
||||
|
||||
const getProxiesDelay = useSWR("getClashProxiesDelay", api.getProxiesDelay);
|
||||
|
||||
const getProxies = useSWR("getClashProxies", api.getProxies);
|
||||
|
||||
return {
|
||||
getConfigs,
|
||||
setConfigs,
|
||||
getVersion,
|
||||
getRules,
|
||||
getProxiesDelay,
|
||||
getProxies,
|
||||
setProxies,
|
||||
deleteConnections,
|
||||
};
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
"module": "index.ts",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "1.5.3",
|
||||
"ofetch": "1.3.4",
|
||||
"swr": "2.2.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { ofetch } from "ofetch";
|
||||
import { getClashInfo } from "./tauri";
|
||||
|
||||
export namespace Clash {
|
||||
export interface Config {
|
||||
port: number;
|
||||
mode: string;
|
||||
ipv6: boolean;
|
||||
"socket-port": number;
|
||||
"allow-lan": boolean;
|
||||
"log-level": string;
|
||||
"mixed-port": number;
|
||||
"redir-port": number;
|
||||
"socks-port": number;
|
||||
"tproxy-port": number;
|
||||
"external-controller": string;
|
||||
secret: string;
|
||||
}
|
||||
|
||||
export interface Version {
|
||||
premium: boolean;
|
||||
meta?: boolean;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface Rule {
|
||||
type: string;
|
||||
payload: string;
|
||||
proxy: string;
|
||||
}
|
||||
|
||||
export interface Proxy {
|
||||
name: string;
|
||||
type: string;
|
||||
udp: boolean;
|
||||
history: {
|
||||
time: string;
|
||||
delay: number;
|
||||
}[];
|
||||
all?: string[];
|
||||
now?: string;
|
||||
provider?: string;
|
||||
}
|
||||
}
|
||||
|
||||
const prepareServer = (server: string) => {
|
||||
if (server.startsWith(":")) {
|
||||
return `127.0.0.1${server}`;
|
||||
} else if (/^\d+$/.test(server)) {
|
||||
return `127.0.0.1:${server}`;
|
||||
} else {
|
||||
return server;
|
||||
}
|
||||
};
|
||||
|
||||
export const clash = () => {
|
||||
const buildRequest = async () => {
|
||||
const info = await getClashInfo();
|
||||
|
||||
return ofetch.create({
|
||||
baseURL: `http://${prepareServer(info?.server as string)}`,
|
||||
headers: info?.secret
|
||||
? { Authorization: `Bearer ${info?.secret}` }
|
||||
: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
const getConfigs = async () => {
|
||||
return (await buildRequest())<Clash.Config>("/configs");
|
||||
};
|
||||
|
||||
const setConfigs = async (config: Partial<Clash.Config>) => {
|
||||
return (await buildRequest())<Clash.Config>("/configs", {
|
||||
method: "PATCH",
|
||||
body: config,
|
||||
});
|
||||
};
|
||||
|
||||
const getVersion = async () => {
|
||||
return (await buildRequest())<Clash.Version>("/version");
|
||||
};
|
||||
|
||||
const getRules = async () => {
|
||||
interface PrivateRule {
|
||||
rules: Clash.Rule[];
|
||||
}
|
||||
|
||||
return (await buildRequest())<PrivateRule>("/rules");
|
||||
};
|
||||
|
||||
const getProxiesDelay = async (
|
||||
name: string,
|
||||
options?: {
|
||||
url?: string;
|
||||
timeout?: number;
|
||||
},
|
||||
) => {
|
||||
return (await buildRequest())<{ delay: number }>(
|
||||
`/proxies/${encodeURIComponent(name)}/delay`,
|
||||
{
|
||||
params: {
|
||||
timeout: options?.timeout || 10000,
|
||||
url: options?.url || "http://www.gstatic.com/generate_204",
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const getProxies = async () => {
|
||||
interface PrivateProxy {
|
||||
proxies: Clash.Proxy[];
|
||||
}
|
||||
|
||||
return (await buildRequest())<PrivateProxy>("/proxies");
|
||||
};
|
||||
|
||||
const setProxies = async ({
|
||||
group,
|
||||
proxy,
|
||||
}: {
|
||||
group: string;
|
||||
proxy: string;
|
||||
}) => {
|
||||
return (await buildRequest())(`/proxies/${encodeURIComponent(group)}`, {
|
||||
method: "PUT",
|
||||
body: { name: proxy },
|
||||
});
|
||||
};
|
||||
|
||||
const deleteConnections = async () => {
|
||||
return (await buildRequest())(`/connections`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
getConfigs,
|
||||
setConfigs,
|
||||
getVersion,
|
||||
getRules,
|
||||
getProxiesDelay,
|
||||
getProxies,
|
||||
setProxies,
|
||||
deleteConnections,
|
||||
};
|
||||
};
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./types";
|
||||
export * from "./tauri";
|
||||
export * from "./clash";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { VergeConfig } from "./types";
|
||||
import { ClashInfo, VergeConfig } from "./types";
|
||||
|
||||
export const nyanpasuConfig = {
|
||||
get: async () => {
|
||||
@@ -10,3 +10,7 @@ export const nyanpasuConfig = {
|
||||
return await invoke<void>("patch_verge_config", { payload });
|
||||
},
|
||||
};
|
||||
|
||||
export const getClashInfo = async () => {
|
||||
return await invoke<ClashInfo | null>("get_clash_info");
|
||||
};
|
||||
|
||||
@@ -44,3 +44,9 @@ export interface VergeConfig {
|
||||
external_controller_port_strategy: "fixed" | "random" | "allow_fallback";
|
||||
};
|
||||
}
|
||||
|
||||
export interface ClashInfo {
|
||||
port?: number;
|
||||
server?: string;
|
||||
secret?: string;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"@dnd-kit/utilities": "3.2.2",
|
||||
"@emotion/react": "11.11.4",
|
||||
"@emotion/styled": "11.11.5",
|
||||
"@generouted/react-router": "1.19.2",
|
||||
"@generouted/react-router": "1.19.3",
|
||||
"@juggle/resize-observer": "3.4.0",
|
||||
"@mui/icons-material": "5.15.15",
|
||||
"@mui/lab": "5.0.0-alpha.170",
|
||||
|
||||
@@ -1,57 +1,45 @@
|
||||
import { BasePage } from "@/components/base";
|
||||
import { ProviderButton } from "@/components/proxy/provider-button";
|
||||
import { ProxyGroups } from "@/components/proxy/proxy-groups";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import {
|
||||
closeAllConnections,
|
||||
getClashConfig,
|
||||
updateConfigs,
|
||||
} from "@/services/api";
|
||||
import { patchClashConfig } from "@/services/cmds";
|
||||
import { Box, Button, ButtonGroup, Paper } from "@mui/material";
|
||||
import { Box, Button, ButtonGroup } from "@mui/material";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useSWR from "swr";
|
||||
import { useNyanpasu, useClash } from "@nyanpasu/interface";
|
||||
|
||||
export default function ProxyPage() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data: clashConfig, mutate: mutateClash } = useSWR(
|
||||
"getClashConfig",
|
||||
getClashConfig,
|
||||
);
|
||||
const { nyanpasuConfig } = useNyanpasu();
|
||||
|
||||
const { verge } = useVerge();
|
||||
const { getConfigs, setConfigs, deleteConnections } = useClash();
|
||||
|
||||
const modeList = useMemo(() => {
|
||||
if (
|
||||
verge?.clash_core === "mihomo" ||
|
||||
verge?.clash_core === "mihomo-alpha" ||
|
||||
verge?.clash_core === "clash-rs"
|
||||
) {
|
||||
return ["rule", "global", "direct"];
|
||||
}
|
||||
return ["rule", "global", "direct", "script"];
|
||||
}, [verge?.clash_core]);
|
||||
const defaultModes = ["rule", "global", "direct"];
|
||||
|
||||
const curMode = clashConfig?.mode?.toLowerCase();
|
||||
return ["mihomo", "mihomo-alpha", "clash-rs"].includes(
|
||||
nyanpasuConfig?.clash_core,
|
||||
)
|
||||
? defaultModes
|
||||
: [...defaultModes, "script"];
|
||||
}, [nyanpasuConfig?.clash_core]);
|
||||
|
||||
const onChangeMode = useLockFn(async (mode: string) => {
|
||||
// 断开连接
|
||||
if (mode !== curMode && verge?.auto_close_connection) {
|
||||
closeAllConnections();
|
||||
const currentMode = getConfigs.data?.mode?.toLowerCase();
|
||||
|
||||
const onChangeMode = useLockFn(async (mode) => {
|
||||
if (mode !== currentMode && nyanpasuConfig?.auto_close_connection) {
|
||||
await deleteConnections();
|
||||
}
|
||||
await updateConfigs({ mode });
|
||||
await patchClashConfig({ mode });
|
||||
mutateClash();
|
||||
|
||||
await setConfigs({ mode });
|
||||
await getConfigs.mutate();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (curMode && !modeList.includes(curMode)) {
|
||||
if (currentMode && !modeList.includes(currentMode)) {
|
||||
onChangeMode("rule");
|
||||
}
|
||||
}, [curMode]);
|
||||
}, [currentMode, modeList, onChangeMode]);
|
||||
|
||||
return (
|
||||
<BasePage
|
||||
@@ -66,7 +54,7 @@ export default function ProxyPage() {
|
||||
{modeList.map((mode) => (
|
||||
<Button
|
||||
key={mode}
|
||||
variant={mode === curMode ? "contained" : "outlined"}
|
||||
variant={mode === currentMode ? "contained" : "outlined"}
|
||||
onClick={() => onChangeMode(mode)}
|
||||
sx={{ textTransform: "capitalize" }}
|
||||
>
|
||||
@@ -77,7 +65,7 @@ export default function ProxyPage() {
|
||||
</Box>
|
||||
}
|
||||
>
|
||||
<ProxyGroups mode={curMode!} />
|
||||
<ProxyGroups mode={currentMode!} />
|
||||
</BasePage>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"manifest_version": 1,
|
||||
"latest": {
|
||||
"mihomo": "v1.18.3",
|
||||
"mihomo_alpha": "alpha-6f0fe85",
|
||||
"mihomo_alpha": "alpha-d84f88b",
|
||||
"clash_rs": "v0.1.16",
|
||||
"clash_premium": "2023-09-05-gdcc8d87"
|
||||
},
|
||||
@@ -12,14 +12,14 @@
|
||||
"linux-aarch64": "mihomo-linux-arm64-{}.gz",
|
||||
"linux-amd64": "mihomo-linux-amd64-compatible-{}.gz",
|
||||
"darwin-arm64": "mihomo-darwin-arm64-{}.gz",
|
||||
"darwin-x64": "mihomo-darwin-amd64-{}.gz"
|
||||
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz"
|
||||
},
|
||||
"mihomo_alpha": {
|
||||
"windows-x86_64": "mihomo-windows-amd64-compatible-{}.zip",
|
||||
"linux-aarch64": "mihomo-linux-arm64-{}.gz",
|
||||
"linux-amd64": "mihomo-linux-amd64-compatible-{}.gz",
|
||||
"darwin-arm64": "mihomo-darwin-arm64-{}.gz",
|
||||
"darwin-x64": "mihomo-darwin-amd64-{}.gz"
|
||||
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz"
|
||||
},
|
||||
"clash_rs": {
|
||||
"windows-x86_64": "clash-x86_64-pc-windows-msvc.exe",
|
||||
@@ -36,5 +36,5 @@
|
||||
"darwin-x64": "clash-darwin-amd64-n{}.gz"
|
||||
}
|
||||
},
|
||||
"updated_at": "2024-04-12T22:18:27.892Z"
|
||||
"updated_at": "2024-04-13T22:18:27.726Z"
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@
|
||||
"lodash-es": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "19.2.1",
|
||||
"@commitlint/config-conventional": "19.1.0",
|
||||
"@commitlint/cli": "19.2.2",
|
||||
"@commitlint/config-conventional": "19.2.2",
|
||||
"@tauri-apps/cli": "1.5.11",
|
||||
"@types/fs-extra": "11.0.4",
|
||||
"@types/lodash-es": "4.17.12",
|
||||
|
||||
Generated
+44
-21
@@ -19,11 +19,11 @@ importers:
|
||||
version: 4.17.21
|
||||
devDependencies:
|
||||
'@commitlint/cli':
|
||||
specifier: 19.2.1
|
||||
version: 19.2.1(@types/node@20.12.7)(typescript@5.4.5)
|
||||
specifier: 19.2.2
|
||||
version: 19.2.2(@types/node@20.12.7)(typescript@5.4.5)
|
||||
'@commitlint/config-conventional':
|
||||
specifier: 19.1.0
|
||||
version: 19.1.0
|
||||
specifier: 19.2.2
|
||||
version: 19.2.2
|
||||
'@tauri-apps/cli':
|
||||
specifier: 1.5.11
|
||||
version: 1.5.11
|
||||
@@ -135,6 +135,9 @@ importers:
|
||||
'@tauri-apps/api':
|
||||
specifier: 1.5.3
|
||||
version: 1.5.3
|
||||
ofetch:
|
||||
specifier: 1.3.4
|
||||
version: 1.3.4
|
||||
swr:
|
||||
specifier: 2.2.5
|
||||
version: 2.2.5(react@18.2.0)
|
||||
@@ -157,8 +160,8 @@ importers:
|
||||
specifier: 11.11.5
|
||||
version: 11.11.5(@emotion/react@11.11.4)(@types/react@18.2.78)(react@18.2.0)
|
||||
'@generouted/react-router':
|
||||
specifier: 1.19.2
|
||||
version: 1.19.2(react-router-dom@6.22.3)(react@18.2.0)(vite@5.2.8)
|
||||
specifier: 1.19.3
|
||||
version: 1.19.3(react-router-dom@6.22.3)(react@18.2.0)(vite@5.2.8)
|
||||
'@juggle/resize-observer':
|
||||
specifier: 3.4.0
|
||||
version: 3.4.0
|
||||
@@ -562,13 +565,13 @@ packages:
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
to-fast-properties: 2.0.0
|
||||
|
||||
/@commitlint/cli@19.2.1(@types/node@20.12.7)(typescript@5.4.5):
|
||||
resolution: {integrity: sha512-cbkYUJsLqRomccNxvoJTyv5yn0bSy05BBizVyIcLACkRbVUqYorC351Diw/XFSWC/GtpwiwT2eOvQgFZa374bg==}
|
||||
/@commitlint/cli@19.2.2(@types/node@20.12.7)(typescript@5.4.5):
|
||||
resolution: {integrity: sha512-P8cbOHfg2PQRzfICLSrzUVOCVMqjEZ8Hlth6mtJ4yOEjT47Q5PbIGymgX3rLVylNw+3IAT2Djn9IJ2wHbXFzBg==}
|
||||
engines: {node: '>=v18'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@commitlint/format': 19.0.3
|
||||
'@commitlint/lint': 19.1.0
|
||||
'@commitlint/lint': 19.2.2
|
||||
'@commitlint/load': 19.2.0(@types/node@20.12.7)(typescript@5.4.5)
|
||||
'@commitlint/read': 19.2.1
|
||||
'@commitlint/types': 19.0.3
|
||||
@@ -579,8 +582,8 @@ packages:
|
||||
- typescript
|
||||
dev: true
|
||||
|
||||
/@commitlint/config-conventional@19.1.0:
|
||||
resolution: {integrity: sha512-KIKD2xrp6Uuk+dcZVj3++MlzIr/Su6zLE8crEDQCZNvWHNQSeeGbzOlNtsR32TUy6H3JbP7nWgduAHCaiGQ6EA==}
|
||||
/@commitlint/config-conventional@19.2.2:
|
||||
resolution: {integrity: sha512-mLXjsxUVLYEGgzbxbxicGPggDuyWNkf25Ht23owXIH+zV2pv1eJuzLK3t1gDY5Gp6pxdE60jZnWUY5cvgL3ufw==}
|
||||
engines: {node: '>=v18'}
|
||||
dependencies:
|
||||
'@commitlint/types': 19.0.3
|
||||
@@ -620,19 +623,19 @@ packages:
|
||||
chalk: 5.3.0
|
||||
dev: true
|
||||
|
||||
/@commitlint/is-ignored@19.0.3:
|
||||
resolution: {integrity: sha512-MqDrxJaRSVSzCbPsV6iOKG/Lt52Y+PVwFVexqImmYYFhe51iVJjK2hRhOG2jUAGiUHk4jpdFr0cZPzcBkSzXDQ==}
|
||||
/@commitlint/is-ignored@19.2.2:
|
||||
resolution: {integrity: sha512-eNX54oXMVxncORywF4ZPFtJoBm3Tvp111tg1xf4zWXGfhBPKpfKG6R+G3G4v5CPlRROXpAOpQ3HMhA9n1Tck1g==}
|
||||
engines: {node: '>=v18'}
|
||||
dependencies:
|
||||
'@commitlint/types': 19.0.3
|
||||
semver: 7.6.0
|
||||
dev: true
|
||||
|
||||
/@commitlint/lint@19.1.0:
|
||||
resolution: {integrity: sha512-ESjaBmL/9cxm+eePyEr6SFlBUIYlYpI80n+Ltm7IA3MAcrmiP05UMhJdAD66sO8jvo8O4xdGn/1Mt2G5VzfZKw==}
|
||||
/@commitlint/lint@19.2.2:
|
||||
resolution: {integrity: sha512-xrzMmz4JqwGyKQKTpFzlN0dx0TAiT7Ran1fqEBgEmEj+PU98crOFtysJgY+QdeSagx6EDRigQIXJVnfrI0ratA==}
|
||||
engines: {node: '>=v18'}
|
||||
dependencies:
|
||||
'@commitlint/is-ignored': 19.0.3
|
||||
'@commitlint/is-ignored': 19.2.2
|
||||
'@commitlint/parse': 19.0.3
|
||||
'@commitlint/rules': 19.0.3
|
||||
'@commitlint/types': 19.0.3
|
||||
@@ -1388,15 +1391,15 @@ packages:
|
||||
resolution: {integrity: sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==}
|
||||
dev: false
|
||||
|
||||
/@generouted/react-router@1.19.2(react-router-dom@6.22.3)(react@18.2.0)(vite@5.2.8):
|
||||
resolution: {integrity: sha512-glHSqsrXZ7t524PgmQOD+fuxFVIuFOyAsYkPI+lbuskGm7Us/FknrkuxiuS4b5wPpHapDnOCChqLdumwvRxBng==}
|
||||
/@generouted/react-router@1.19.3(react-router-dom@6.22.3)(react@18.2.0)(vite@5.2.8):
|
||||
resolution: {integrity: sha512-3/Y0j302HnwxyU0KOoCOFSVwJZN4eD73+CVtSaOKUnLbGW1ftP1dT8Eur14PALGvZOVR4gsFrUJFq6a4c/kWvQ==}
|
||||
peerDependencies:
|
||||
react: '>=18'
|
||||
react-router-dom: '>=6'
|
||||
vite: '>=4'
|
||||
dependencies:
|
||||
fast-glob: 3.3.2
|
||||
generouted: 1.19.2(vite@5.2.8)
|
||||
generouted: 1.19.3(vite@5.2.8)
|
||||
react: 18.2.0
|
||||
react-router-dom: 6.22.3(react-dom@18.2.0)(react@18.2.0)
|
||||
vite: 5.2.8(@types/node@20.12.7)(sass@1.75.0)
|
||||
@@ -3293,6 +3296,10 @@ packages:
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/destr@2.0.3:
|
||||
resolution: {integrity: sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==}
|
||||
dev: false
|
||||
|
||||
/devlop@1.1.0:
|
||||
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
||||
dependencies:
|
||||
@@ -4157,8 +4164,8 @@ packages:
|
||||
resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==}
|
||||
dev: true
|
||||
|
||||
/generouted@1.19.2(vite@5.2.8):
|
||||
resolution: {integrity: sha512-kldS/yjNkjytPlQ1m44Gm98NCV1gWmgKJXM+pdtcIEp+x7V2JJTKs86N7jAMH0omnBe9GrhVj5OqtuN8x+VjZA==}
|
||||
/generouted@1.19.3(vite@5.2.8):
|
||||
resolution: {integrity: sha512-1KnOmPYBNryAm+9PvvOTOzKiWvuBKRwK+Xr4dP/I9U00y7UAv/VrFGeb0v7mYMiny6jpWBmfBFKaUvq4Q0Z4dQ==}
|
||||
peerDependencies:
|
||||
vite: '>=3'
|
||||
dependencies:
|
||||
@@ -5516,6 +5523,10 @@ packages:
|
||||
engines: {node: '>=10.5.0'}
|
||||
dev: true
|
||||
|
||||
/node-fetch-native@1.6.4:
|
||||
resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==}
|
||||
dev: false
|
||||
|
||||
/node-fetch@2.7.0:
|
||||
resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}
|
||||
engines: {node: 4.x || >=6.0.0}
|
||||
@@ -5649,6 +5660,14 @@ packages:
|
||||
es-abstract: 1.22.5
|
||||
dev: true
|
||||
|
||||
/ofetch@1.3.4:
|
||||
resolution: {integrity: sha512-KLIET85ik3vhEfS+3fDlc/BAZiAp+43QEC/yCo5zkNoY2YaKvNkOaFr/6wCFgFH1kuYQM5pMNi0Tg8koiIemtw==}
|
||||
dependencies:
|
||||
destr: 2.0.3
|
||||
node-fetch-native: 1.6.4
|
||||
ufo: 1.5.3
|
||||
dev: false
|
||||
|
||||
/once@1.4.0:
|
||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
||||
dependencies:
|
||||
@@ -6960,6 +6979,10 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/ufo@1.5.3:
|
||||
resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==}
|
||||
dev: false
|
||||
|
||||
/unbox-primitive@1.0.2:
|
||||
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
||||
dependencies:
|
||||
|
||||
@@ -72,7 +72,7 @@ const MIHOMO_VERSION = versionManifest.latest.mihomo;
|
||||
const MIHOMO_URL_PREFIX = `https://github.com/MetaCubeX/mihomo/releases/download/${MIHOMO_VERSION}`;
|
||||
const MIHOMO_MAP = {
|
||||
"win32-x64": "mihomo-windows-amd64-compatible",
|
||||
"darwin-x64": "mihomo-darwin-amd64",
|
||||
"darwin-x64": "mihomo-darwin-amd64-compatible",
|
||||
"darwin-arm64": "mihomo-darwin-arm64",
|
||||
"linux-x64": "mihomo-linux-amd64-compatible",
|
||||
"linux-arm64": "mihomo-linux-arm64",
|
||||
@@ -85,7 +85,7 @@ let MIHOMO_ALPHA_VERSION = versionManifest.latest.mihomo_alpha;
|
||||
const MIHOMO_ALPHA_URL_PREFIX = `https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha`;
|
||||
const MIHOMO_ALPHA_MAP = {
|
||||
"win32-x64": "mihomo-windows-amd64-compatible",
|
||||
"darwin-x64": "mihomo-darwin-amd64",
|
||||
"darwin-x64": "mihomo-darwin-amd64-compatible",
|
||||
"darwin-arm64": "mihomo-darwin-arm64",
|
||||
"linux-x64": "mihomo-linux-amd64-compatible",
|
||||
"linux-arm64": "mihomo-linux-arm64",
|
||||
|
||||
@@ -72,7 +72,7 @@ const resolveMihomo: LatestVersionResolver = async () => {
|
||||
[SupportedArch.LinuxAarch64]: "mihomo-linux-arm64-{}.gz",
|
||||
[SupportedArch.LinuxAmd64]: "mihomo-linux-amd64-compatible-{}.gz",
|
||||
[SupportedArch.DarwinArm64]: "mihomo-darwin-arm64-{}.gz",
|
||||
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-{}.gz",
|
||||
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-compatible-{}.gz",
|
||||
} satisfies ArchMapping;
|
||||
return {
|
||||
name: "mihomo",
|
||||
@@ -95,7 +95,7 @@ const resolveMihomoAlpha: LatestVersionResolver = async () => {
|
||||
[SupportedArch.LinuxAarch64]: "mihomo-linux-arm64-{}.gz",
|
||||
[SupportedArch.LinuxAmd64]: "mihomo-linux-amd64-compatible-{}.gz",
|
||||
[SupportedArch.DarwinArm64]: "mihomo-darwin-arm64-{}.gz",
|
||||
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-{}.gz",
|
||||
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-compatible-{}.gz",
|
||||
} satisfies ArchMapping;
|
||||
return {
|
||||
name: "mihomo_alpha",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-6.6 = .26
|
||||
LINUX_KERNEL_HASH-6.6.26 = af54b449f4fb93b8e8daa346144a7309e8e95174bd962c4b5917cf56120456d9
|
||||
LINUX_VERSION-6.6 = .27
|
||||
LINUX_KERNEL_HASH-6.6.27 = 639e50060e3c8f23ed017cb10cfeacc6ba88ff5583812bb76859b4cc6a128291
|
||||
|
||||
@@ -142,7 +142,7 @@ $(eval $(call KernelPackage,mii))
|
||||
define KernelPackage/mdio-devres
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Supports MDIO device registration
|
||||
DEPENDS:=@!LINUX_5_4 +kmod-libphy +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
DEPENDS:=@!LINUX_5_4 +kmod-libphy +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_loongarch64||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
KCONFIG:=CONFIG_MDIO_DEVRES
|
||||
HIDDEN:=1
|
||||
FILES:=$(LINUX_DIR)/drivers/net/phy/mdio_devres.ko
|
||||
@@ -159,7 +159,7 @@ $(eval $(call KernelPackage,mdio-devres))
|
||||
define KernelPackage/mdio-gpio
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:= Supports GPIO lib-based MDIO busses
|
||||
DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
DEPENDS:=+kmod-libphy @GPIO_SUPPORT +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_loongarch64||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
KCONFIG:= \
|
||||
CONFIG_MDIO_BITBANG \
|
||||
CONFIG_MDIO_GPIO
|
||||
@@ -475,7 +475,7 @@ $(eval $(call KernelPackage,switch-rtl8306))
|
||||
define KernelPackage/switch-rtl8366-smi
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Realtek RTL8366 SMI switch interface support
|
||||
DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
DEPENDS:=@GPIO_SUPPORT +kmod-swconfig +(TARGET_armvirt||TARGET_bcm27xx_bcm2708||TARGET_loongarch64||TARGET_malta||TARGET_tegra):kmod-of-mdio
|
||||
KCONFIG:=CONFIG_RTL8366_SMI
|
||||
FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko
|
||||
AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi,1)
|
||||
|
||||
+7
-7
@@ -121,7 +121,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
u32 vsc85xx_csr_read(struct phy_device *phydev,
|
||||
--- a/drivers/net/phy/phy_device.c
|
||||
+++ b/drivers/net/phy/phy_device.c
|
||||
@@ -1650,20 +1650,22 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_1
|
||||
@@ -1658,20 +1658,22 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_1
|
||||
/**
|
||||
* phy_package_join - join a common PHY group
|
||||
* @phydev: target phy_device struct
|
||||
@@ -151,7 +151,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
*
|
||||
* This will set the shared pointer of the phydev to the shared storage.
|
||||
* If this is the first call for a this cookie the shared storage will be
|
||||
@@ -1673,17 +1675,17 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_1
|
||||
@@ -1681,17 +1683,17 @@ EXPORT_SYMBOL_GPL(phy_driver_is_genphy_1
|
||||
* Returns < 1 on error, 0 on success. Esp. calling phy_package_join()
|
||||
* with the same cookie but a different priv_size is an error.
|
||||
*/
|
||||
@@ -172,7 +172,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
if (!shared) {
|
||||
ret = -ENOMEM;
|
||||
shared = kzalloc(sizeof(*shared), GFP_KERNEL);
|
||||
@@ -1695,9 +1697,9 @@ int phy_package_join(struct phy_device *
|
||||
@@ -1703,9 +1705,9 @@ int phy_package_join(struct phy_device *
|
||||
goto err_free;
|
||||
shared->priv_size = priv_size;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
} else {
|
||||
ret = -EINVAL;
|
||||
if (priv_size && priv_size != shared->priv_size)
|
||||
@@ -1735,7 +1737,7 @@ void phy_package_leave(struct phy_device
|
||||
@@ -1743,7 +1745,7 @@ void phy_package_leave(struct phy_device
|
||||
return;
|
||||
|
||||
if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) {
|
||||
@@ -193,7 +193,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mutex_unlock(&bus->shared_lock);
|
||||
kfree(shared->priv);
|
||||
kfree(shared);
|
||||
@@ -1754,7 +1756,8 @@ static void devm_phy_package_leave(struc
|
||||
@@ -1762,7 +1764,8 @@ static void devm_phy_package_leave(struc
|
||||
* devm_phy_package_join - resource managed phy_package_join()
|
||||
* @dev: device that is registering this PHY package
|
||||
* @phydev: target phy_device struct
|
||||
@@ -203,7 +203,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
* @priv_size: if non-zero allocate this amount of bytes for private data
|
||||
*
|
||||
* Managed phy_package_join(). Shared storage fetched by this function,
|
||||
@@ -1762,7 +1765,7 @@ static void devm_phy_package_leave(struc
|
||||
@@ -1770,7 +1773,7 @@ static void devm_phy_package_leave(struc
|
||||
* phy_package_join() for more information.
|
||||
*/
|
||||
int devm_phy_package_join(struct device *dev, struct phy_device *phydev,
|
||||
@@ -212,7 +212,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
{
|
||||
struct phy_device **ptr;
|
||||
int ret;
|
||||
@@ -1772,7 +1775,7 @@ int devm_phy_package_join(struct device
|
||||
@@ -1780,7 +1783,7 @@ int devm_phy_package_join(struct device
|
||||
if (!ptr)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/phy/phy_device.c
|
||||
+++ b/drivers/net/phy/phy_device.c
|
||||
@@ -1698,6 +1698,7 @@ int phy_package_join(struct phy_device *
|
||||
@@ -1706,6 +1706,7 @@ int phy_package_join(struct phy_device *
|
||||
shared->priv_size = priv_size;
|
||||
}
|
||||
shared->base_addr = base_addr;
|
||||
@@ -35,7 +35,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
refcount_set(&shared->refcnt, 1);
|
||||
bus->shared[base_addr] = shared;
|
||||
} else {
|
||||
@@ -1721,6 +1722,63 @@ err_unlock:
|
||||
@@ -1729,6 +1730,63 @@ err_unlock:
|
||||
EXPORT_SYMBOL_GPL(phy_package_join);
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
* phy_package_leave - leave a common PHY group
|
||||
* @phydev: target phy_device struct
|
||||
*
|
||||
@@ -1736,6 +1794,10 @@ void phy_package_leave(struct phy_device
|
||||
@@ -1744,6 +1802,10 @@ void phy_package_leave(struct phy_device
|
||||
if (!shared)
|
||||
return;
|
||||
|
||||
@@ -110,7 +110,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) {
|
||||
bus->shared[shared->base_addr] = NULL;
|
||||
mutex_unlock(&bus->shared_lock);
|
||||
@@ -1789,6 +1851,40 @@ int devm_phy_package_join(struct device
|
||||
@@ -1797,6 +1859,40 @@ int devm_phy_package_join(struct device
|
||||
EXPORT_SYMBOL_GPL(devm_phy_package_join);
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/phy/phy_device.c
|
||||
+++ b/drivers/net/phy/phy_device.c
|
||||
@@ -2607,12 +2607,15 @@ EXPORT_SYMBOL(genphy_read_status);
|
||||
@@ -2615,12 +2615,15 @@ EXPORT_SYMBOL(genphy_read_status);
|
||||
/**
|
||||
* genphy_c37_read_status - check the link status and update current link state
|
||||
* @phydev: target phy_device struct
|
||||
@@ -58,7 +58,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
{
|
||||
int lpa, err, old_link = phydev->link;
|
||||
|
||||
@@ -2622,9 +2625,13 @@ int genphy_c37_read_status(struct phy_de
|
||||
@@ -2630,9 +2633,13 @@ int genphy_c37_read_status(struct phy_de
|
||||
return err;
|
||||
|
||||
/* why bother the PHY if nothing can have changed */
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/phy/phy_device.c
|
||||
+++ b/drivers/net/phy/phy_device.c
|
||||
@@ -3198,6 +3198,7 @@ static int of_phy_led(struct phy_device
|
||||
@@ -3201,6 +3201,7 @@ static int of_phy_led(struct phy_device
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct led_init_data init_data = {};
|
||||
struct led_classdev *cdev;
|
||||
@@ -36,7 +36,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
struct phy_led *phyled;
|
||||
u32 index;
|
||||
int err;
|
||||
@@ -3215,6 +3216,21 @@ static int of_phy_led(struct phy_device
|
||||
@@ -3218,6 +3219,21 @@ static int of_phy_led(struct phy_device
|
||||
if (index > U8_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
+8
-8
@@ -23,7 +23,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
|
||||
--- a/drivers/bus/mhi/host/init.c
|
||||
+++ b/drivers/bus/mhi/host/init.c
|
||||
@@ -881,6 +881,7 @@ static int parse_config(struct mhi_contr
|
||||
@@ -882,6 +882,7 @@ static int parse_config(struct mhi_contr
|
||||
if (!mhi_cntrl->timeout_ms)
|
||||
mhi_cntrl->timeout_ms = MHI_TIMEOUT_MS;
|
||||
|
||||
@@ -33,7 +33,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
if (!mhi_cntrl->buffer_len)
|
||||
--- a/drivers/bus/mhi/host/internal.h
|
||||
+++ b/drivers/bus/mhi/host/internal.h
|
||||
@@ -321,7 +321,7 @@ int __must_check mhi_read_reg_field(stru
|
||||
@@ -324,7 +324,7 @@ int __must_check mhi_read_reg_field(stru
|
||||
u32 *out);
|
||||
int __must_check mhi_poll_reg_field(struct mhi_controller *mhi_cntrl,
|
||||
void __iomem *base, u32 offset, u32 mask,
|
||||
@@ -60,7 +60,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
ret = mhi_read_reg_field(mhi_cntrl, base, offset, mask, &out);
|
||||
--- a/drivers/bus/mhi/host/pm.c
|
||||
+++ b/drivers/bus/mhi/host/pm.c
|
||||
@@ -163,6 +163,7 @@ int mhi_ready_state_transition(struct mh
|
||||
@@ -171,6 +171,7 @@ int mhi_ready_state_transition(struct mh
|
||||
enum mhi_pm_state cur_state;
|
||||
struct device *dev = &mhi_cntrl->mhi_dev->dev;
|
||||
u32 interval_us = 25000; /* poll register field every 25 milliseconds */
|
||||
@@ -68,7 +68,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
int ret, i;
|
||||
|
||||
/* Check if device entered error state */
|
||||
@@ -173,14 +174,18 @@ int mhi_ready_state_transition(struct mh
|
||||
@@ -181,14 +182,18 @@ int mhi_ready_state_transition(struct mh
|
||||
|
||||
/* Wait for RESET to be cleared and READY bit to be set by the device */
|
||||
ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL,
|
||||
@@ -89,7 +89,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
if (ret) {
|
||||
dev_err(dev, "Device failed to enter MHI Ready\n");
|
||||
return ret;
|
||||
@@ -479,7 +484,7 @@ static void mhi_pm_disable_transition(st
|
||||
@@ -487,7 +492,7 @@ static void mhi_pm_disable_transition(st
|
||||
|
||||
/* Wait for the reset bit to be cleared by the device */
|
||||
ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL,
|
||||
@@ -98,7 +98,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
if (ret)
|
||||
dev_err(dev, "Device failed to clear MHI Reset\n");
|
||||
|
||||
@@ -492,8 +497,8 @@ static void mhi_pm_disable_transition(st
|
||||
@@ -500,8 +505,8 @@ static void mhi_pm_disable_transition(st
|
||||
if (!MHI_IN_PBL(mhi_get_exec_env(mhi_cntrl))) {
|
||||
/* wait for ready to be set */
|
||||
ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs,
|
||||
@@ -109,7 +109,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
if (ret)
|
||||
dev_err(dev, "Device failed to enter READY state\n");
|
||||
}
|
||||
@@ -1111,7 +1116,8 @@ int mhi_async_power_up(struct mhi_contro
|
||||
@@ -1125,7 +1130,8 @@ int mhi_async_power_up(struct mhi_contro
|
||||
if (state == MHI_STATE_SYS_ERR) {
|
||||
mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET);
|
||||
ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL,
|
||||
@@ -119,7 +119,7 @@ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
if (ret) {
|
||||
dev_info(dev, "Failed to reset MHI due to syserr state\n");
|
||||
goto error_exit;
|
||||
@@ -1202,14 +1208,18 @@ EXPORT_SYMBOL_GPL(mhi_power_down);
|
||||
@@ -1216,14 +1222,18 @@ EXPORT_SYMBOL_GPL(mhi_power_down);
|
||||
int mhi_sync_power_up(struct mhi_controller *mhi_cntrl)
|
||||
{
|
||||
int ret = mhi_async_power_up(mhi_cntrl);
|
||||
|
||||
@@ -7300,8 +7300,8 @@ CONFIG_USB_BELKIN=y
|
||||
# CONFIG_USB_CDNS3 is not set
|
||||
# CONFIG_USB_CDNS3_IMX is not set
|
||||
# CONFIG_USB_CDNS3_PCI_WRAP is not set
|
||||
# CONFIG_USB_CDNS_SUPPORT is not set
|
||||
# CONFIG_USB_CDNSP_PCI is not set
|
||||
# CONFIG_USB_CDNS_SUPPORT is not set
|
||||
# CONFIG_USB_CHAOSKEY is not set
|
||||
# CONFIG_USB_CHIPIDEA is not set
|
||||
# CONFIG_USB_CHIPIDEA_GENERIC is not set
|
||||
|
||||
@@ -141,7 +141,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
if (err)
|
||||
--- a/scripts/mod/modpost.c
|
||||
+++ b/scripts/mod/modpost.c
|
||||
@@ -1690,7 +1690,9 @@ static void read_symbols(const char *mod
|
||||
@@ -1692,7 +1692,9 @@ static void read_symbols(const char *mod
|
||||
symname = remove_dot(info.strtab + sym->st_name);
|
||||
|
||||
handle_symbol(mod, &info, sym, symname);
|
||||
@@ -151,7 +151,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
}
|
||||
|
||||
check_sec_ref(mod, &info);
|
||||
@@ -1863,8 +1865,10 @@ static void add_header(struct buffer *b,
|
||||
@@ -1865,8 +1867,10 @@ static void add_header(struct buffer *b,
|
||||
buf_printf(b, "BUILD_SALT;\n");
|
||||
buf_printf(b, "BUILD_LTO_INFO;\n");
|
||||
buf_printf(b, "\n");
|
||||
@@ -162,7 +162,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
buf_printf(b, "\n");
|
||||
buf_printf(b, "__visible struct module __this_module\n");
|
||||
buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n");
|
||||
@@ -1878,8 +1882,10 @@ static void add_header(struct buffer *b,
|
||||
@@ -1880,8 +1884,10 @@ static void add_header(struct buffer *b,
|
||||
buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n");
|
||||
buf_printf(b, "};\n");
|
||||
|
||||
@@ -173,7 +173,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
buf_printf(b,
|
||||
"\n"
|
||||
@@ -1887,8 +1893,10 @@ static void add_header(struct buffer *b,
|
||||
@@ -1889,8 +1895,10 @@ static void add_header(struct buffer *b,
|
||||
"MODULE_INFO(retpoline, \"Y\");\n"
|
||||
"#endif\n");
|
||||
|
||||
@@ -184,7 +184,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
if (strstarts(mod->name, "tools/testing"))
|
||||
buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n");
|
||||
@@ -1998,11 +2006,13 @@ static void add_depends(struct buffer *b
|
||||
@@ -2000,11 +2008,13 @@ static void add_depends(struct buffer *b
|
||||
|
||||
static void add_srcversion(struct buffer *b, struct module *mod)
|
||||
{
|
||||
@@ -198,7 +198,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
}
|
||||
|
||||
static void write_buf(struct buffer *b, const char *fname)
|
||||
@@ -2085,7 +2095,9 @@ static void write_mod_c_file(struct modu
|
||||
@@ -2087,7 +2097,9 @@ static void write_mod_c_file(struct modu
|
||||
add_exported_symbols(&buf, mod);
|
||||
add_versions(&buf, mod);
|
||||
add_depends(&buf, mod);
|
||||
|
||||
@@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
*/
|
||||
--- a/include/linux/skbuff.h
|
||||
+++ b/include/linux/skbuff.h
|
||||
@@ -3070,6 +3070,10 @@ static inline int pskb_trim(struct sk_bu
|
||||
@@ -3081,6 +3081,10 @@ static inline int pskb_trim(struct sk_bu
|
||||
return (len < skb->len) ? __pskb_trim(skb, len) : 0;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
/**
|
||||
* pskb_trim_unique - remove end from a paged unique (not cloned) buffer
|
||||
* @skb: buffer to alter
|
||||
@@ -3235,16 +3239,6 @@ static inline struct sk_buff *dev_alloc_
|
||||
@@ -3246,16 +3250,6 @@ static inline struct sk_buff *dev_alloc_
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/drivers/usb/serial/option.c
|
||||
+++ b/drivers/usb/serial/option.c
|
||||
@@ -589,6 +589,7 @@
|
||||
@@ -642,6 +642,7 @@ static void option_instat_callback(struc
|
||||
|
||||
|
||||
static const struct usb_device_id option_ids[] = {
|
||||
@@ -8,7 +8,7 @@
|
||||
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
|
||||
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
|
||||
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
|
||||
@@ -2210,6 +2211,15 @@
|
||||
@@ -2379,6 +2380,15 @@ static int option_probe(struct usb_seria
|
||||
if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
|
||||
return -ENODEV;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
--- a/include/linux/skbuff.h
|
||||
+++ b/include/linux/skbuff.h
|
||||
@@ -3036,7 +3036,7 @@ static inline int pskb_network_may_pull(
|
||||
@@ -3047,7 +3047,7 @@ static inline int pskb_network_may_pull(
|
||||
* NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
|
||||
*/
|
||||
#ifndef NET_SKB_PAD
|
||||
|
||||
+7
-7
@@ -361,7 +361,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
memcpy(p->name, u->name, sizeof(u->name));
|
||||
}
|
||||
|
||||
@@ -1963,6 +2133,15 @@ static int ip6_tnl_validate(struct nlatt
|
||||
@@ -1964,6 +2134,15 @@ static int ip6_tnl_validate(struct nlatt
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
static void ip6_tnl_netlink_parms(struct nlattr *data[],
|
||||
struct __ip6_tnl_parm *parms)
|
||||
{
|
||||
@@ -2000,6 +2179,46 @@ static void ip6_tnl_netlink_parms(struct
|
||||
@@ -2001,6 +2180,46 @@ static void ip6_tnl_netlink_parms(struct
|
||||
|
||||
if (data[IFLA_IPTUN_FWMARK])
|
||||
parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]);
|
||||
@@ -424,7 +424,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
}
|
||||
|
||||
static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
|
||||
@@ -2083,6 +2302,12 @@ static void ip6_tnl_dellink(struct net_d
|
||||
@@ -2084,6 +2303,12 @@ static void ip6_tnl_dellink(struct net_d
|
||||
|
||||
static size_t ip6_tnl_get_size(const struct net_device *dev)
|
||||
{
|
||||
@@ -437,7 +437,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
return
|
||||
/* IFLA_IPTUN_LINK */
|
||||
nla_total_size(4) +
|
||||
@@ -2112,6 +2337,24 @@ static size_t ip6_tnl_get_size(const str
|
||||
@@ -2113,6 +2338,24 @@ static size_t ip6_tnl_get_size(const str
|
||||
nla_total_size(0) +
|
||||
/* IFLA_IPTUN_FWMARK */
|
||||
nla_total_size(4) +
|
||||
@@ -462,7 +462,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
0;
|
||||
}
|
||||
|
||||
@@ -2119,6 +2362,9 @@ static int ip6_tnl_fill_info(struct sk_b
|
||||
@@ -2120,6 +2363,9 @@ static int ip6_tnl_fill_info(struct sk_b
|
||||
{
|
||||
struct ip6_tnl *tunnel = netdev_priv(dev);
|
||||
struct __ip6_tnl_parm *parm = &tunnel->parms;
|
||||
@@ -472,7 +472,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
|
||||
if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
|
||||
nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) ||
|
||||
@@ -2128,9 +2374,27 @@ static int ip6_tnl_fill_info(struct sk_b
|
||||
@@ -2129,9 +2375,27 @@ static int ip6_tnl_fill_info(struct sk_b
|
||||
nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
|
||||
nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) ||
|
||||
nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) ||
|
||||
@@ -501,7 +501,7 @@ Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) ||
|
||||
nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) ||
|
||||
nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) ||
|
||||
@@ -2170,6 +2434,7 @@ static const struct nla_policy ip6_tnl_p
|
||||
@@ -2171,6 +2435,7 @@ static const struct nla_policy ip6_tnl_p
|
||||
[IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
|
||||
[IFLA_IPTUN_COLLECT_METADATA] = { .type = NLA_FLAG },
|
||||
[IFLA_IPTUN_FWMARK] = { .type = NLA_U32 },
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
||||
|
||||
--- a/drivers/net/phy/phy_device.c
|
||||
+++ b/drivers/net/phy/phy_device.c
|
||||
@@ -1900,6 +1900,9 @@ void phy_detach(struct phy_device *phyde
|
||||
@@ -1908,6 +1908,9 @@ void phy_detach(struct phy_device *phyde
|
||||
if (phydev->devlink)
|
||||
device_link_del(phydev->devlink);
|
||||
|
||||
|
||||
@@ -46,37 +46,53 @@ static const struct mtk_pin_field_calc mt7988_pin_do_range[] = {
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x30, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x30, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x30, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x30, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x30, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x30, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x30, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x30, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x30, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x30, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0x30, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x30, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x30, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x40, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x40, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x40, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0x30, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x40, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x40, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0x30, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0x30, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0x30, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x30, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x50, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x50, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x50, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x50, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x50, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x50, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x50, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x50, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x50, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x50, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x50, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x50, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x50, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x50, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x50, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x50, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x50, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x50, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x50, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x50, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x50, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x50, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x50, 0x10, 7, 1),
|
||||
@@ -86,17 +102,31 @@ static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x50, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x50, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x50, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x50, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x50, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x50, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x40, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x40, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x40, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x40, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x40, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x40, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x40, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x40, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x40, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x40, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x40, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x40, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x40, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x40, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x40, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x30, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0x30, 0x10, 6, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x30, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x30, 0x10, 11, 1),
|
||||
@@ -104,42 +134,61 @@ static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x30, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0x30, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0x30, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x40, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x40, 0x10, 16, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x40, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x40, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x40, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x40, 0x10, 17, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0xc0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0xc0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0xc0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0xc0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0xc0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0xc0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0xc0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0xc0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0xc0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0xc0, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0xb0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0xb0, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0xb0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0xb0, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0xe0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0xe0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0xe0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0xc0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0xc0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0xe0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0xe0, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0xc0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0xc0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0xc0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0xc0, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0xb0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0xb0, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x140, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x140, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x140, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x140, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x140, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x140, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x140, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x140, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x140, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x140, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x140, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x140, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x140, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x140, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x150, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x140, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x140, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x140, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x140, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x150, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x140, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x140, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x140, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x140, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x140, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x140, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x140, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x140, 0x10, 7, 1),
|
||||
@@ -149,17 +198,31 @@ static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x140, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x140, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x140, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x140, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x140, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x140, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x140, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x140, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0xe0, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0xe0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0xe0, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0xe0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0xe0, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0xe0, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0xe0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0xe0, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0xe0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0xe0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0xe0, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0xe0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0xc0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0xe0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0xe0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0xe0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0xe0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0xe0, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0xc0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0xc0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0xc0, 0x10, 6, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0xb0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0xb0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0xb0, 0x10, 11, 1),
|
||||
@@ -167,8 +230,11 @@ static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0xb0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0xe0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0xe0, 0x10, 16, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0xe0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0xe0, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0xe0, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0xe0, 0x10, 17, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_pu_range[] = {
|
||||
@@ -176,8 +242,11 @@ static const struct mtk_pin_field_calc mt7988_pin_pu_range[] = {
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x60, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x70, 0x10, 0, 1),
|
||||
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x70, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(76, 76, 4, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x60, 0x10, 1, 1),
|
||||
@@ -190,11 +259,19 @@ static const struct mtk_pin_field_calc mt7988_pin_pd_range[] = {
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x40, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0x40, 0x10, 0, 1),
|
||||
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x50, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0x40, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0x40, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0x40, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0x40, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x40, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(76, 76, 4, 0x40, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x40, 0x10, 1, 1),
|
||||
@@ -203,26 +280,37 @@ static const struct mtk_pin_field_calc mt7988_pin_pd_range[] = {
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x00, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x00, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x00, 0x10, 28, 3),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x00, 0x10, 9, 3),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x00, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x00, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x10, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x20, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x20, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x10, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x20, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x20, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x20, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x20, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x20, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x20, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x20, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x30, 0x10, 6, 3),
|
||||
@@ -232,7 +320,8 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x30, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x10, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x00, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x00, 0x10, 21, 3),
|
||||
@@ -242,17 +331,29 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x00, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x10, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x10, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x10, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x10, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x10, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x10, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x10, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x10, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x00, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x00, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x00, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x20, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(64, 65, 1, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(66, 68, 1, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x00, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x10, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x10, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x00, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x10, 0x10, 3, 3),
|
||||
@@ -260,35 +361,49 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x00, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x10, 0x10, 18, 3),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x10, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x10, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x10, 0x10, 21, 3),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_pupd_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x50, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x50, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x50, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x50, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x50, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x50, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x50, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x60, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x50, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x70, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x70, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x70, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x70, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x70, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x70, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x70, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x70, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x70, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x70, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x70, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x70, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x70, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x70, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x70, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x70, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x70, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x70, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x80, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x70, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x70, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x70, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x70, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x70, 0x10, 7, 1),
|
||||
@@ -298,46 +413,73 @@ static const struct mtk_pin_field_calc mt7988_pin_pupd_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x70, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x70, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x70, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x70, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x70, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x70, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x70, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x60, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x60, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x60, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x60, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x60, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x60, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x60, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x60, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x50, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x60, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x60, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x60, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x60, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x60, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x60, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_r0_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x60, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x60, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x80, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x70, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x70, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x90, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x90, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x90, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x90, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x90, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x90, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x90, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x90, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x90, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x90, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x90, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x90, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x90, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x90, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0xa0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x90, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x90, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x90, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x90, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0xa0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x90, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x90, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x90, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x90, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x90, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x90, 0x10, 7, 1),
|
||||
@@ -347,46 +489,73 @@ static const struct mtk_pin_field_calc mt7988_pin_r0_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x90, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x90, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x90, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x90, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x80, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x80, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x80, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x80, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x80, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x80, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x80, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x80, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x80, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x80, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x80, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x80, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x80, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x80, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x60, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x80, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x80, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x80, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x80, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x80, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x80, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x70, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x70, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x70, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x70, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x70, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x70, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x70, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x90, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x80, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0xb0, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0xb0, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0xb0, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0xb0, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0xb0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0xb0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0xb0, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0xb0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0xb0, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0xb0, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0xb0, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0xb0, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0xb0, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0xb0, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0xc0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0xb0, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0xb0, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0xb0, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0xb0, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0xb0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0xb0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0xb0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0xb0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0xb0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0xb0, 0x10, 7, 1),
|
||||
@@ -396,19 +565,35 @@ static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0xb0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0xb0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0xb0, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0xb0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0xb0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0xb0, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x90, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x90, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x90, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x90, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x90, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x90, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x90, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x90, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x90, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x90, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x90, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x90, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x90, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x70, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x80, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x90, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x90, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x90, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x90, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_reg_calc mt7988_reg_cals[] = {
|
||||
|
||||
@@ -46,37 +46,53 @@ static const struct mtk_pin_field_calc mt7988_pin_do_range[] = {
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x30, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x30, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x30, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x30, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x30, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x30, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x30, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x30, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x30, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x30, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0x30, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x30, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x30, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x40, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x40, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x40, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0x30, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x40, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x40, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0x30, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0x30, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0x30, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x30, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x30, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x50, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x50, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x50, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x50, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x50, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x50, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x50, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x50, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x50, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x50, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x50, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x50, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x50, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x50, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x50, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x50, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x50, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x50, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x50, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x50, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x50, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x50, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x50, 0x10, 7, 1),
|
||||
@@ -86,17 +102,31 @@ static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x50, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x50, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x50, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x50, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x50, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x50, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x40, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x40, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x40, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x40, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x40, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x40, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x40, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x40, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x40, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x40, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x40, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x40, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x40, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x40, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x40, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x30, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0x30, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0x30, 0x10, 6, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x30, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x30, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x30, 0x10, 11, 1),
|
||||
@@ -104,42 +134,61 @@ static const struct mtk_pin_field_calc mt7988_pin_ies_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x30, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0x30, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0x30, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x40, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x40, 0x10, 16, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x40, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x40, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x40, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x40, 0x10, 17, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0xc0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0xc0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0xc0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0xc0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0xc0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0xc0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0xc0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0xc0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0xc0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0xc0, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0xb0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0xb0, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0xb0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0xb0, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0xe0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0xe0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0xe0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0xc0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0xc0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0xe0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0xe0, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0xc0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0xc0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0xc0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0xc0, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0xb0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0xb0, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x140, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x140, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x140, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x140, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x140, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x140, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x140, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x140, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x140, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x140, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x140, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x140, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x140, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x140, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x150, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x140, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x140, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x140, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x140, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x150, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x140, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x140, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x140, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x140, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x140, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x140, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x140, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x140, 0x10, 7, 1),
|
||||
@@ -149,17 +198,31 @@ static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x140, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x140, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x140, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x140, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x140, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x140, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x140, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x140, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0xe0, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0xe0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0xe0, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0xe0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0xe0, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0xe0, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0xe0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0xe0, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0xe0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0xe0, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0xe0, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0xe0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0xc0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0xe0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0xe0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0xe0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0xe0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0xe0, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0xc0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0xc0, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0xc0, 0x10, 6, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0xb0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0xb0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0xb0, 0x10, 11, 1),
|
||||
@@ -167,8 +230,11 @@ static const struct mtk_pin_field_calc mt7988_pin_smt_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0xb0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0xe0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0xe0, 0x10, 16, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0xe0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0xe0, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0xe0, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0xe0, 0x10, 17, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_pu_range[] = {
|
||||
@@ -176,8 +242,11 @@ static const struct mtk_pin_field_calc mt7988_pin_pu_range[] = {
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x60, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x70, 0x10, 0, 1),
|
||||
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x70, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(76, 76, 4, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x60, 0x10, 1, 1),
|
||||
@@ -190,11 +259,19 @@ static const struct mtk_pin_field_calc mt7988_pin_pd_range[] = {
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x40, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(15, 16, 5, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(17, 18, 5, 0x40, 0x10, 0, 1),
|
||||
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x50, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(15, 15, 5, 0x40, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(16, 16, 5, 0x40, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(17, 17, 5, 0x40, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(18, 18, 5, 0x40, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 72, 5, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(71, 71, 5, 0x40, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(72, 72, 5, 0x40, 0x10, 3, 1),
|
||||
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x40, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(76, 76, 4, 0x40, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x40, 0x10, 1, 1),
|
||||
@@ -203,26 +280,37 @@ static const struct mtk_pin_field_calc mt7988_pin_pd_range[] = {
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x00, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x00, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(7, 7, 4, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(8, 8, 4, 0x00, 0x10, 28, 3),
|
||||
PIN_FIELD_BASE(9, 9, 4, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(10, 10, 4, 0x00, 0x10, 9, 3),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(13, 14, 1, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(13, 13, 1, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(14, 14, 1, 0x00, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x00, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x10, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x20, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x20, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x10, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x20, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x20, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x20, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x20, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x20, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x20, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x20, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x20, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x30, 0x10, 6, 3),
|
||||
@@ -232,7 +320,8 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x30, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x10, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x00, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x00, 0x10, 21, 3),
|
||||
@@ -242,17 +331,29 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x00, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x10, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x10, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x10, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x10, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x10, 0x10, 12, 3),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x10, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x10, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x10, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x00, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x00, 0x10, 12, 3),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x00, 0x10, 15, 3),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x00, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x00, 0x10, 9, 3),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x00, 0x10, 21, 3),
|
||||
PIN_FIELD_BASE(63, 63, 1, 0x20, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(64, 65, 1, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(66, 68, 1, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x00, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x00, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x10, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x10, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x00, 0x10, 6, 3),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x10, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x00, 0x10, 3, 3),
|
||||
PIN_FIELD_BASE(75, 75, 4, 0x10, 0x10, 3, 3),
|
||||
@@ -260,35 +361,49 @@ static const struct mtk_pin_field_calc mt7988_pin_drv_range[] = {
|
||||
PIN_FIELD_BASE(77, 77, 4, 0x00, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(78, 78, 4, 0x00, 0x10, 0, 3),
|
||||
PIN_FIELD_BASE(79, 79, 4, 0x10, 0x10, 6, 3),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x10, 0x10, 18, 3),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x10, 0x10, 24, 3),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x10, 0x10, 27, 3),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x10, 0x10, 18, 3),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x10, 0x10, 21, 3),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_pupd_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x50, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x50, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x50, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x50, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x50, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x50, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x50, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x60, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x50, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x50, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x70, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x70, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x70, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x70, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x70, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x70, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x70, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x70, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x70, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x70, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x70, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x70, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x70, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x70, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x70, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x70, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x70, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x70, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0x80, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x70, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x70, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x70, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x70, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x70, 0x10, 7, 1),
|
||||
@@ -298,46 +413,73 @@ static const struct mtk_pin_field_calc mt7988_pin_pupd_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x70, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x70, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x70, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x70, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x70, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x70, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x70, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x60, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x60, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x60, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x60, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x60, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x60, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x60, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x60, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x60, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x50, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x50, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x50, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x50, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x60, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x60, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x60, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x60, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x60, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x60, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_r0_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x60, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x60, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x60, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x60, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x60, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x60, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x60, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x80, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x70, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x70, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0x90, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0x90, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0x90, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0x90, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0x90, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0x90, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0x90, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0x90, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0x90, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0x90, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0x90, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0x90, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0x90, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0x90, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0xa0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0x90, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0x90, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0x90, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0x90, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0xa0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0x90, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0x90, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0x90, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0x90, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0x90, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0x90, 0x10, 7, 1),
|
||||
@@ -347,46 +489,73 @@ static const struct mtk_pin_field_calc mt7988_pin_r0_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0x90, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0x90, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0x90, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0x90, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x80, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x80, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x80, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x80, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x80, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x80, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x80, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x80, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x80, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x80, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x80, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x80, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x80, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x80, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x60, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x60, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x80, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x80, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x80, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x80, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x80, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x80, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = {
|
||||
PIN_FIELD_BASE(0, 1, 5, 0x70, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(2, 3, 5, 0x70, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(0, 0, 5, 0x70, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(1, 1, 5, 0x70, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(2, 2, 5, 0x70, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(3, 3, 5, 0x70, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(4, 4, 5, 0x70, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(5, 6, 5, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(5, 5, 5, 0x70, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(6, 6, 5, 0x70, 0x10, 4, 1),
|
||||
|
||||
PIN_FIELD_BASE(11, 11, 1, 0x90, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(12, 12, 1, 0x90, 0x10, 18, 1),
|
||||
|
||||
PIN_FIELD_BASE(19, 19, 4, 0x80, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(20, 20, 4, 0x80, 0x10, 1, 1),
|
||||
|
||||
PIN_FIELD_BASE(21, 21, 3, 0xb0, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(22, 22, 3, 0xb0, 0x10, 23, 1),
|
||||
PIN_FIELD_BASE(23, 23, 3, 0xb0, 0x10, 20, 1),
|
||||
PIN_FIELD_BASE(24, 24, 3, 0xb0, 0x10, 19, 1),
|
||||
PIN_FIELD_BASE(25, 26, 3, 0xb0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(25, 25, 3, 0xb0, 0x10, 21, 1),
|
||||
PIN_FIELD_BASE(26, 26, 3, 0xb0, 0x10, 22, 1),
|
||||
PIN_FIELD_BASE(27, 27, 3, 0xb0, 0x10, 18, 1),
|
||||
PIN_FIELD_BASE(28, 30, 3, 0xb0, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(28, 28, 3, 0xb0, 0x10, 25, 1),
|
||||
PIN_FIELD_BASE(29, 29, 3, 0xb0, 0x10, 26, 1),
|
||||
PIN_FIELD_BASE(30, 30, 3, 0xb0, 0x10, 27, 1),
|
||||
PIN_FIELD_BASE(31, 31, 3, 0xb0, 0x10, 24, 1),
|
||||
PIN_FIELD_BASE(32, 32, 3, 0xb0, 0x10, 28, 1),
|
||||
PIN_FIELD_BASE(33, 33, 3, 0xc0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(34, 34, 3, 0xb0, 0x10, 31, 1),
|
||||
PIN_FIELD_BASE(35, 36, 3, 0xb0, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(35, 35, 3, 0xb0, 0x10, 29, 1),
|
||||
PIN_FIELD_BASE(36, 36, 3, 0xb0, 0x10, 30, 1),
|
||||
PIN_FIELD_BASE(37, 37, 3, 0xc0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(38, 38, 3, 0xb0, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(39, 39, 3, 0xb0, 0x10, 10, 1),
|
||||
PIN_FIELD_BASE(40, 41, 3, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(40, 40, 3, 0xb0, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(41, 41, 3, 0xb0, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(42, 42, 3, 0xb0, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(43, 43, 3, 0xb0, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(44, 44, 3, 0xb0, 0x10, 7, 1),
|
||||
@@ -396,19 +565,35 @@ static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = {
|
||||
PIN_FIELD_BASE(48, 48, 3, 0xb0, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(49, 49, 3, 0xb0, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(50, 50, 3, 0xb0, 0x10, 15, 1),
|
||||
PIN_FIELD_BASE(51, 53, 3, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(51, 51, 3, 0xb0, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(52, 52, 3, 0xb0, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(53, 53, 3, 0xb0, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(54, 54, 3, 0xb0, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(55, 56, 1, 0x90, 0x10, 12, 1),
|
||||
|
||||
PIN_FIELD_BASE(55, 55, 1, 0x90, 0x10, 12, 1),
|
||||
PIN_FIELD_BASE(56, 56, 1, 0x90, 0x10, 13, 1),
|
||||
PIN_FIELD_BASE(57, 57, 1, 0x90, 0x10, 11, 1),
|
||||
PIN_FIELD_BASE(58, 60, 1, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(58, 58, 1, 0x90, 0x10, 2, 1),
|
||||
PIN_FIELD_BASE(59, 59, 1, 0x90, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(60, 60, 1, 0x90, 0x10, 4, 1),
|
||||
PIN_FIELD_BASE(61, 61, 1, 0x90, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(62, 62, 1, 0x90, 0x10, 5, 1),
|
||||
PIN_FIELD_BASE(64, 68, 1, 0x90, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(69, 70, 5, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(64, 64, 1, 0x90, 0x10, 6, 1),
|
||||
PIN_FIELD_BASE(65, 65, 1, 0x90, 0x10, 7, 1),
|
||||
PIN_FIELD_BASE(66, 66, 1, 0x90, 0x10, 8, 1),
|
||||
PIN_FIELD_BASE(67, 67, 1, 0x90, 0x10, 9, 1),
|
||||
PIN_FIELD_BASE(68, 68, 1, 0x90, 0x10, 10, 1),
|
||||
|
||||
PIN_FIELD_BASE(69, 69, 5, 0x70, 0x10, 1, 1),
|
||||
PIN_FIELD_BASE(70, 70, 5, 0x70, 0x10, 2, 1),
|
||||
|
||||
PIN_FIELD_BASE(73, 73, 4, 0x80, 0x10, 3, 1),
|
||||
PIN_FIELD_BASE(74, 74, 4, 0x80, 0x10, 0, 1),
|
||||
PIN_FIELD_BASE(80, 81, 1, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(82, 83, 1, 0x90, 0x10, 14, 1),
|
||||
|
||||
PIN_FIELD_BASE(80, 80, 1, 0x90, 0x10, 16, 1),
|
||||
PIN_FIELD_BASE(81, 81, 1, 0x90, 0x10, 17, 1),
|
||||
PIN_FIELD_BASE(82, 82, 1, 0x90, 0x10, 14, 1),
|
||||
PIN_FIELD_BASE(83, 83, 1, 0x90, 0x10, 15, 1),
|
||||
};
|
||||
|
||||
static const struct mtk_pin_reg_calc mt7988_reg_cals[] = {
|
||||
@@ -1279,4 +1464,3 @@ static int __init mt7988_pinctrl_init(void)
|
||||
return platform_driver_register(&mt7988_pinctrl_driver);
|
||||
}
|
||||
arch_initcall(mt7988_pinctrl_init);
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ Signed-off-by: wevsty <ty@wevs.org>
|
||||
reg = <0x0 0xff100000 0x0 0x1000>;
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
|
||||
@@ -2106,6 +2106,16 @@
|
||||
@@ -2114,6 +2114,16 @@
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
|
||||
@@ -1025,6 +1025,13 @@
|
||||
@@ -1034,6 +1034,13 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
@@ -203,8 +203,6 @@ CONFIG_HWMON=y
|
||||
CONFIG_HW_CONSOLE=y
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_VIA=y
|
||||
# CONFIG_HYPERVISOR_GUEST is not set
|
||||
CONFIG_HZ_PERIODIC=y
|
||||
CONFIG_HYPERV=y
|
||||
CONFIG_HYPERVISOR_GUEST=y
|
||||
CONFIG_HYPERV_BALLOON=y
|
||||
@@ -214,9 +212,8 @@ CONFIG_HYPERV_STORAGE=y
|
||||
# CONFIG_HYPERV_TESTING is not set
|
||||
CONFIG_HYPERV_TIMER=y
|
||||
CONFIG_HYPERV_UTILS=y
|
||||
CONFIG_PTP_1588_CLOCK_OPTIONAL=y
|
||||
CONFIG_PTP_1588_CLOCK=y
|
||||
# CONFIG_HYPERV_VSOCKETS is not set
|
||||
CONFIG_HZ_PERIODIC=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_ALGOBIT=y
|
||||
# CONFIG_I2C_AMD_MP2 is not set
|
||||
@@ -323,10 +320,9 @@ CONFIG_NEED_SG_DMA_LENGTH=y
|
||||
CONFIG_NET_EGRESS=y
|
||||
CONFIG_NET_INGRESS=y
|
||||
# CONFIG_NET_NS is not set
|
||||
CONFIG_NET_XGRESS=y
|
||||
CONFIG_NLS=y
|
||||
CONFIG_NET_VENDOR_DAVICOM=y
|
||||
CONFIG_NET_VENDOR_FUNGIBLE=y
|
||||
CONFIG_NET_XGRESS=y
|
||||
CONFIG_NLS=y
|
||||
# CONFIG_NOHIGHMEM is not set
|
||||
CONFIG_NR_CPUS=1
|
||||
@@ -408,6 +404,8 @@ CONFIG_PREEMPT_RCU=y
|
||||
CONFIG_PROC_PAGE_MONITOR=y
|
||||
CONFIG_PROC_PID_ARCH_STATUS=y
|
||||
# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set
|
||||
CONFIG_PTP_1588_CLOCK=y
|
||||
CONFIG_PTP_1588_CLOCK_OPTIONAL=y
|
||||
# CONFIG_PUNIT_ATOM_DEBUG is not set
|
||||
CONFIG_RANDOMIZE_KSTACK_OFFSET=y
|
||||
CONFIG_RANDSTRUCT_NONE=y
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright (C) 2023 ImmortalWrt.org
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI app for FileBrowser
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+filebrowser
|
||||
LUCI_TITLE:=LuCI File Browser module
|
||||
LUCI_DEPENDS:=+luci-base
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=Sergey Ponomarev <stokito@gmail.com>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require poll';
|
||||
'require rpc';
|
||||
'require uci';
|
||||
'require view';
|
||||
|
||||
var callServiceList = rpc.declare({
|
||||
object: 'service',
|
||||
method: 'list',
|
||||
params: ['name'],
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
function getServiceStatus() {
|
||||
return L.resolveDefault(callServiceList('filebrowser'), {}).then(function (res) {
|
||||
var isRunning = false;
|
||||
try {
|
||||
isRunning = res['filebrowser']['instances']['instance1']['running'];
|
||||
} catch (e) { }
|
||||
return isRunning;
|
||||
});
|
||||
}
|
||||
|
||||
function renderStatus(isRunning, port) {
|
||||
var spanTemp = '<span style="color:%s"><strong>%s %s</strong></span>';
|
||||
var renderHTML;
|
||||
if (isRunning) {
|
||||
var button = String.format(' <a class="btn cbi-button" href="http://%s:%s" target="_blank" rel="noreferrer noopener">%s</a>',
|
||||
window.location.hostname, port, _('Open Web Interface'));
|
||||
renderHTML = spanTemp.format('green', _('FileBrowser'), _('RUNNING')) + button;
|
||||
} else {
|
||||
renderHTML = spanTemp.format('red', _('FileBrowser'), _('NOT RUNNING'));
|
||||
}
|
||||
|
||||
return renderHTML;
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return uci.load('filebrowser');
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var m, s, o;
|
||||
var webport = (uci.get(data, 'config', 'listen_port') || '8989');
|
||||
|
||||
m = new form.Map('filebrowser', _('FileBrowser'),
|
||||
_('FileBrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files..'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
s.anonymous = true;
|
||||
s.render = function () {
|
||||
poll.add(function () {
|
||||
return L.resolveDefault(getServiceStatus()).then(function (res) {
|
||||
var view = document.getElementById('service_status');
|
||||
view.innerHTML = renderStatus(res, webport);
|
||||
});
|
||||
});
|
||||
|
||||
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
||||
E('p', { id: 'service_status' }, _('Collecting data...'))
|
||||
]);
|
||||
}
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'filebrowser');
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
o.default = o.disabled;
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'listen_port', _('Listen port'));
|
||||
o.datatype = 'port';
|
||||
o.default = '8989';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'root_path', _('Root directory'));
|
||||
o.default = '/mnt';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Flag, 'disable_exec', _('Disable Command Runner feature'));
|
||||
o.default = o.enabled;
|
||||
o.rmempty = false;
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
'require view';
|
||||
'require ui';
|
||||
'require form';
|
||||
|
||||
var formData = {
|
||||
files: {
|
||||
root: null,
|
||||
}
|
||||
};
|
||||
|
||||
return view.extend({
|
||||
render: function() {
|
||||
var m, s, o;
|
||||
|
||||
m = new form.JSONMap(formData, _('File Browser'), '');
|
||||
|
||||
s = m.section(form.NamedSection, 'files', 'files');
|
||||
|
||||
o = s.option(form.FileUpload, 'root', '');
|
||||
o.root_directory = '/';
|
||||
o.browser = true;
|
||||
o.show_hidden = true;
|
||||
o.enable_upload = true;
|
||||
o.enable_remove = true;
|
||||
o.enable_download = true;
|
||||
|
||||
return m.render();
|
||||
},
|
||||
|
||||
handleSave: null,
|
||||
handleSaveApply: null,
|
||||
handleReset: null
|
||||
})
|
||||
@@ -1,51 +1,11 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:62
|
||||
msgid "Collecting data..."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:81
|
||||
msgid "Disable Command Runner feature"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:68
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:48
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js:16
|
||||
#: applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json:3
|
||||
msgid "FileBrowser"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:49
|
||||
msgid ""
|
||||
"FileBrowser provides a file managing interface within a specified directory "
|
||||
"and it can be used to upload, delete, preview, rename and edit your files.."
|
||||
msgid "File Browser"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json:3
|
||||
msgid "Grant UCI access for luci-app-filebrowser"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:72
|
||||
msgid "Listen port"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33
|
||||
msgid "NOT RUNNING"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:30
|
||||
msgid "Open Web Interface"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31
|
||||
msgid "RUNNING"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:77
|
||||
msgid "Root directory"
|
||||
msgid "Grant access to File Browser"
|
||||
msgstr ""
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
zh_Hans
|
||||
@@ -1,60 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh-Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:62
|
||||
msgid "Collecting data..."
|
||||
msgstr "收集数据中..."
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:81
|
||||
msgid "Disable Command Runner feature"
|
||||
msgstr "禁用命令执行功能"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:68
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:48
|
||||
#: applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json:3
|
||||
msgid "FileBrowser"
|
||||
msgstr "FileBrowser"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:49
|
||||
msgid ""
|
||||
"FileBrowser provides a file managing interface within a specified directory "
|
||||
"and it can be used to upload, delete, preview, rename and edit your files.."
|
||||
msgstr ""
|
||||
"FileBrowser 提供指定目录下的文件管理界面,可用于上传、删除、预览、重命名和编"
|
||||
"辑文件。"
|
||||
|
||||
#: applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json:3
|
||||
msgid "Grant UCI access for luci-app-filebrowser"
|
||||
msgstr "授予 luci-app-filebrowser 访问 UCI 配置的权限"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:72
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:30
|
||||
msgid "Open Web Interface"
|
||||
msgstr "打开 Web 界面"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:77
|
||||
msgid "Root directory"
|
||||
msgstr "根目录"
|
||||
+5
-6
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"admin/services/filebrowser": {
|
||||
"title": "FileBrowser",
|
||||
"admin/system/filebrowser": {
|
||||
"title": "File Browser",
|
||||
"order": 80,
|
||||
"action": {
|
||||
"order": 30,
|
||||
"type": "view",
|
||||
"path": "filebrowser"
|
||||
"path": "system/filebrowser"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-filebrowser" ],
|
||||
"uci": { "filebrowser": true }
|
||||
"acl": [ "luci-app-filebrowser" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"luci-app-filebrowser": {
|
||||
"description": "Grant UCI access for luci-app-filebrowser",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"service": [ "list" ]
|
||||
},
|
||||
"uci": [ "filebrowser" ]
|
||||
},
|
||||
"description": "Grant access to File Browser",
|
||||
"write": {
|
||||
"uci": [ "filebrowser" ]
|
||||
"cgi-io": [ "upload", "download" ],
|
||||
"ubus": {
|
||||
"file": [ "*" ]
|
||||
},
|
||||
"file": {
|
||||
"/*": [ "list", "read", "write" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Common.Memory
|
||||
{
|
||||
/// <summary>
|
||||
/// A struct that can represent both a Span and Array.
|
||||
/// This is useful to keep the Array representation when possible to avoid copies.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Element Type</typeparam>
|
||||
public readonly ref struct SpanOrArray<T> where T : unmanaged
|
||||
{
|
||||
public readonly T[] Array;
|
||||
public readonly ReadOnlySpan<T> Span;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new SpanOrArray from an array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to store</param>
|
||||
public SpanOrArray(T[] array)
|
||||
{
|
||||
Array = array;
|
||||
Span = ReadOnlySpan<T>.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new SpanOrArray from a readonly span.
|
||||
/// </summary>
|
||||
/// <param name="array">Span to store</param>
|
||||
public SpanOrArray(ReadOnlySpan<T> span)
|
||||
{
|
||||
Array = null;
|
||||
Span = span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the contained array, or convert the span if necessary.
|
||||
/// </summary>
|
||||
/// <returns>An array containing the data</returns>
|
||||
public T[] ToArray()
|
||||
{
|
||||
return Array ?? Span.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a ReadOnlySpan from either the array or ReadOnlySpan.
|
||||
/// </summary>
|
||||
/// <returns>A ReadOnlySpan containing the data</returns>
|
||||
public ReadOnlySpan<T> AsSpan()
|
||||
{
|
||||
return Array ?? Span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cast an array to a SpanOrArray.
|
||||
/// </summary>
|
||||
/// <param name="array">Source array</param>
|
||||
public static implicit operator SpanOrArray<T>(T[] array)
|
||||
{
|
||||
return new SpanOrArray<T>(array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cast a ReadOnlySpan to a SpanOrArray.
|
||||
/// </summary>
|
||||
/// <param name="span">Source ReadOnlySpan</param>
|
||||
public static implicit operator SpanOrArray<T>(ReadOnlySpan<T> span)
|
||||
{
|
||||
return new SpanOrArray<T>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cast a Span to a SpanOrArray.
|
||||
/// </summary>
|
||||
/// <param name="span">Source Span</param>
|
||||
public static implicit operator SpanOrArray<T>(Span<T> span)
|
||||
{
|
||||
return new SpanOrArray<T>(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cast a SpanOrArray to a ReadOnlySpan
|
||||
/// </summary>
|
||||
/// <param name="spanOrArray">Source SpanOrArray</param>
|
||||
public static implicit operator ReadOnlySpan<T>(SpanOrArray<T> spanOrArray)
|
||||
{
|
||||
return spanOrArray.AsSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -41,6 +42,22 @@ namespace Ryujinx.Common
|
||||
return StreamUtils.StreamToBytes(stream);
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ReadFileToRentedMemory(string filename)
|
||||
{
|
||||
var (assembly, path) = ResolveManifestPath(filename);
|
||||
|
||||
return ReadFileToRentedMemory(assembly, path);
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ReadFileToRentedMemory(Assembly assembly, string filename)
|
||||
{
|
||||
using var stream = GetStream(assembly, filename);
|
||||
|
||||
return stream is null
|
||||
? null
|
||||
: StreamUtils.StreamToRentedMemory(stream);
|
||||
}
|
||||
|
||||
public async static Task<byte[]> ReadAsync(Assembly assembly, string filename)
|
||||
{
|
||||
using var stream = GetStream(assembly, filename);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.IO;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,12 +11,50 @@ namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
public static byte[] StreamToBytes(Stream input)
|
||||
{
|
||||
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
|
||||
using RecyclableMemoryStream output = StreamToRecyclableMemoryStream(input);
|
||||
|
||||
return output.ToArray();
|
||||
}
|
||||
|
||||
input.CopyTo(stream);
|
||||
public static IMemoryOwner<byte> StreamToRentedMemory(Stream input)
|
||||
{
|
||||
if (input is MemoryStream inputMemoryStream)
|
||||
{
|
||||
return MemoryStreamToRentedMemory(inputMemoryStream);
|
||||
}
|
||||
else if (input.CanSeek)
|
||||
{
|
||||
long bytesExpected = input.Length;
|
||||
|
||||
return stream.ToArray();
|
||||
IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(bytesExpected);
|
||||
|
||||
var destSpan = ownedMemory.Memory.Span;
|
||||
|
||||
int totalBytesRead = 0;
|
||||
|
||||
while (totalBytesRead < bytesExpected)
|
||||
{
|
||||
int bytesRead = input.Read(destSpan[totalBytesRead..]);
|
||||
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
ownedMemory.Dispose();
|
||||
|
||||
throw new IOException($"Tried reading {bytesExpected} but the stream closed after reading {totalBytesRead}.");
|
||||
}
|
||||
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
|
||||
return ownedMemory;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If input is (non-seekable) then copy twice: first into a RecyclableMemoryStream, then to a rented IMemoryOwner<byte>.
|
||||
using RecyclableMemoryStream output = StreamToRecyclableMemoryStream(input);
|
||||
|
||||
return MemoryStreamToRentedMemory(output);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<byte[]> StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default)
|
||||
@@ -25,5 +65,26 @@ namespace Ryujinx.Common.Utilities
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
|
||||
private static IMemoryOwner<byte> MemoryStreamToRentedMemory(MemoryStream input)
|
||||
{
|
||||
input.Position = 0;
|
||||
|
||||
IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(input.Length);
|
||||
|
||||
// Discard the return value because we assume reading a MemoryStream always succeeds completely.
|
||||
_ = input.Read(ownedMemory.Memory.Span);
|
||||
|
||||
return ownedMemory;
|
||||
}
|
||||
|
||||
private static RecyclableMemoryStream StreamToRecyclableMemoryStream(Stream input)
|
||||
{
|
||||
RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream();
|
||||
|
||||
input.CopyTo(stream);
|
||||
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -143,11 +145,11 @@ namespace Ryujinx.Graphics.Device
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory<byte> memory = new byte[size];
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size);
|
||||
|
||||
GetSpan(va, size).CopyTo(memory.Span);
|
||||
GetSpan(va, size).CopyTo(memoryOwner.Memory.Span);
|
||||
|
||||
return new WritableRegion(this, va, memory, tracked: true);
|
||||
return new WritableRegion(this, va, memoryOwner, tracked: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
@@ -17,10 +17,34 @@ namespace Ryujinx.Graphics.GAL
|
||||
PinnedSpan<byte> GetData();
|
||||
PinnedSpan<byte> GetData(int layer, int level);
|
||||
|
||||
void SetData(SpanOrArray<byte> data);
|
||||
void SetData(SpanOrArray<byte> data, int layer, int level);
|
||||
void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region);
|
||||
/// <summary>
|
||||
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
|
||||
/// the operation completes.
|
||||
/// </summary>
|
||||
/// <param name="data">Texture data bytes</param>
|
||||
void SetData(IMemoryOwner<byte> data);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
|
||||
/// the operation completes.
|
||||
/// </summary>
|
||||
/// <param name="data">Texture data bytes</param>
|
||||
/// <param name="layer">Target layer</param>
|
||||
/// <param name="level">Target level</param>
|
||||
void SetData(IMemoryOwner<byte> data, int layer, int level);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when
|
||||
/// the operation completes.
|
||||
/// </summary>
|
||||
/// <param name="data">Texture data bytes</param>
|
||||
/// <param name="layer">Target layer</param>
|
||||
/// <param name="level">Target level</param>
|
||||
/// <param name="region">Target sub-region of the texture to update</param>
|
||||
void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region);
|
||||
|
||||
void SetStorage(BufferRange buffer);
|
||||
|
||||
void Release();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
@@ -8,9 +8,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
public readonly CommandType CommandType => CommandType.TextureSetData;
|
||||
private TableRef<ThreadedTexture> _texture;
|
||||
private TableRef<byte[]> _data;
|
||||
private TableRef<IMemoryOwner<byte>> _data;
|
||||
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<byte[]> data)
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data)
|
||||
{
|
||||
_texture = texture;
|
||||
_data = data;
|
||||
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
public static void Run(ref TextureSetDataCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ThreadedTexture texture = command._texture.Get(threaded);
|
||||
texture.Base.SetData(new ReadOnlySpan<byte>(command._data.Get(threaded)));
|
||||
texture.Base.SetData(command._data.Get(threaded));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
@@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
public readonly CommandType CommandType => CommandType.TextureSetDataSlice;
|
||||
private TableRef<ThreadedTexture> _texture;
|
||||
private TableRef<byte[]> _data;
|
||||
private TableRef<IMemoryOwner<byte>> _data;
|
||||
private int _layer;
|
||||
private int _level;
|
||||
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<byte[]> data, int layer, int level)
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level)
|
||||
{
|
||||
_texture = texture;
|
||||
_data = data;
|
||||
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
public static void Run(ref TextureSetDataSliceCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ThreadedTexture texture = command._texture.Get(threaded);
|
||||
texture.Base.SetData(new ReadOnlySpan<byte>(command._data.Get(threaded)), command._layer, command._level);
|
||||
texture.Base.SetData(command._data.Get(threaded), command._layer, command._level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
@@ -8,12 +8,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
{
|
||||
public readonly CommandType CommandType => CommandType.TextureSetDataSliceRegion;
|
||||
private TableRef<ThreadedTexture> _texture;
|
||||
private TableRef<byte[]> _data;
|
||||
private TableRef<IMemoryOwner<byte>> _data;
|
||||
private int _layer;
|
||||
private int _level;
|
||||
private Rectangle<int> _region;
|
||||
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<byte[]> data, int layer, int level, Rectangle<int> region)
|
||||
public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
_texture = texture;
|
||||
_data = data;
|
||||
@@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
|
||||
public static void Run(ref TextureSetDataSliceRegionCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ThreadedTexture texture = command._texture.Get(threaded);
|
||||
texture.Base.SetData(new ReadOnlySpan<byte>(command._data.Get(threaded)), command._layer, command._level, command._region);
|
||||
texture.Base.SetData(command._data.Get(threaded), command._layer, command._level, command._region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Texture;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Resources
|
||||
{
|
||||
@@ -110,21 +110,24 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
|
||||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
_renderer.New<TextureSetDataCommand>().Set(Ref(this), Ref(data.ToArray()));
|
||||
_renderer.New<TextureSetDataCommand>().Set(Ref(this), Ref(data));
|
||||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
_renderer.New<TextureSetDataSliceCommand>().Set(Ref(this), Ref(data.ToArray()), layer, level);
|
||||
_renderer.New<TextureSetDataSliceCommand>().Set(Ref(this), Ref(data), layer, level);
|
||||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
_renderer.New<TextureSetDataSliceRegionCommand>().Set(Ref(this), Ref(data.ToArray()), layer, level, region);
|
||||
_renderer.New<TextureSetDataSliceRegionCommand>().Set(Ref(this), Ref(data), layer, level, region);
|
||||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Ryujinx.Graphics.Gpu.Engine.Threed;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -308,7 +309,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
byte[] data;
|
||||
IMemoryOwner<byte> data;
|
||||
if (srcLinear)
|
||||
{
|
||||
data = LayoutConverter.ConvertLinearStridedToLinear(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using System;
|
||||
@@ -198,7 +199,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
|
||||
if (target != null)
|
||||
{
|
||||
target.SynchronizeMemory();
|
||||
target.SetData(data, 0, 0, new GAL.Rectangle<int>(_dstX, _dstY, _lineLengthIn / target.Info.FormatInfo.BytesPerPixel, _lineCount));
|
||||
var dataCopy = ByteMemoryPool.RentCopy(data);
|
||||
target.SetData(dataCopy, 0, 0, new GAL.Rectangle<int>(_dstX, _dstY, _lineLengthIn / target.Info.FormatInfo.BytesPerPixel, _lineCount));
|
||||
target.SignalModified();
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
@@ -7,6 +6,7 @@ using Ryujinx.Graphics.Texture.Astc;
|
||||
using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
@@ -661,7 +661,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
}
|
||||
}
|
||||
|
||||
SpanOrArray<byte> result = ConvertToHostCompatibleFormat(data);
|
||||
IMemoryOwner<byte> result = ConvertToHostCompatibleFormat(data);
|
||||
|
||||
if (ScaleFactor != 1f && AllowScaledSetData())
|
||||
{
|
||||
@@ -684,7 +684,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// Uploads new texture data to the host GPU.
|
||||
/// </summary>
|
||||
/// <param name="data">New data</param>
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
BlacklistScale();
|
||||
|
||||
@@ -703,7 +703,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <param name="data">New data</param>
|
||||
/// <param name="layer">Target layer</param>
|
||||
/// <param name="level">Target level</param>
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
BlacklistScale();
|
||||
|
||||
@@ -721,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <param name="layer">Target layer</param>
|
||||
/// <param name="level">Target level</param>
|
||||
/// <param name="region">Target sub-region of the texture to update</param>
|
||||
public void SetData(ReadOnlySpan<byte> data, int layer, int level, Rectangle<int> region)
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
BlacklistScale();
|
||||
|
||||
@@ -739,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <param name="level">Mip level to convert</param>
|
||||
/// <param name="single">True to convert a single slice</param>
|
||||
/// <returns>Converted data</returns>
|
||||
public SpanOrArray<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false)
|
||||
public IMemoryOwner<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false)
|
||||
{
|
||||
int width = Info.Width;
|
||||
int height = Info.Height;
|
||||
@@ -754,11 +754,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
int sliceDepth = single ? 1 : depth;
|
||||
|
||||
SpanOrArray<byte> result;
|
||||
IMemoryOwner<byte> linear;
|
||||
|
||||
if (Info.IsLinear)
|
||||
{
|
||||
result = LayoutConverter.ConvertLinearStridedToLinear(
|
||||
linear = LayoutConverter.ConvertLinearStridedToLinear(
|
||||
width,
|
||||
height,
|
||||
Info.FormatInfo.BlockWidth,
|
||||
@@ -770,7 +770,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
}
|
||||
else
|
||||
{
|
||||
result = LayoutConverter.ConvertBlockLinearToLinear(
|
||||
linear = LayoutConverter.ConvertBlockLinearToLinear(
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
@@ -787,33 +787,41 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
data);
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> result = linear;
|
||||
|
||||
// Handle compressed cases not supported by the host:
|
||||
// - ASTC is usually not supported on desktop cards.
|
||||
// - BC4/BC5 is not supported on 3D textures.
|
||||
if (!_context.Capabilities.SupportsAstcCompression && Format.IsAstc())
|
||||
{
|
||||
if (!AstcDecoder.TryDecodeToRgba8P(
|
||||
result.ToArray(),
|
||||
Info.FormatInfo.BlockWidth,
|
||||
Info.FormatInfo.BlockHeight,
|
||||
width,
|
||||
height,
|
||||
sliceDepth,
|
||||
levels,
|
||||
layers,
|
||||
out byte[] decoded))
|
||||
using (result)
|
||||
{
|
||||
string texInfo = $"{Info.Target} {Info.FormatInfo.Format} {Info.Width}x{Info.Height}x{Info.DepthOrLayers} levels {Info.Levels}";
|
||||
if (!AstcDecoder.TryDecodeToRgba8P(
|
||||
result.Memory,
|
||||
Info.FormatInfo.BlockWidth,
|
||||
Info.FormatInfo.BlockHeight,
|
||||
width,
|
||||
height,
|
||||
sliceDepth,
|
||||
levels,
|
||||
layers,
|
||||
out IMemoryOwner<byte> decoded))
|
||||
{
|
||||
string texInfo = $"{Info.Target} {Info.FormatInfo.Format} {Info.Width}x{Info.Height}x{Info.DepthOrLayers} levels {Info.Levels}";
|
||||
|
||||
Logger.Debug?.Print(LogClass.Gpu, $"Invalid ASTC texture at 0x{Info.GpuAddress:X} ({texInfo}).");
|
||||
Logger.Debug?.Print(LogClass.Gpu, $"Invalid ASTC texture at 0x{Info.GpuAddress:X} ({texInfo}).");
|
||||
}
|
||||
|
||||
if (GraphicsConfig.EnableTextureRecompression)
|
||||
{
|
||||
using (decoded)
|
||||
{
|
||||
return BCnEncoder.EncodeBC7(decoded.Memory, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
if (GraphicsConfig.EnableTextureRecompression)
|
||||
{
|
||||
decoded = BCnEncoder.EncodeBC7(decoded, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
|
||||
result = decoded;
|
||||
}
|
||||
else if (!_context.Capabilities.SupportsEtc2Compression && Format.IsEtc2())
|
||||
{
|
||||
@@ -821,16 +829,22 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
case Format.Etc2RgbaSrgb:
|
||||
case Format.Etc2RgbaUnorm:
|
||||
result = ETC2Decoder.DecodeRgba(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return ETC2Decoder.DecodeRgba(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
case Format.Etc2RgbPtaSrgb:
|
||||
case Format.Etc2RgbPtaUnorm:
|
||||
result = ETC2Decoder.DecodePta(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return ETC2Decoder.DecodePta(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
case Format.Etc2RgbSrgb:
|
||||
case Format.Etc2RgbUnorm:
|
||||
result = ETC2Decoder.DecodeRgb(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return ETC2Decoder.DecodeRgb(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!TextureCompatibility.HostSupportsBcFormat(Format, Target, _context.Capabilities))
|
||||
@@ -839,48 +853,75 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
case Format.Bc1RgbaSrgb:
|
||||
case Format.Bc1RgbaUnorm:
|
||||
result = BCnDecoder.DecodeBC1(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC1(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
case Format.Bc2Srgb:
|
||||
case Format.Bc2Unorm:
|
||||
result = BCnDecoder.DecodeBC2(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC2(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
case Format.Bc3Srgb:
|
||||
case Format.Bc3Unorm:
|
||||
result = BCnDecoder.DecodeBC3(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC3(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
case Format.Bc4Snorm:
|
||||
case Format.Bc4Unorm:
|
||||
result = BCnDecoder.DecodeBC4(result, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC4(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm);
|
||||
}
|
||||
case Format.Bc5Snorm:
|
||||
case Format.Bc5Unorm:
|
||||
result = BCnDecoder.DecodeBC5(result, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC5(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm);
|
||||
}
|
||||
case Format.Bc6HSfloat:
|
||||
case Format.Bc6HUfloat:
|
||||
result = BCnDecoder.DecodeBC6(result, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC6(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat);
|
||||
}
|
||||
case Format.Bc7Srgb:
|
||||
case Format.Bc7Unorm:
|
||||
result = BCnDecoder.DecodeBC7(result, width, height, sliceDepth, levels, layers);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return BCnDecoder.DecodeBC7(result.Memory.Span, width, height, sliceDepth, levels, layers);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!_context.Capabilities.SupportsR4G4Format && Format == Format.R4G4Unorm)
|
||||
{
|
||||
result = PixelConverter.ConvertR4G4ToR4G4B4A4(result, width);
|
||||
|
||||
if (!_context.Capabilities.SupportsR4G4B4A4Format)
|
||||
using (result)
|
||||
{
|
||||
result = PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result, width);
|
||||
var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Memory.Span, width);
|
||||
|
||||
if (_context.Capabilities.SupportsR4G4B4A4Format)
|
||||
{
|
||||
return converted;
|
||||
}
|
||||
else
|
||||
{
|
||||
using (converted)
|
||||
{
|
||||
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(converted.Memory.Span, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Format == Format.R4G4B4A4Unorm)
|
||||
{
|
||||
if (!_context.Capabilities.SupportsR4G4B4A4Format)
|
||||
{
|
||||
result = PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result, width);
|
||||
using (result)
|
||||
{
|
||||
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!_context.Capabilities.Supports5BitComponentFormat && Format.Is16BitPacked())
|
||||
@@ -889,19 +930,27 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
case Format.B5G6R5Unorm:
|
||||
case Format.R5G6B5Unorm:
|
||||
result = PixelConverter.ConvertR5G6B5ToR8G8B8A8(result, width);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return PixelConverter.ConvertR5G6B5ToR8G8B8A8(result.Memory.Span, width);
|
||||
}
|
||||
case Format.B5G5R5A1Unorm:
|
||||
case Format.R5G5B5X1Unorm:
|
||||
case Format.R5G5B5A1Unorm:
|
||||
result = PixelConverter.ConvertR5G5B5ToR8G8B8A8(result, width, Format == Format.R5G5B5X1Unorm);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return PixelConverter.ConvertR5G5B5ToR8G8B8A8(result.Memory.Span, width, Format == Format.R5G5B5X1Unorm);
|
||||
}
|
||||
case Format.A1B5G5R5Unorm:
|
||||
result = PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result, width);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result.Memory.Span, width);
|
||||
}
|
||||
case Format.R4G4B4A4Unorm:
|
||||
result = PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result, width);
|
||||
break;
|
||||
using (result)
|
||||
{
|
||||
return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
@@ -6,6 +5,7 @@ using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using Ryujinx.Memory.Tracking;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..];
|
||||
|
||||
SpanOrArray<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
|
||||
IMemoryOwner<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
|
||||
|
||||
Storage.SetData(result, info.BaseLayer + layer, info.BaseLevel + level);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -240,11 +242,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory<byte> memory = new byte[size];
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size);
|
||||
|
||||
GetSpan(va, size).CopyTo(memory.Span);
|
||||
GetSpan(va, size).CopyTo(memoryOwner.Memory.Span);
|
||||
|
||||
return new WritableRegion(this, va, memory, tracked);
|
||||
return new WritableRegion(this, va, memoryOwner, tracked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Gpu.Image;
|
||||
@@ -6,6 +7,7 @@ using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using Ryujinx.Memory.Tracking;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -190,7 +192,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory<byte> memory = new byte[range.GetSize()];
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(range.GetSize());
|
||||
|
||||
Memory<byte> memory = memoryOwner.Memory;
|
||||
|
||||
int offset = 0;
|
||||
for (int i = 0; i < range.Count; i++)
|
||||
@@ -204,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
offset += size;
|
||||
}
|
||||
|
||||
return new WritableRegion(new MultiRangeWritableBlock(range, this), 0, memory, tracked);
|
||||
return new WritableRegion(new MultiRangeWritableBlock(range, this), 0, memoryOwner, tracked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
|
||||
|
||||
public int Quality
|
||||
{
|
||||
get => _quality; set
|
||||
get => _quality;
|
||||
set
|
||||
{
|
||||
_quality = Math.Clamp(value, 0, _qualities.Length - 1);
|
||||
}
|
||||
@@ -150,8 +151,8 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
|
||||
_areaTexture = new TextureStorage(_renderer, areaInfo);
|
||||
_searchTexture = new TextureStorage(_renderer, searchInfo);
|
||||
|
||||
var areaTexture = EmbeddedResources.Read("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaAreaTexture.bin");
|
||||
var searchTexture = EmbeddedResources.Read("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaSearchTexture.bin");
|
||||
var areaTexture = EmbeddedResources.ReadFileToRentedMemory("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaAreaTexture.bin");
|
||||
var searchTexture = EmbeddedResources.ReadFileToRentedMemory("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaSearchTexture.bin");
|
||||
|
||||
var areaView = _areaTexture.CreateDefaultView();
|
||||
var searchView = _searchTexture.CreateDefaultView();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
@@ -8,9 +10,11 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
{
|
||||
static class FormatConverter
|
||||
{
|
||||
public unsafe static byte[] ConvertS8D24ToD24S8(ReadOnlySpan<byte> data)
|
||||
public unsafe static IMemoryOwner<byte> ConvertS8D24ToD24S8(ReadOnlySpan<byte> data)
|
||||
{
|
||||
byte[] output = new byte[data.Length];
|
||||
IMemoryOwner<byte> outputMemory = ByteMemoryPool.Rent(data.Length);
|
||||
|
||||
Span<byte> output = outputMemory.Memory.Span;
|
||||
|
||||
int start = 0;
|
||||
|
||||
@@ -74,7 +78,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
outSpan[i] = BitOperations.RotateLeft(dataSpan[i], 8);
|
||||
}
|
||||
|
||||
return output;
|
||||
return outputMemory;
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertD24S8ToS8D24(ReadOnlySpan<byte> data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL.Image
|
||||
{
|
||||
@@ -54,19 +54,24 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
var dataSpan = data.AsSpan();
|
||||
var dataSpan = data.Memory.Span;
|
||||
|
||||
Buffer.SetData(_buffer, _bufferOffset, dataSpan[..Math.Min(dataSpan.Length, _bufferSize)]);
|
||||
|
||||
data.Dispose();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL.Image
|
||||
@@ -448,70 +448,59 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
var dataSpan = data.AsSpan();
|
||||
|
||||
if (Format == Format.S8UintD24Unorm)
|
||||
using (data = EnsureDataFormat(data))
|
||||
{
|
||||
dataSpan = FormatConverter.ConvertS8D24ToD24S8(dataSpan);
|
||||
}
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* ptr = dataSpan)
|
||||
unsafe
|
||||
{
|
||||
ReadFrom((IntPtr)ptr, dataSpan.Length);
|
||||
var dataSpan = data.Memory.Span;
|
||||
fixed (byte* ptr = dataSpan)
|
||||
{
|
||||
ReadFrom((IntPtr)ptr, dataSpan.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
var dataSpan = data.AsSpan();
|
||||
|
||||
if (Format == Format.S8UintD24Unorm)
|
||||
using (data = EnsureDataFormat(data))
|
||||
{
|
||||
dataSpan = FormatConverter.ConvertS8D24ToD24S8(dataSpan);
|
||||
}
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* ptr = dataSpan)
|
||||
unsafe
|
||||
{
|
||||
int width = Math.Max(Info.Width >> level, 1);
|
||||
int height = Math.Max(Info.Height >> level, 1);
|
||||
fixed (byte* ptr = data.Memory.Span)
|
||||
{
|
||||
int width = Math.Max(Info.Width >> level, 1);
|
||||
int height = Math.Max(Info.Height >> level, 1);
|
||||
|
||||
ReadFrom2D((IntPtr)ptr, layer, level, 0, 0, width, height);
|
||||
ReadFrom2D((IntPtr)ptr, layer, level, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
var dataSpan = data.AsSpan();
|
||||
|
||||
if (Format == Format.S8UintD24Unorm)
|
||||
using (data = EnsureDataFormat(data))
|
||||
{
|
||||
dataSpan = FormatConverter.ConvertS8D24ToD24S8(dataSpan);
|
||||
}
|
||||
int wInBlocks = BitUtils.DivRoundUp(region.Width, Info.BlockWidth);
|
||||
int hInBlocks = BitUtils.DivRoundUp(region.Height, Info.BlockHeight);
|
||||
|
||||
int wInBlocks = BitUtils.DivRoundUp(region.Width, Info.BlockWidth);
|
||||
int hInBlocks = BitUtils.DivRoundUp(region.Height, Info.BlockHeight);
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* ptr = dataSpan)
|
||||
unsafe
|
||||
{
|
||||
ReadFrom2D(
|
||||
(IntPtr)ptr,
|
||||
layer,
|
||||
level,
|
||||
region.X,
|
||||
region.Y,
|
||||
region.Width,
|
||||
region.Height,
|
||||
BitUtils.AlignUp(wInBlocks * Info.BytesPerPixel, 4) * hInBlocks);
|
||||
fixed (byte* ptr = data.Memory.Span)
|
||||
{
|
||||
ReadFrom2D(
|
||||
(IntPtr)ptr,
|
||||
layer,
|
||||
level,
|
||||
region.X,
|
||||
region.Y,
|
||||
region.Width,
|
||||
region.Height,
|
||||
BitUtils.AlignUp(wInBlocks * Info.BytesPerPixel, 4) * hInBlocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,6 +522,19 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
ReadFrom2D(data, layer, level, x, y, width, height, mipSize);
|
||||
}
|
||||
|
||||
private IMemoryOwner<byte> EnsureDataFormat(IMemoryOwner<byte> data)
|
||||
{
|
||||
if (Format == Format.S8UintD24Unorm)
|
||||
{
|
||||
using (data)
|
||||
{
|
||||
return FormatConverter.ConvertS8D24ToD24S8(data.Memory.Span);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private void ReadFrom2D(IntPtr data, int layer, int level, int x, int y, int width, int height, int mipSize)
|
||||
{
|
||||
TextureTarget target = Target.Convert();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -291,16 +293,14 @@ namespace Ryujinx.Graphics.Texture.Astc
|
||||
int depth,
|
||||
int levels,
|
||||
int layers,
|
||||
out byte[] decoded)
|
||||
out IMemoryOwner<byte> decoded)
|
||||
{
|
||||
byte[] output = new byte[QueryDecompressedSize(width, height, depth, levels, layers)];
|
||||
decoded = ByteMemoryPool.Rent(QueryDecompressedSize(width, height, depth, levels, layers));
|
||||
|
||||
AstcDecoder decoder = new(data, output, blockWidth, blockHeight, width, height, depth, levels, layers);
|
||||
AstcDecoder decoder = new(data, decoded.Memory, blockWidth, blockHeight, width, height, depth, levels, layers);
|
||||
|
||||
Enumerable.Range(0, decoder.TotalBlockCount).AsParallel().ForAll(x => decoder.ProcessBlock(x));
|
||||
|
||||
decoded = output;
|
||||
|
||||
return decoder.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
@@ -12,7 +14,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
private const int BlockWidth = 4;
|
||||
private const int BlockHeight = 4;
|
||||
|
||||
public static byte[] DecodeBC1(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeBC1(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -21,12 +23,12 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@@ -100,7 +102,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC2(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeBC2(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -109,12 +111,12 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@@ -195,7 +197,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC3(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeBC3(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -204,13 +206,13 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
Span<byte> rPal = stackalloc byte[8];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@@ -292,7 +294,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC4(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static IMemoryOwner<byte> DecodeBC4(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -304,8 +306,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
// Backends currently expect a stride alignment of 4 bytes, so output width must be aligned.
|
||||
int alignedWidth = BitUtils.AlignUp(width, 4);
|
||||
|
||||
byte[] output = new byte[size];
|
||||
Span<byte> outputSpan = new(output);
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
|
||||
ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
@@ -400,7 +402,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC5(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static IMemoryOwner<byte> DecodeBC5(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -412,7 +414,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
// Backends currently expect a stride alignment of 4 bytes, so output width must be aligned.
|
||||
int alignedWidth = BitUtils.AlignUp(width, 2);
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
|
||||
ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
@@ -421,7 +423,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
Span<byte> rPal = stackalloc byte[8];
|
||||
Span<byte> gPal = stackalloc byte[8];
|
||||
|
||||
Span<ushort> outputAsUshort = MemoryMarshal.Cast<byte, ushort>(output);
|
||||
Span<ushort> outputAsUshort = MemoryMarshal.Cast<byte, ushort>(output.Memory.Span);
|
||||
|
||||
Span<uint> rTileAsUint = MemoryMarshal.Cast<byte, uint>(rTile);
|
||||
Span<uint> gTileAsUint = MemoryMarshal.Cast<byte, uint>(gTile);
|
||||
@@ -525,7 +527,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC6(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static IMemoryOwner<byte> DecodeBC6(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -534,7 +536,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 8;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
|
||||
int inputOffset = 0;
|
||||
int outputOffset = 0;
|
||||
@@ -548,7 +551,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
for (int z = 0; z < depth; z++)
|
||||
{
|
||||
BC6Decoder.Decode(output.AsSpan()[outputOffset..], data[inputOffset..], width, height, signed);
|
||||
BC6Decoder.Decode(outputSpan[outputOffset..], data[inputOffset..], width, height, signed);
|
||||
|
||||
inputOffset += w * h * 16;
|
||||
outputOffset += width * height * 8;
|
||||
@@ -563,7 +566,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC7(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeBC7(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -572,7 +575,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
|
||||
int inputOffset = 0;
|
||||
int outputOffset = 0;
|
||||
@@ -586,7 +590,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
for (int z = 0; z < depth; z++)
|
||||
{
|
||||
BC7Decoder.Decode(output.AsSpan()[outputOffset..], data[inputOffset..], width, height);
|
||||
BC7Decoder.Decode(outputSpan[outputOffset..], data[inputOffset..], width, height);
|
||||
|
||||
inputOffset += w * h * 16;
|
||||
outputOffset += width * height * 4;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.Texture.Encoders;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
@@ -9,7 +11,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
private const int BlockWidth = 4;
|
||||
private const int BlockHeight = 4;
|
||||
|
||||
public static byte[] EncodeBC7(byte[] data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> EncodeBC7(Memory<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@@ -21,7 +23,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += w * h * 16 * Math.Max(1, depth >> l) * layers;
|
||||
}
|
||||
|
||||
byte[] output = new byte[size];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Memory<byte> outputMemory = output.Memory;
|
||||
|
||||
int imageBaseIOffs = 0;
|
||||
int imageBaseOOffs = 0;
|
||||
@@ -36,8 +39,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
for (int z = 0; z < depth; z++)
|
||||
{
|
||||
BC7Encoder.Encode(
|
||||
output.AsMemory()[imageBaseOOffs..],
|
||||
data.AsMemory()[imageBaseIOffs..],
|
||||
outputMemory[imageBaseOOffs..],
|
||||
data[imageBaseIOffs..],
|
||||
width,
|
||||
height,
|
||||
EncodeMode.Fast | EncodeMode.Multithreaded);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -49,15 +51,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
new int[] { -3, -5, -7, -9, 2, 4, 6, 8 },
|
||||
};
|
||||
|
||||
public static byte[] DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
byte[] output = new byte[CalculateOutputSize(width, height, depth, levels, layers)];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
@@ -111,15 +113,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
byte[] output = new byte[CalculateOutputSize(width, height, depth, levels, layers)];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
@@ -168,15 +170,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static IMemoryOwner<byte> DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
byte[] output = new byte[CalculateOutputSize(width, height, depth, levels, layers)];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.Intrinsics;
|
||||
using static Ryujinx.Graphics.Texture.BlockLinearConstants;
|
||||
|
||||
@@ -93,7 +95,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
};
|
||||
}
|
||||
|
||||
public static byte[] ConvertBlockLinearToLinear(
|
||||
public static IMemoryOwner<byte> ConvertBlockLinearToLinear(
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
@@ -119,7 +121,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
blockHeight,
|
||||
bytesPerPixel);
|
||||
|
||||
byte[] output = new byte[outSize];
|
||||
IMemoryOwner<byte> outputOwner = ByteMemoryPool.Rent(outSize);
|
||||
Span<byte> output = outputOwner.Memory.Span;
|
||||
|
||||
int outOffs = 0;
|
||||
|
||||
@@ -243,10 +246,10 @@ namespace Ryujinx.Graphics.Texture
|
||||
_ => throw new NotSupportedException($"Unable to convert ${bytesPerPixel} bpp pixel format."),
|
||||
};
|
||||
}
|
||||
return output;
|
||||
return outputOwner;
|
||||
}
|
||||
|
||||
public static byte[] ConvertLinearStridedToLinear(
|
||||
public static IMemoryOwner<byte> ConvertLinearStridedToLinear(
|
||||
int width,
|
||||
int height,
|
||||
int blockWidth,
|
||||
@@ -262,8 +265,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
int outStride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment);
|
||||
lineSize = Math.Min(lineSize, outStride);
|
||||
|
||||
byte[] output = new byte[h * outStride];
|
||||
Span<byte> outSpan = output;
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(h * outStride);
|
||||
Span<byte> outSpan = output.Memory.Span;
|
||||
|
||||
int outOffs = 0;
|
||||
int inOffs = 0;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
@@ -19,13 +21,13 @@ namespace Ryujinx.Graphics.Texture
|
||||
return (remainder, outRemainder, length / stride);
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertR4G4ToR4G4B4A4(ReadOnlySpan<byte> data, int width)
|
||||
public unsafe static IMemoryOwner<byte> ConvertR4G4ToR4G4B4A4(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
byte[] output = new byte[data.Length * 2];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 1, 2);
|
||||
|
||||
Span<ushort> outputSpan = MemoryMarshal.Cast<byte, ushort>(output);
|
||||
Span<ushort> outputSpan = MemoryMarshal.Cast<byte, ushort>(output.Memory.Span);
|
||||
|
||||
if (remainder == 0)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
int sizeTrunc = data.Length & ~7;
|
||||
start = sizeTrunc;
|
||||
|
||||
fixed (byte* inputPtr = data, outputPtr = output)
|
||||
fixed (byte* inputPtr = data, outputPtr = output.Memory.Span)
|
||||
{
|
||||
for (ulong offset = 0; offset < (ulong)sizeTrunc; offset += 8)
|
||||
{
|
||||
@@ -47,7 +49,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
|
||||
for (int i = start; i < data.Length; i++)
|
||||
{
|
||||
outputSpan[i] = (ushort)data[i];
|
||||
outputSpan[i] = data[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -70,16 +72,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertR5G6B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static IMemoryOwner<byte> ConvertR5G6B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
byte[] output = new byte[data.Length * 2];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@@ -107,16 +109,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertR5G5B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width, bool forceAlpha)
|
||||
public static IMemoryOwner<byte> ConvertR5G5B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width, bool forceAlpha)
|
||||
{
|
||||
byte[] output = new byte[data.Length * 2];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@@ -144,16 +146,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertA1B5G5R5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static IMemoryOwner<byte> ConvertA1B5G5R5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
byte[] output = new byte[data.Length * 2];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@@ -181,16 +183,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public unsafe static byte[] ConvertR4G4B4A4ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static IMemoryOwner<byte> ConvertR4G4B4A4ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
byte[] output = new byte[data.Length * 2];
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using CompareOp = Ryujinx.Graphics.GAL.CompareOp;
|
||||
@@ -216,7 +217,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Span<byte> dummyTextureData = stackalloc byte[4];
|
||||
IMemoryOwner<byte> dummyTextureData = ByteMemoryPool.RentCleared(4);
|
||||
_dummyTexture.SetData(dummyTextureData);
|
||||
}
|
||||
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
SwizzleComponent.Blue,
|
||||
SwizzleComponent.Alpha);
|
||||
|
||||
var areaTexture = EmbeddedResources.Read("Ryujinx.Graphics.Vulkan/Effects/Textures/SmaaAreaTexture.bin");
|
||||
var searchTexture = EmbeddedResources.Read("Ryujinx.Graphics.Vulkan/Effects/Textures/SmaaSearchTexture.bin");
|
||||
var areaTexture = EmbeddedResources.ReadFileToRentedMemory("Ryujinx.Graphics.Vulkan/Effects/Textures/SmaaAreaTexture.bin");
|
||||
var searchTexture = EmbeddedResources.ReadFileToRentedMemory("Ryujinx.Graphics.Vulkan/Effects/Textures/SmaaSearchTexture.bin");
|
||||
|
||||
_areaTexture = _renderer.CreateTexture(areaInfo) as TextureView;
|
||||
_searchTexture = _renderer.CreateTexture(searchInfo) as TextureView;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using Format = Ryujinx.Graphics.GAL.Format;
|
||||
using VkFormat = Silk.NET.Vulkan.Format;
|
||||
@@ -94,17 +94,21 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_bufferView = null;
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
_gd.SetBufferData(_bufferHandle, _offset, data);
|
||||
_gd.SetBufferData(_bufferHandle, _offset, data.Memory.Span);
|
||||
data.Dispose();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -702,19 +702,25 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return GetDataFromBuffer(result, size, result);
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data)
|
||||
{
|
||||
SetData(data, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false);
|
||||
SetData(data.Memory.Span, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false);
|
||||
data.Dispose();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level)
|
||||
{
|
||||
SetData(data, layer, level, 1, 1, singleSlice: true);
|
||||
SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true);
|
||||
data.Dispose();
|
||||
}
|
||||
|
||||
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
|
||||
/// <inheritdoc/>
|
||||
public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
|
||||
{
|
||||
SetData(data, layer, level, 1, 1, singleSlice: true, region);
|
||||
SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true, region);
|
||||
data.Dispose();
|
||||
}
|
||||
|
||||
private void SetData(ReadOnlySpan<byte> data, int layer, int level, int layers, int levels, bool singleSlice, Rectangle<int>? region = null)
|
||||
|
||||
@@ -70,7 +70,14 @@ use serde::{Deserialize, Serialize};
|
||||
use shadowsocks::relay::socks5::Address;
|
||||
use shadowsocks::{
|
||||
config::{
|
||||
ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerUser, ServerUserManager, ServerWeight,
|
||||
ManagerAddr,
|
||||
Mode,
|
||||
ReplayAttackPolicy,
|
||||
ServerAddr,
|
||||
ServerConfig,
|
||||
ServerUser,
|
||||
ServerUserManager,
|
||||
ServerWeight,
|
||||
},
|
||||
crypto::CipherKind,
|
||||
plugin::PluginConfig,
|
||||
|
||||
@@ -6,7 +6,10 @@ use hickory_resolver::proto::{
|
||||
op::{header::MessageType, response_code::ResponseCode, Message, OpCode},
|
||||
rr::{
|
||||
rdata::{A, AAAA},
|
||||
DNSClass, RData, Record, RecordType,
|
||||
DNSClass,
|
||||
RData,
|
||||
Record,
|
||||
RecordType,
|
||||
},
|
||||
};
|
||||
use log::{debug, trace};
|
||||
|
||||
+13
-9
@@ -35,7 +35,7 @@ use tokio::{
|
||||
time,
|
||||
};
|
||||
|
||||
use crate::local::context::ServiceContext;
|
||||
use crate::{config::ServerInstanceConfig, local::context::ServiceContext};
|
||||
|
||||
use super::{
|
||||
server_data::ServerIdent,
|
||||
@@ -82,8 +82,9 @@ impl PingBalancerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_server(&mut self, server: ServerConfig) {
|
||||
pub fn add_server(&mut self, server: ServerInstanceConfig) {
|
||||
let ident = ServerIdent::new(
|
||||
self.context.clone(),
|
||||
server,
|
||||
self.max_server_rtt,
|
||||
self.check_interval * EXPECTED_CHECK_POINTS_IN_CHECK_WINDOW,
|
||||
@@ -720,13 +721,14 @@ impl PingBalancer {
|
||||
}
|
||||
|
||||
/// Reset servers in load balancer. Designed for auto-reloading configuration file.
|
||||
pub async fn reset_servers(&self, servers: Vec<ServerConfig>) -> io::Result<()> {
|
||||
pub async fn reset_servers(&self, servers: Vec<ServerInstanceConfig>) -> io::Result<()> {
|
||||
let old_context = self.inner.context.load();
|
||||
|
||||
let servers = servers
|
||||
.into_iter()
|
||||
.map(|s| {
|
||||
Arc::new(ServerIdent::new(
|
||||
old_context.context.clone(),
|
||||
s,
|
||||
old_context.max_server_rtt,
|
||||
old_context.check_interval * EXPECTED_CHECK_POINTS_IN_CHECK_WINDOW,
|
||||
@@ -811,7 +813,7 @@ impl PingChecker {
|
||||
self.context.context(),
|
||||
self.server.server_config(),
|
||||
&addr,
|
||||
self.context.connect_opts_ref(),
|
||||
self.server.connect_opts_ref(),
|
||||
)
|
||||
.await?;
|
||||
stream.write_all(GET_BODY).await?;
|
||||
@@ -851,7 +853,7 @@ impl PingChecker {
|
||||
self.context.context(),
|
||||
self.server.server_config(),
|
||||
&addr,
|
||||
self.context.connect_opts_ref(),
|
||||
self.server.connect_opts_ref(),
|
||||
)
|
||||
.await?;
|
||||
stream.write_all(GET_BODY).await?;
|
||||
@@ -896,10 +898,12 @@ impl PingChecker {
|
||||
|
||||
let addr = Address::SocketAddress(SocketAddr::new(Ipv4Addr::new(8, 8, 8, 8).into(), 53));
|
||||
|
||||
let svr_cfg = self.server.server_config();
|
||||
|
||||
let client =
|
||||
ProxySocket::connect_with_opts(self.context.context(), svr_cfg, self.context.connect_opts_ref()).await?;
|
||||
let client = ProxySocket::connect_with_opts(
|
||||
self.context.context(),
|
||||
self.server.server_config(),
|
||||
self.server.connect_opts_ref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut control = UdpSocketControlData::default();
|
||||
control.client_session_id = rand::random::<u64>();
|
||||
|
||||
@@ -2,13 +2,18 @@
|
||||
|
||||
use std::{
|
||||
fmt::{self, Debug},
|
||||
sync::atomic::{AtomicU32, Ordering},
|
||||
sync::{
|
||||
atomic::{AtomicU32, Ordering},
|
||||
Arc,
|
||||
},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use shadowsocks::ServerConfig;
|
||||
use shadowsocks::{net::ConnectOpts, ServerConfig};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{config::ServerInstanceConfig, local::context::ServiceContext};
|
||||
|
||||
use super::server_stat::{Score, ServerStat};
|
||||
|
||||
/// Server's statistic score
|
||||
@@ -61,25 +66,44 @@ impl Debug for ServerScore {
|
||||
pub struct ServerIdent {
|
||||
tcp_score: ServerScore,
|
||||
udp_score: ServerScore,
|
||||
svr_cfg: ServerConfig,
|
||||
svr_cfg: ServerInstanceConfig,
|
||||
connect_opts: ConnectOpts,
|
||||
}
|
||||
|
||||
impl ServerIdent {
|
||||
/// Create a `ServerIdent`
|
||||
pub fn new(svr_cfg: ServerConfig, max_server_rtt: Duration, check_window: Duration) -> ServerIdent {
|
||||
pub fn new(
|
||||
context: Arc<ServiceContext>,
|
||||
svr_cfg: ServerInstanceConfig,
|
||||
max_server_rtt: Duration,
|
||||
check_window: Duration,
|
||||
) -> ServerIdent {
|
||||
#[allow(unused_mut)]
|
||||
let mut connect_opts = context.connect_opts_ref().clone();
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
if let Some(fwmark) = svr_cfg.outbound_fwmark {
|
||||
connect_opts.fwmark = Some(fwmark);
|
||||
}
|
||||
|
||||
ServerIdent {
|
||||
tcp_score: ServerScore::new(svr_cfg.weight().tcp_weight(), max_server_rtt, check_window),
|
||||
udp_score: ServerScore::new(svr_cfg.weight().udp_weight(), max_server_rtt, check_window),
|
||||
tcp_score: ServerScore::new(svr_cfg.config.weight().tcp_weight(), max_server_rtt, check_window),
|
||||
udp_score: ServerScore::new(svr_cfg.config.weight().udp_weight(), max_server_rtt, check_window),
|
||||
svr_cfg,
|
||||
connect_opts,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connect_opts_ref(&self) -> &ConnectOpts {
|
||||
&self.connect_opts
|
||||
}
|
||||
|
||||
pub fn server_config(&self) -> &ServerConfig {
|
||||
&self.svr_cfg
|
||||
&self.svr_cfg.config
|
||||
}
|
||||
|
||||
pub fn server_config_mut(&mut self) -> &mut ServerConfig {
|
||||
&mut self.svr_cfg
|
||||
&mut self.svr_cfg.config
|
||||
}
|
||||
|
||||
pub fn tcp_score(&self) -> &ServerScore {
|
||||
|
||||
@@ -226,7 +226,7 @@ impl Server {
|
||||
}
|
||||
|
||||
for server in config.server {
|
||||
balancer_builder.add_server(server.config);
|
||||
balancer_builder.add_server(server);
|
||||
}
|
||||
|
||||
balancer_builder.build().await?
|
||||
|
||||
@@ -29,7 +29,9 @@ use shadowsocks::{
|
||||
use crate::{
|
||||
local::{context::ServiceContext, loadbalancing::PingBalancer},
|
||||
net::{
|
||||
packet_window::PacketWindowFilter, MonProxySocket, UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE,
|
||||
packet_window::PacketWindowFilter,
|
||||
MonProxySocket,
|
||||
UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE,
|
||||
UDP_ASSOCIATION_SEND_CHANNEL_SIZE,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ use tokio::{
|
||||
};
|
||||
|
||||
use crate::net::{
|
||||
sys::{ErrorKind, set_common_sockopt_after_connect, set_common_sockopt_for_connect},
|
||||
sys::{set_common_sockopt_after_connect, set_common_sockopt_for_connect, ErrorKind},
|
||||
AcceptOpts,
|
||||
AddrFamily,
|
||||
ConnectOpts,
|
||||
|
||||
@@ -991,10 +991,13 @@ fn launch_reload_server_task(config_path: PathBuf, balancer: PingBalancer) {
|
||||
}
|
||||
};
|
||||
|
||||
let servers: Vec<ServerConfig> = config.server.into_iter().map(|s| s.config).collect();
|
||||
info!("auto-reload {} with {} servers", config_path.display(), servers.len());
|
||||
info!(
|
||||
"auto-reload {} with {} servers",
|
||||
config_path.display(),
|
||||
config.server.len()
|
||||
);
|
||||
|
||||
if let Err(err) = balancer.reset_servers(servers).await {
|
||||
if let Err(err) = balancer.reset_servers(config.server).await {
|
||||
error!("auto-reload {} but found error: {}", config_path.display(), err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,33 +3,33 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=chinadns-ng
|
||||
PKG_VERSION:=2024.03.27
|
||||
PKG_VERSION:=2024.04.13
|
||||
PKG_RELEASE:=1
|
||||
|
||||
ifeq ($(ARCH),aarch64)
|
||||
PKG_ARCH:=chinadns-ng@aarch64-linux-musl@generic+v8a@fast+lto
|
||||
PKG_HASH:=5255a5393d0923ca378f1076eefa8719ab301b25398ab0280e026cdc6316b0e4
|
||||
PKG_HASH:=dddbfcde000d4178fee2f8cdcfec7f10f8deb1f6673f9046b35d340dd2182ac5
|
||||
else ifeq ($(ARCH),arm)
|
||||
ARM_CPU_FEATURES:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
|
||||
ifeq ($(ARM_CPU_FEATURES),)
|
||||
PKG_ARCH:=chinadns-ng@arm-linux-musleabi@generic+v6+soft_float@fast+lto
|
||||
PKG_HASH:=f9e597bbc060d7c5e19c837a3c0b3118f91c986f29ee7f55a23ace321aca1731
|
||||
PKG_HASH:=08fb1ae28eeb41ff48e9fd3b0dea3f58111885f1a39acea91978a883fb3d62ed
|
||||
else
|
||||
PKG_ARCH:=chinadns-ng@arm-linux-musleabihf@generic+v7a@fast+lto
|
||||
PKG_HASH:=d065c7d55b6c43b20dbb668d7bdafabe371c3360cc75bd0279cc2d7a83e342e9
|
||||
PKG_HASH:=2653bc82f8ae622e793c28933da55321aef82e8b923df9fd3cedb72f3f34fa90
|
||||
endif
|
||||
else ifeq ($(ARCH),mips)
|
||||
PKG_ARCH:=chinadns-ng@mips-linux-musl@mips32+soft_float@fast+lto
|
||||
PKG_HASH:=2170011ecf8ee29057d805eb8054bcc4366b759f454c063f0a258c84403e416e
|
||||
PKG_HASH:=0245d23021867461524398b1074fc13abf8aae56ae93faa1ecd78b1bda6b5d76
|
||||
else ifeq ($(ARCH),mipsel)
|
||||
PKG_ARCH:=chinadns-ng@mipsel-linux-musl@mips32+soft_float@fast+lto
|
||||
PKG_HASH:=9ac1462187b3b06173f908295d45fd0fa3e37eb50171e22198e29dd81710b268
|
||||
PKG_HASH:=15845a0b03deba4e407dda963d60f47623e93fdf5d0e9ab0f83baa25be0bb36f
|
||||
else ifeq ($(ARCH),i386)
|
||||
PKG_ARCH:=chinadns-ng@i386-linux-musl@i686@fast+lto
|
||||
PKG_HASH:=bf22fb35fba5e9b1174b0334a5473d4db8b3f85e489cec5af94f9a92f7c9787b
|
||||
PKG_HASH:=5bfdf006971be9c96f59c797c554972337197aaf5d9b6d8402da61738147653d
|
||||
else ifeq ($(ARCH),x86_64)
|
||||
PKG_ARCH:=chinadns-ng@x86_64-linux-musl@x86_64@fast+lto
|
||||
PKG_HASH:=8adf68d15068a3a27588772deb19be0a9804077a075aa8dad9dafa12a154c529
|
||||
PKG_HASH:=af11c02a80f5b7db69832c86a15126adf822d54e8f0aa38bb1d88f75449180bc
|
||||
else
|
||||
PKG_HASH:=dummy
|
||||
endif
|
||||
|
||||
@@ -568,6 +568,7 @@ o.rmempty = true
|
||||
|
||||
-- Tuic settings for the local inbound socks5 server
|
||||
o = s:option(Flag, "tuic_dual_stack", translate("Dual-stack Listening Socket"))
|
||||
o.description = translate("If this option is not set, the socket behavior is platform dependent.")
|
||||
o:depends("type", "tuic")
|
||||
o.default = "0"
|
||||
o.rmempty = true
|
||||
@@ -941,7 +942,8 @@ o:depends("reality", true)
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(DynamicList, "tls_alpn", translate("TLS ALPN"))
|
||||
o:depends({type = "tuic", tls = true})
|
||||
o:depends("type", "tuic")
|
||||
o.default = "h3"
|
||||
o.rmempty = true
|
||||
|
||||
-- [[ allowInsecure ]]--
|
||||
|
||||
@@ -1050,6 +1050,9 @@ msgstr "接收窗口(无需确认即可接收的最大字节数:默认8Mb)
|
||||
msgid "Dual-stack Listening Socket"
|
||||
msgstr "双栈Socket监听"
|
||||
|
||||
msgid "If this option is not set, the socket behavior is platform dependent."
|
||||
msgstr "如果未设置此选项,则套接字行为依赖于平台。"
|
||||
|
||||
msgid "Maximum packet size the socks5 server can receive from external"
|
||||
msgstr "socks5服务器可以从外部接收的最大数据包大小(单位:字节)"
|
||||
|
||||
|
||||
@@ -476,8 +476,8 @@ local tuic = {
|
||||
receive_window = tonumber(server.receive_window)
|
||||
},
|
||||
["local"] = {
|
||||
server = tonumber(socks_port) and (server.tuic_dual_stack == "1" and "[::1]:" or "127.0.0.1:") .. (socks_port == "0" and local_port or tonumber(socks_port)),
|
||||
dual_stack = (server.tuic_dual_stack == "1") and true or false,
|
||||
server = tonumber(socks_port) and "[::]:" .. (socks_port == "0" and local_port or tonumber(socks_port)),
|
||||
dual_stack = (server.tuic_dual_stack == "1") and true or nil,
|
||||
max_packet_size = tonumber(server.tuic_max_package_size)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ FROM golang:alpine
|
||||
RUN apk --no-cache add iptables ip6tables git
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn
|
||||
RUN go get github.com/codegangsta/gin
|
||||
RUN go install github.com/codegangsta/gin@latest
|
||||
WORKDIR /service
|
||||
COPY --from=v2ray /usr/bin/v2ray /usr/bin/v2ctl /usr/share/v2ray/
|
||||
COPY --from=v2ray /usr/bin/v2ray /usr/share/v2ray/
|
||||
COPY --from=v2ray /usr/local/share/v2ray/* /usr/local/share/v2ray/
|
||||
ENV PATH=$PATH:/usr/share/v2ray
|
||||
ENV CONFIG=../config.json
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ else
|
||||
fi
|
||||
# https://github.com/webpack/webpack/issues/14532#issuecomment-947012063
|
||||
cd "$CurrentDir"/gui && yarn && OUTPUT_DIR="$CurrentDir"/service/server/router/web yarn build
|
||||
cd "$CurrentDir"/service && CGO_ENABLED=0 go build -ldflags "-X github.com/v2rayA/v2rayA/conf.Version=$version -s -w" -o "$CurrentDir"/v2raya
|
||||
cd "$CurrentDir"/service && CGO_ENABLED=0 go build -tags "with_gvisor" -ldflags "-X github.com/v2rayA/v2rayA/conf.Version=$version -s -w" -o "$CurrentDir"/v2raya
|
||||
@@ -32,7 +32,6 @@
|
||||
}}</span>
|
||||
<b-button
|
||||
size="is-small"
|
||||
type="is-text"
|
||||
style="
|
||||
position: relative;
|
||||
top: -2px;
|
||||
@@ -121,6 +120,8 @@
|
||||
<b-select v-model="transparentType" expanded class="left-border">
|
||||
<option v-show="!lite" value="redirect">redirect</option>
|
||||
<option v-show="!lite" value="tproxy">tproxy</option>
|
||||
<option v-show="!lite" value="gvisor_tun">gvisor tun</option>
|
||||
<option v-show="!lite" value="system_tun">system tun</option>
|
||||
<option value="system_proxy">system proxy</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
@@ -175,6 +175,7 @@ type Mux struct {
|
||||
type OutboundObject struct {
|
||||
Tag string `json:"tag"`
|
||||
Protocol string `json:"protocol"`
|
||||
SendThrough string `json:"sendThrough,omitempty"`
|
||||
Settings Settings `json:"settings,omitempty"`
|
||||
StreamSettings *StreamSettings `json:"streamSettings,omitempty"`
|
||||
ProxySettings *ProxySettings `json:"proxySettings,omitempty"`
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package dns
|
||||
|
||||
import "net/netip"
|
||||
|
||||
var defaultDNS = []netip.AddrPort{netip.MustParseAddrPort("127.0.0.1:53"), netip.MustParseAddrPort("[::1]:53")}
|
||||
@@ -0,0 +1,67 @@
|
||||
//go:build !js && !windows
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetSystemDNS() (servers []netip.AddrPort) {
|
||||
f, err := os.Open("/etc/resolv.conf")
|
||||
if err != nil {
|
||||
return defaultDNS
|
||||
}
|
||||
defer f.Close()
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
f := getFields(line)
|
||||
if len(f) < 1 {
|
||||
continue
|
||||
}
|
||||
switch f[0] {
|
||||
case "nameserver":
|
||||
if len(f) > 1 {
|
||||
if addr, err := netip.ParseAddr(f[1]); err == nil {
|
||||
servers = append(servers, netip.AddrPortFrom(addr, 53))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func countAnyByte(s string, t string) int {
|
||||
n := 0
|
||||
for i := 0; i < len(s); i++ {
|
||||
if strings.IndexByte(t, s[i]) >= 0 {
|
||||
n++
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func splitAtBytes(s string, t string) []string {
|
||||
a := make([]string, 1+countAnyByte(s, t))
|
||||
n := 0
|
||||
last := 0
|
||||
for i := 0; i < len(s); i++ {
|
||||
if strings.IndexByte(t, s[i]) >= 0 {
|
||||
if last < i {
|
||||
a[n] = s[last:i]
|
||||
n++
|
||||
}
|
||||
last = i + 1
|
||||
}
|
||||
}
|
||||
if last < len(s) {
|
||||
a[n] = s[last:]
|
||||
n++
|
||||
}
|
||||
return a[0:n]
|
||||
}
|
||||
|
||||
func getFields(s string) []string { return splitAtBytes(s, " \r\t\n") }
|
||||
@@ -0,0 +1,68 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func GetSystemDNS() (servers []netip.AddrPort) {
|
||||
aas, err := adapterAddresses()
|
||||
if err != nil {
|
||||
return defaultDNS
|
||||
}
|
||||
for _, aa := range aas {
|
||||
for dns := aa.FirstDnsServerAddress; dns != nil; dns = dns.Next {
|
||||
if aa.OperStatus != windows.IfOperStatusUp {
|
||||
continue
|
||||
}
|
||||
sa, err := dns.Address.Sockaddr.Sockaddr()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
var addr netip.Addr
|
||||
switch sa := sa.(type) {
|
||||
case *syscall.SockaddrInet4:
|
||||
addr = netip.AddrFrom4(sa.Addr)
|
||||
case *syscall.SockaddrInet6:
|
||||
if sa.Addr[0] == 0xfe && sa.Addr[1] == 0xc0 {
|
||||
continue
|
||||
}
|
||||
addr = netip.AddrFrom16(sa.Addr)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
servers = append(servers, netip.AddrPortFrom(addr, 53))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func adapterAddresses() ([]*windows.IpAdapterAddresses, error) {
|
||||
var b []byte
|
||||
l := uint32(15000)
|
||||
for {
|
||||
b = make([]byte, l)
|
||||
err := windows.GetAdaptersAddresses(syscall.AF_UNSPEC, windows.GAA_FLAG_INCLUDE_PREFIX, 0, (*windows.IpAdapterAddresses)(unsafe.Pointer(&b[0])), &l)
|
||||
if err == nil {
|
||||
if l == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
break
|
||||
}
|
||||
if err.(syscall.Errno) != syscall.ERROR_BUFFER_OVERFLOW {
|
||||
return nil, os.NewSyscallError("getadaptersaddresses", err)
|
||||
}
|
||||
if l <= uint32(len(b)) {
|
||||
return nil, os.NewSyscallError("getadaptersaddresses", err)
|
||||
}
|
||||
}
|
||||
var aas []*windows.IpAdapterAddresses
|
||||
for aa := (*windows.IpAdapterAddresses)(unsafe.Pointer(&b[0])); aa != nil; aa = aa.Next {
|
||||
aas = append(aas, aa)
|
||||
}
|
||||
return aas, nil
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const networksetup = "/usr/sbin/networksetup"
|
||||
|
||||
func GetValidNetworkInterfaces() ([]string, error) {
|
||||
cmd := exec.Command(networksetup, "-listallnetworkservices")
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("networksetup get: %v", err)
|
||||
}
|
||||
var interfaces []string
|
||||
scanner := bufio.NewScanner(bytes.NewReader(output))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.Contains(line, "*") {
|
||||
continue
|
||||
}
|
||||
cmd = exec.Command(networksetup, "-getinfo", line)
|
||||
output, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
valid := false
|
||||
scanner2 := bufio.NewScanner(bytes.NewReader(output))
|
||||
for scanner2.Scan() {
|
||||
line2 := scanner2.Text()
|
||||
key, value, ok := strings.Cut(line2, ": ")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if key == "IP address" || key == "IPv6 IP address" {
|
||||
if _, err = netip.ParseAddr(value); err == nil {
|
||||
valid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if valid {
|
||||
interfaces = append(interfaces, line)
|
||||
}
|
||||
}
|
||||
return interfaces, nil
|
||||
}
|
||||
|
||||
func GetDNSServer(ifi string) ([]string, error) {
|
||||
cmd := exec.Command(networksetup, "-getdnsservers", ifi)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("networksetup get: %v", err)
|
||||
}
|
||||
var server []string
|
||||
scanner := bufio.NewScanner(bytes.NewReader(output))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if _, err = netip.ParseAddr(line); err == nil {
|
||||
server = append(server, line)
|
||||
}
|
||||
}
|
||||
return server, nil
|
||||
}
|
||||
|
||||
func SetDNSServer(ifi string, server ...string) error {
|
||||
cmd := exec.Command(networksetup, "-setdnsservers", ifi)
|
||||
if len(server) == 0 {
|
||||
cmd.Args = append(cmd.Args, "Empty")
|
||||
} else {
|
||||
cmd.Args = append(cmd.Args, server...)
|
||||
}
|
||||
_, err := cmd.CombinedOutput()
|
||||
return err
|
||||
}
|
||||
|
||||
func ReplaceDNSServer(ifi string, server ...string) ([]string, error) {
|
||||
old, err := GetDNSServer(ifi)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return old, SetDNSServer(ifi, server...)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//go:build !windows && !darwin
|
||||
|
||||
package dns
|
||||
|
||||
import "errors"
|
||||
|
||||
func GetValidNetworkInterfaces() ([]string, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func GetDNSServer(ifi string) ([]string, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func SetDNSServer(ifi string, server ...string) error {
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
|
||||
func ReplaceDNSServer(ifi string, server ...string) ([]string, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
const basePath = `SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\`
|
||||
|
||||
func GetValidNetworkInterfaces() ([]string, error) {
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, basePath, registry.ENUMERATE_SUB_KEYS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer key.Close()
|
||||
names, err := key.ReadSubKeyNames(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var interfaces []string
|
||||
for _, name := range names {
|
||||
key, err = registry.OpenKey(registry.LOCAL_MACHINE, basePath+name, registry.READ)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if ip, _, _ := key.GetStringsValue("IPAddress"); len(ip) != 0 {
|
||||
interfaces = append(interfaces, name)
|
||||
} else if ip, _, _ := key.GetStringValue("DhcpIPAddress"); ip != "" {
|
||||
interfaces = append(interfaces, name)
|
||||
}
|
||||
key.Close()
|
||||
}
|
||||
return interfaces, nil
|
||||
}
|
||||
|
||||
func GetDNSServer(ifi string) ([]string, error) {
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, basePath+ifi, registry.READ)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer key.Close()
|
||||
server, _, err := key.GetStringValue("NameServer")
|
||||
if err != nil && !errors.Is(err, registry.ErrNotExist) {
|
||||
return nil, err
|
||||
}
|
||||
return strings.Split(server, ","), nil
|
||||
}
|
||||
|
||||
func SetDNSServer(ifi string, server ...string) error {
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, basePath+ifi, registry.WRITE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer key.Close()
|
||||
return key.SetStringValue("NameServer", strings.Join(server, ","))
|
||||
}
|
||||
|
||||
func ReplaceDNSServer(ifi string, server ...string) ([]string, error) {
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, basePath+ifi, registry.READ|registry.WRITE)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer key.Close()
|
||||
value, _, err := key.GetStringValue("NameServer")
|
||||
if err != nil && !errors.Is(err, registry.ErrNotExist) {
|
||||
return nil, err
|
||||
}
|
||||
return strings.Split(value, ","), key.SetStringValue("NameServer", strings.Join(server, ","))
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type cacheItem[T any] struct {
|
||||
expires time.Time
|
||||
data T
|
||||
}
|
||||
|
||||
type cache[K comparable, V any] struct {
|
||||
sync.RWMutex
|
||||
cache map[K]*cacheItem[V]
|
||||
}
|
||||
|
||||
func newCache[K comparable, V any]() *cache[K, V] {
|
||||
return &cache[K, V]{
|
||||
cache: make(map[K]*cacheItem[V]),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) Check() {
|
||||
c.Lock()
|
||||
c.UnsafeCheck()
|
||||
c.Unlock()
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) Contains(key K) bool {
|
||||
c.RLock()
|
||||
_, ok := c.cache[key]
|
||||
c.RUnlock()
|
||||
return ok
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) Load(key K) (value V, ok bool) {
|
||||
c.RLock()
|
||||
value, ok = c.UnsafeLoad(key)
|
||||
c.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) Store(key K, value V, ttl time.Duration) {
|
||||
c.Lock()
|
||||
c.UnsafeStore(key, value, ttl)
|
||||
c.Unlock()
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) UnsafeCheck() {
|
||||
now := time.Now()
|
||||
for k, v := range c.cache {
|
||||
if now.After(v.expires) {
|
||||
delete(c.cache, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) UnsafeContains(key K) bool {
|
||||
_, ok := c.cache[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) UnsafeLoad(key K) (value V, ok bool) {
|
||||
var item *cacheItem[V]
|
||||
item, ok = c.cache[key]
|
||||
if ok {
|
||||
value = item.data
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cache[K, V]) UnsafeStore(key K, value V, ttl time.Duration) {
|
||||
c.cache[key] = &cacheItem[V]{
|
||||
expires: time.Now().Add(ttl),
|
||||
data: value,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tun
|
||||
|
||||
import "io"
|
||||
|
||||
type Closer []io.Closer
|
||||
|
||||
func (c Closer) Close() error {
|
||||
for i := len(c) - 1; i >= 0; i-- {
|
||||
c[i].Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
"github.com/sagernet/sing/common/bufio"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
)
|
||||
|
||||
const (
|
||||
DNSTimeout = 10 * time.Second
|
||||
FakeTTL = 5 * time.Minute
|
||||
|
||||
FixedPacketSize = 16384
|
||||
)
|
||||
|
||||
const (
|
||||
dnsDirect = iota
|
||||
dnsForward
|
||||
dnsFake4
|
||||
dnsFake6
|
||||
)
|
||||
|
||||
var (
|
||||
fakePrefix4 = netip.MustParsePrefix("198.18.0.0/15")
|
||||
fakePrefix6 = netip.MustParsePrefix("fc00::/18")
|
||||
|
||||
defaultDNSServer = M.ParseSocksaddrHostPort("1.1.1.1", 53)
|
||||
)
|
||||
|
||||
type DNS struct {
|
||||
dialer N.Dialer
|
||||
forward N.Dialer
|
||||
addr M.Socksaddr
|
||||
whitelist Matcher
|
||||
servers []M.Socksaddr
|
||||
cache *cache[netip.Addr, string]
|
||||
currentIP4 netip.Addr
|
||||
currentIP6 netip.Addr
|
||||
fakeCache *cache[netip.Addr, string]
|
||||
domainCache4 *cache[string, netip.Addr]
|
||||
domainCache6 *cache[string, netip.Addr]
|
||||
}
|
||||
|
||||
func NewDNS(dialer, forward N.Dialer, addr M.Socksaddr) *DNS {
|
||||
return &DNS{
|
||||
dialer: dialer,
|
||||
forward: forward,
|
||||
addr: addr,
|
||||
cache: newCache[netip.Addr, string](),
|
||||
currentIP4: fakePrefix4.Addr().Next(),
|
||||
currentIP6: fakePrefix6.Addr().Next(),
|
||||
fakeCache: newCache[netip.Addr, string](),
|
||||
domainCache4: newCache[string, netip.Addr](),
|
||||
domainCache6: newCache[string, netip.Addr](),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DNS) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error {
|
||||
d.fakeCache.Check()
|
||||
if metadata.Destination != d.addr {
|
||||
return continueHandler
|
||||
}
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func() {
|
||||
for {
|
||||
var queryLength uint16
|
||||
err := binary.Read(conn, binary.BigEndian, &queryLength)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
if queryLength == 0 {
|
||||
cancel(errors.New("format error"))
|
||||
return
|
||||
}
|
||||
buffer := buf.NewSize(int(queryLength))
|
||||
defer buffer.Release()
|
||||
_, err = buffer.ReadFullFrom(conn, int(queryLength))
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
var message D.Msg
|
||||
err = message.Unpack(buffer.Bytes())
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
response, err := d.Exchange(ctx, &message)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
responseBuffer := buf.NewPacket()
|
||||
defer responseBuffer.Release()
|
||||
responseBuffer.Resize(2, 0)
|
||||
n, err := response.PackBuffer(responseBuffer.FreeBytes())
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
responseBuffer.Truncate(len(n))
|
||||
binary.BigEndian.PutUint16(responseBuffer.ExtendHeader(2), uint16(len(n)))
|
||||
_, err = conn.Write(responseBuffer.Bytes())
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
<-ctx.Done()
|
||||
cancel(nil)
|
||||
conn.Close()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func (d *DNS) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error {
|
||||
d.fakeCache.Check()
|
||||
if metadata.Destination != d.addr {
|
||||
return continueHandler
|
||||
}
|
||||
var reader N.PacketReader = conn
|
||||
var counters []N.CountFunc
|
||||
var cachedPackets []*N.PacketBuffer
|
||||
for {
|
||||
reader, counters = N.UnwrapCountPacketReader(reader, counters)
|
||||
if cachedReader, isCached := reader.(N.CachedPacketReader); isCached {
|
||||
packet := cachedReader.ReadCachedPacket()
|
||||
if packet != nil {
|
||||
cachedPackets = append(cachedPackets, packet)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if readWaiter, created := bufio.CreatePacketReadWaiter(reader); created {
|
||||
return d.newPacketConnection(ctx, conn, readWaiter, counters, cachedPackets, metadata)
|
||||
}
|
||||
break
|
||||
}
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func() {
|
||||
for {
|
||||
var message D.Msg
|
||||
var destination M.Socksaddr
|
||||
var err error
|
||||
if len(cachedPackets) > 0 {
|
||||
packet := cachedPackets[0]
|
||||
cachedPackets = cachedPackets[1:]
|
||||
for _, counter := range counters {
|
||||
counter(int64(packet.Buffer.Len()))
|
||||
}
|
||||
err = message.Unpack(packet.Buffer.Bytes())
|
||||
packet.Buffer.Release()
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
destination = packet.Destination
|
||||
} else {
|
||||
timeout := time.AfterFunc(DNSTimeout, func() {
|
||||
cancel(context.DeadlineExceeded)
|
||||
})
|
||||
buffer := buf.NewPacket()
|
||||
destination, err = conn.ReadPacket(buffer)
|
||||
if err != nil {
|
||||
buffer.Release()
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
for _, counter := range counters {
|
||||
counter(int64(buffer.Len()))
|
||||
}
|
||||
err = message.Unpack(buffer.Bytes())
|
||||
buffer.Release()
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
timeout.Stop()
|
||||
}
|
||||
go func() {
|
||||
response, err := d.Exchange(ctx, &message)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
responseBuffer := buf.NewPacket()
|
||||
n, err := response.PackBuffer(responseBuffer.FreeBytes())
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
responseBuffer.Release()
|
||||
return
|
||||
}
|
||||
responseBuffer.Truncate(len(n))
|
||||
err = conn.WritePacket(responseBuffer, destination)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
<-ctx.Done()
|
||||
cancel(nil)
|
||||
conn.Close()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func (d *DNS) Exchange(ctx context.Context, msg *D.Msg) (*D.Msg, error) {
|
||||
if len(msg.Question) != 1 {
|
||||
return d.newResponse(msg, D.RcodeFormatError), nil
|
||||
}
|
||||
mode := dnsDirect
|
||||
if len(d.servers) == 0 {
|
||||
mode = dnsForward
|
||||
}
|
||||
question := msg.Question[0]
|
||||
domain := strings.TrimSuffix(question.Name, ".")
|
||||
if !d.whitelist.Match(domain) {
|
||||
switch question.Qtype {
|
||||
case D.TypeA:
|
||||
mode = dnsFake4
|
||||
case D.TypeAAAA:
|
||||
return d.newResponse(msg, D.RcodeSuccess), nil
|
||||
mode = dnsFake6
|
||||
case D.TypeMX, D.TypeHTTPS:
|
||||
return d.newResponse(msg, D.RcodeSuccess), nil
|
||||
}
|
||||
}
|
||||
var dialer N.Dialer
|
||||
server := defaultDNSServer
|
||||
switch mode {
|
||||
case dnsDirect:
|
||||
dialer = d.dialer
|
||||
server = d.getServer()
|
||||
case dnsForward:
|
||||
dialer = d.forward
|
||||
case dnsFake4:
|
||||
addr, ok := d.getAvailableIP4(domain)
|
||||
if ok {
|
||||
return d.newResponse(msg, D.RcodeSuccess, addr), nil
|
||||
}
|
||||
dialer = d.forward
|
||||
case dnsFake6:
|
||||
if addr, ok := d.getAvailableIP6(domain); ok {
|
||||
return d.newResponse(msg, D.RcodeSuccess, addr), nil
|
||||
}
|
||||
dialer = d.forward
|
||||
}
|
||||
if dialer != nil {
|
||||
buffer := make([]byte, 1024)
|
||||
data, err := msg.PackBuffer(buffer)
|
||||
if err != nil {
|
||||
return d.newResponse(msg, D.RcodeFormatError), nil
|
||||
}
|
||||
resp, err := func() (*D.Msg, error) {
|
||||
serverConn, err := dialer.ListenPacket(ctx, server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer serverConn.Close()
|
||||
serverConn.SetDeadline(time.Now().Add(DNSTimeout))
|
||||
_, err = serverConn.WriteTo(data, server.UDPAddr())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n, _, err := serverConn.ReadFrom(buffer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var resp D.Msg
|
||||
err = resp.Unpack(buffer[:n])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}()
|
||||
if err != nil {
|
||||
return d.newResponse(msg, D.RcodeServerFailure), nil
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
return d.newResponse(msg, D.RcodeRefused), nil
|
||||
}
|
||||
|
||||
func (d *DNS) newPacketConnection(ctx context.Context, conn N.PacketConn, readWaiter N.PacketReadWaiter, readCounters []N.CountFunc, cached []*N.PacketBuffer, metadata M.Metadata) error {
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func() {
|
||||
var buffer *buf.Buffer
|
||||
readWaiter.InitializeReadWaiter(func() *buf.Buffer {
|
||||
buffer = buf.NewSize(FixedPacketSize)
|
||||
buffer.FullReset()
|
||||
return buffer
|
||||
})
|
||||
defer readWaiter.InitializeReadWaiter(nil)
|
||||
for {
|
||||
var message D.Msg
|
||||
var destination M.Socksaddr
|
||||
var err error
|
||||
if len(cached) > 0 {
|
||||
packet := cached[0]
|
||||
cached = cached[1:]
|
||||
for _, counter := range readCounters {
|
||||
counter(int64(packet.Buffer.Len()))
|
||||
}
|
||||
err = message.Unpack(packet.Buffer.Bytes())
|
||||
packet.Buffer.Release()
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
destination = packet.Destination
|
||||
} else {
|
||||
timeout := time.AfterFunc(DNSTimeout, func() {
|
||||
cancel(context.DeadlineExceeded)
|
||||
})
|
||||
destination, err = readWaiter.WaitReadPacket()
|
||||
if err != nil {
|
||||
buffer.Release()
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
for _, counter := range readCounters {
|
||||
counter(int64(buffer.Len()))
|
||||
}
|
||||
err = message.Unpack(buffer.Bytes())
|
||||
buffer.Release()
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
timeout.Stop()
|
||||
}
|
||||
go func() {
|
||||
response, err := d.Exchange(ctx, &message)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
return
|
||||
}
|
||||
responseBuffer := buf.NewPacket()
|
||||
n, err := response.PackBuffer(responseBuffer.FreeBytes())
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
responseBuffer.Release()
|
||||
return
|
||||
}
|
||||
responseBuffer.Truncate(len(n))
|
||||
err = conn.WritePacket(responseBuffer, destination)
|
||||
if err != nil {
|
||||
cancel(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
<-ctx.Done()
|
||||
cancel(nil)
|
||||
conn.Close()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func (d *DNS) newResponse(msg *D.Msg, code int, answer ...netip.Addr) *D.Msg {
|
||||
resp := D.Msg{
|
||||
MsgHdr: D.MsgHdr{
|
||||
Id: msg.Id,
|
||||
Response: true,
|
||||
Rcode: code,
|
||||
},
|
||||
Question: msg.Question,
|
||||
}
|
||||
for _, addr := range answer {
|
||||
var rr D.RR
|
||||
if addr.Is4() {
|
||||
rr = &D.A{
|
||||
Hdr: D.RR_Header{
|
||||
Name: msg.Question[0].Name,
|
||||
Rrtype: D.TypeA,
|
||||
Class: D.ClassINET,
|
||||
Ttl: uint32(FakeTTL / time.Second),
|
||||
Rdlength: 4,
|
||||
},
|
||||
A: addr.AsSlice(),
|
||||
}
|
||||
} else if addr.Is6() {
|
||||
rr = &D.AAAA{
|
||||
Hdr: D.RR_Header{
|
||||
Name: msg.Question[0].Name,
|
||||
Rrtype: D.TypeAAAA,
|
||||
Class: D.ClassINET,
|
||||
Ttl: uint32(FakeTTL / time.Second),
|
||||
Rdlength: 16,
|
||||
},
|
||||
AAAA: addr.AsSlice(),
|
||||
}
|
||||
}
|
||||
resp.Answer = append(resp.Answer, rr)
|
||||
}
|
||||
return &resp
|
||||
}
|
||||
|
||||
func (d *DNS) getAvailableIP4(domain string) (netip.Addr, bool) {
|
||||
d.domainCache4.Lock()
|
||||
defer d.domainCache4.Unlock()
|
||||
d.domainCache4.UnsafeCheck()
|
||||
addr, ok := d.domainCache4.UnsafeLoad(domain)
|
||||
if ok {
|
||||
d.fakeCache.Store(addr, domain, FakeTTL)
|
||||
d.domainCache4.UnsafeStore(domain, addr, FakeTTL)
|
||||
return addr, true
|
||||
}
|
||||
begin := d.currentIP4
|
||||
for {
|
||||
addr = d.currentIP4.Next()
|
||||
if !fakePrefix4.Contains(addr) {
|
||||
addr = fakePrefix4.Addr().Next().Next()
|
||||
}
|
||||
d.currentIP4 = addr
|
||||
if !d.fakeCache.Contains(addr) {
|
||||
d.fakeCache.Store(addr, domain, FakeTTL)
|
||||
d.domainCache4.UnsafeStore(domain, addr, FakeTTL)
|
||||
return addr, true
|
||||
} else if addr == begin {
|
||||
break
|
||||
}
|
||||
}
|
||||
return addr, false
|
||||
}
|
||||
|
||||
func (d *DNS) getAvailableIP6(domain string) (netip.Addr, bool) {
|
||||
d.domainCache6.Lock()
|
||||
defer d.domainCache6.Unlock()
|
||||
d.domainCache6.UnsafeCheck()
|
||||
addr, ok := d.domainCache6.UnsafeLoad(domain)
|
||||
if ok {
|
||||
d.fakeCache.Store(addr, domain, FakeTTL)
|
||||
d.domainCache6.UnsafeStore(domain, addr, FakeTTL)
|
||||
return addr, true
|
||||
}
|
||||
begin := d.currentIP6
|
||||
for {
|
||||
addr = d.currentIP6.Next()
|
||||
if !fakePrefix6.Contains(addr) {
|
||||
addr = fakePrefix6.Addr().Next().Next()
|
||||
}
|
||||
d.currentIP6 = addr
|
||||
if !d.fakeCache.Contains(addr) {
|
||||
d.fakeCache.Store(addr, domain, FakeTTL)
|
||||
d.domainCache6.UnsafeStore(domain, addr, FakeTTL)
|
||||
return addr, true
|
||||
} else if addr == begin {
|
||||
break
|
||||
}
|
||||
}
|
||||
return addr, false
|
||||
}
|
||||
|
||||
func (t *DNS) getServer() M.Socksaddr {
|
||||
if len(t.servers) != 1 {
|
||||
n, err := rand.Int(rand.Reader, big.NewInt(int64(len(t.servers))))
|
||||
if err == nil {
|
||||
return t.servers[n.Uint64()]
|
||||
}
|
||||
}
|
||||
return t.servers[0]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//go:build !with_gvisor
|
||||
|
||||
package tun
|
||||
|
||||
import (
|
||||
tun "github.com/sagernet/sing-tun"
|
||||
)
|
||||
|
||||
type gvisorWaiter struct {
|
||||
stack tun.Stack
|
||||
}
|
||||
|
||||
func (gc gvisorWaiter) Wait() {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//go:build with_gvisor
|
||||
|
||||
package tun
|
||||
|
||||
import (
|
||||
"github.com/modern-go/reflect2"
|
||||
"github.com/sagernet/gvisor/pkg/tcpip/stack"
|
||||
tun "github.com/sagernet/sing-tun"
|
||||
)
|
||||
|
||||
type gvisorWaiter struct {
|
||||
stack tun.Stack
|
||||
}
|
||||
|
||||
func (gc gvisorWaiter) Wait() {
|
||||
if _, ok := gc.stack.(*tun.GVisor); ok {
|
||||
typ := reflect2.TypeOfPtr(gc.stack).Elem().(*reflect2.UnsafeStructType)
|
||||
if field, ok := typ.FieldByName("stack").(*reflect2.UnsafeStructField); ok {
|
||||
value := field.UnsafeGet(reflect2.PtrOf(gc.stack))
|
||||
stack := *(**stack.Stack)(value)
|
||||
stack.Wait()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tun
|
||||
|
||||
import "github.com/v2fly/v2ray-core/v5/common/strmatcher"
|
||||
|
||||
type Matcher []strmatcher.Matcher
|
||||
|
||||
func (mg Matcher) Match(input string) bool {
|
||||
for _, m := range mg {
|
||||
if m.Match(input) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user