Sfoglia il codice sorgente

projects/usb_amr/fw: Add an option to manually generate test ring

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut 1 anno fa
parent
commit
fccbc539d7
3 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 2 0
      projects/usb_amr/fw/fw_app.c
  2. 12 0
      projects/usb_amr/fw/mc97.c
  3. 1 0
      projects/usb_amr/fw/mc97.h

+ 2 - 0
projects/usb_amr/fw/fw_app.c

@@ -146,6 +146,8 @@ main()
 			case 'H': mc97_set_hook(OFF_HOOK);  break;
 			case 'C': mc97_set_hook(CALLER_ID); break;
 
+			case 'n': mc97_test_ring(); break;
+
 			case '0': mc97_set_loopback(MC97_LOOPBACK_NONE);            break;
 			case '1': mc97_set_loopback(MC97_LOOPBACK_DIGITAL_ADC);     break;
 			case '2': mc97_set_loopback(MC97_LOOPBACK_ANALOG_LOCAL);    break;

+ 12 - 0
projects/usb_amr/fw/mc97.c

@@ -66,6 +66,7 @@ static struct {
 	uint16_t rc_46;	/* Cache of reg 0x46 */
 	uint16_t rc_5c; /* Cache of reg 0x5c */
 	uint16_t rc_62; /* Cache of reg 0x62 */
+	bool     test_ring;
 } g_mc97;
 
 
@@ -185,9 +186,20 @@ mc97_set_hook(enum mc97_hook_state s)
 	mc97_regs->gpio_out = gpio_out;
 }
 
+void
+mc97_test_ring(void)
+{
+	g_mc97.test_ring = true;
+}
+
 bool
 mc97_get_ring_detect(void)
 {
+	if (g_mc97.test_ring) {
+		g_mc97.test_ring = false;
+		return true;
+	}
+
 	return (
 		(mc97_regs->gpio_in & (1 << 5)) &&
 		(mc97_regs->csr & MC97_CSR_RFI)

+ 1 - 0
projects/usb_amr/fw/mc97.h

@@ -41,6 +41,7 @@ bool     mc97_select_country(int cc);
 
 void     mc97_set_aux_relay(bool disconnect);
 void     mc97_set_hook(enum mc97_hook_state s);
+void     mc97_test_ring(void);
 bool     mc97_get_ring_detect(void);
 void     mc97_set_loopback(enum mc97_loopback_mode m);